提交 364a77ff 编写于 作者: D Daniel P. Berrange

Add a qemuMonitorGetTargetArch() method for QMP query-target command

Add a new qemuMonitorGetTargetArch() method to support invocation
of the 'query-target' JSON monitor command. No HMP equivalent
is required, since this will only be present for QEMU >= 1.2
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 b785cec0
......@@ -3186,3 +3186,24 @@ int qemuMonitorGetObjectProps(qemuMonitorPtr mon,
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);
}
......@@ -606,7 +606,7 @@ int qemuMonitorGetObjectTypes(qemuMonitorPtr 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
......
......@@ -4374,3 +4374,48 @@ cleanup:
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;
}
......@@ -312,5 +312,6 @@ int qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon,
const char *type,
char ***props)
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
char *qemuMonitorJSONGetTargetArch(qemuMonitorPtr mon);
#endif /* QEMU_MONITOR_JSON_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册