Add monitor tooling for calling query-named-block-nodes. The monitor
returns the data as the raw JSON array that is returned from the
monitor.
Unfortunately the logic to extract the node names for a complete backing
chain will be so complex that I won't be able to extract any meaningful
subset of the data in the monitor code.
---
src/qemu/qemu_monitor.c | 11 +++++++++++
src/qemu/qemu_monitor.h | 1 +
src/qemu/qemu_monitor_json.c | 26 ++++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 3 +++
4 files changed, 41 insertions(+)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index e2af0ca02..36b8b5ea4 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -4184,3 +4184,14 @@ qemuMonitorSetBlockThreshold(qemuMonitorPtr mon,
return qemuMonitorJSONSetBlockThreshold(mon, nodename, threshold);
}
+
+
+virJSONValuePtr
+qemuMonitorQueryNamedBlockNodes(qemuMonitorPtr mon)
+{
+ VIR_DEBUG("mon=%p", mon);
+
+ QEMU_CHECK_MONITOR_JSON_NULL(mon);
+
+ return qemuMonitorJSONQueryNamedBlockNodes(mon);
+}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 61d89a9cf..77e7aeeca 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -1076,5 +1076,6 @@ int qemuMonitorSetBlockThreshold(qemuMonitorPtr mon,
const char *nodename,
unsigned long long threshold);
+virJSONValuePtr qemuMonitorQueryNamedBlockNodes(qemuMonitorPtr mon);
#endif /* QEMU_MONITOR_H */
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 6fb2af48a..141d56b3d 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -7518,3 +7518,29 @@ qemuMonitorJSONSetBlockThreshold(qemuMonitorPtr mon,
return ret;
}
+
+
+virJSONValuePtr
+qemuMonitorJSONQueryNamedBlockNodes(qemuMonitorPtr mon)
+{
+ virJSONValuePtr cmd;
+ virJSONValuePtr reply = NULL;
+ virJSONValuePtr ret = NULL;
+
+ if (!(cmd = qemuMonitorJSONMakeCommand("query-named-block-nodes", NULL)))
+ return NULL;
+
+ if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
+ goto cleanup;
+
+ if (qemuMonitorJSONCheckError(cmd, reply) < 0)
+ goto cleanup;
+
+ ret = virJSONValueObjectStealArray(reply, "return");
+
+ cleanup:
+ virJSONValueFree(cmd);
+ virJSONValueFree(reply);
+
+ return ret;
+}
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index e0dd696d9..9c363a0a1 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -517,4 +517,7 @@ int qemuMonitorJSONSetBlockThreshold(qemuMonitorPtr mon,
unsigned long long threshold)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
+virJSONValuePtr qemuMonitorJSONQueryNamedBlockNodes(qemuMonitorPtr mon)
+ ATTRIBUTE_NONNULL(1);
+
#endif /* QEMU_MONITOR_JSON_H */
--
2.12.0