Now that we've gotten rid of misleading names we can introduce
qemuMonitorGetObjectProps() function which queries -object
properties. Again, some parts of code can be reused.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_monitor.c | 13 ++++++++++
src/qemu/qemu_monitor.h | 3 +++
src/qemu/qemu_monitor_json.c | 62 ++++++++++++++++++++++++++++++++++----------
src/qemu/qemu_monitor_json.h | 4 +++
4 files changed, 68 insertions(+), 14 deletions(-)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 8a4350f6b2..278c2ec517 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3954,6 +3954,19 @@ qemuMonitorGetDeviceProps(qemuMonitorPtr mon,
}
+int
+qemuMonitorGetObjectProps(qemuMonitorPtr mon,
+ const char *object,
+ char ***props)
+{
+ VIR_DEBUG("object=%s props=%p", object, props);
+
+ QEMU_CHECK_MONITOR_JSON(mon);
+
+ return qemuMonitorJSONGetObjectProps(mon, object, props);
+}
+
+
char *
qemuMonitorGetTargetArch(qemuMonitorPtr mon)
{
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index b797ea800e..94620b2b76 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1097,6 +1097,9 @@ int qemuMonitorGetObjectTypes(qemuMonitorPtr mon,
int qemuMonitorGetDeviceProps(qemuMonitorPtr mon,
const char *device,
char ***props);
+int qemuMonitorGetObjectProps(qemuMonitorPtr mon,
+ const char *object,
+ char ***props);
char *qemuMonitorGetTargetArch(qemuMonitorPtr mon);
int qemuMonitorNBDServerStart(qemuMonitorPtr mon,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index a90762a4ff..31992c5bee 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -6033,29 +6033,23 @@ int qemuMonitorJSONSetObjectProperty(qemuMonitorPtr mon,
#undef MAKE_SET_CMD
-int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon,
- const char *device,
- char ***props)
+static int
+qemuMonitorJSONParsePropsList(qemuMonitorPtr mon,
+ virJSONValuePtr cmd,
+ char ***props)
{
- int ret = -1;
- virJSONValuePtr cmd;
virJSONValuePtr reply = NULL;
virJSONValuePtr data;
char **proplist = NULL;
ssize_t n = 0;
size_t i;
-
- *props = NULL;
-
- if (!(cmd = qemuMonitorJSONMakeCommand("device-list-properties",
- "s:typename", device,
- NULL)))
- return -1;
+ int ret = -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
goto cleanup;
- if (qemuMonitorJSONHasError(reply, "DeviceNotFound")) {
+ if (qemuMonitorJSONHasError(reply, "DeviceNotFound") ||
+ qemuMonitorJSONHasError(reply, "CommandNotFound")) {
ret = 0;
goto cleanup;
}
@@ -6090,12 +6084,52 @@ int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon,
cleanup:
virStringListFree(proplist);
- virJSONValueFree(cmd);
virJSONValueFree(reply);
return ret;
}
+int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon,
+ const char *device,
+ char ***props)
+{
+ int ret = -1;
+ virJSONValuePtr cmd;
+
+ *props = NULL;
+
+ if (!(cmd = qemuMonitorJSONMakeCommand("device-list-properties",
+ "s:typename", device,
+ NULL)))
+ return -1;
+
+ ret = qemuMonitorJSONParsePropsList(mon, cmd, props);
+ virJSONValueFree(cmd);
+ return ret;
+}
+
+
+int
+qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon,
+ const char *object,
+ char ***props)
+{
+ int ret = -1;
+ virJSONValuePtr cmd;
+
+ *props = NULL;
+
+ if (!(cmd = qemuMonitorJSONMakeCommand("qom-list-properties",
+ "s:typename", object,
+ NULL)))
+ return -1;
+
+ ret = qemuMonitorJSONParsePropsList(mon, cmd, props);
+ virJSONValueFree(cmd);
+ return ret;
+}
+
+
char *
qemuMonitorJSONGetTargetArch(qemuMonitorPtr mon)
{
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index df91b0b5dc..e2826ae4c6 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -445,6 +445,10 @@ int qemuMonitorJSONGetDeviceProps(qemuMonitorPtr mon,
const char *device,
char ***props)
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
+int qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon,
+ const char *object,
+ char ***props)
+ ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
char *qemuMonitorJSONGetTargetArch(qemuMonitorPtr mon);
int qemuMonitorJSONNBDServerStart(qemuMonitorPtr mon,
--
2.16.1