mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 20:45:18 +00:00
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: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
b785cec0dc
commit
364a77ff0f
@ -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 */
|
||||
|
Loading…
x
Reference in New Issue
Block a user