return qemuMonitorJSONGetObjectProps(mon, type, props);
}
+
+
+char *qemuMonitorGetTargetArch(qemuMonitorPtr mon)
+{
+ VIR_DEBUG("mon=%p",
+ mon);
+
+ if (!mon) {
+ virReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("monitor must not be NULL"));
+ return NULL;
+ }
+
+ if (!mon->json) {
+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+ _("JSON monitor is required"));
+ return NULL;
+ }
+
+ return qemuMonitorJSONGetTargetArch(mon);
+}
int qemuMonitorGetObjectProps(qemuMonitorPtr mon,
const char *type,
char ***props);
-
+char *qemuMonitorGetTargetArch(qemuMonitorPtr mon);
/**
* When running two dd process and using <> redirection, we need a
virJSONValueFree(reply);
return ret;
}
+
+
+char *
+qemuMonitorJSONGetTargetArch(qemuMonitorPtr mon)
+{
+ char *ret = NULL;
+ int rv;
+ const char *arch;
+ virJSONValuePtr cmd;
+ virJSONValuePtr reply = NULL;
+ virJSONValuePtr data;
+
+ if (!(cmd = qemuMonitorJSONMakeCommand("query-target", NULL)))
+ return NULL;
+
+ rv = qemuMonitorJSONCommand(mon, cmd, &reply);
+
+ if (rv == 0)
+ rv = qemuMonitorJSONCheckError(cmd, reply);
+
+ if (rv < 0)
+ goto cleanup;
+
+ if (!(data = virJSONValueObjectGet(reply, "return"))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("query-target reply was missing return data"));
+ goto cleanup;
+ }
+
+ if (!(arch = virJSONValueObjectGetString(data, "arch"))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("query-target reply was missing arch data"));
+ goto cleanup;
+ }
+
+ if (!(ret = strdup(arch))) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+cleanup:
+ virJSONValueFree(cmd);
+ virJSONValueFree(reply);
+ return ret;
+}