Use the 'flat' flag for 'query-named-block-nodes' if qemu supports QEMU_CAPS_QMP_QUERY_NAMED_BLOCK_NODES_FLAT in qemuBlockGetNamedNodeData. We don't need the data so plumb in whether qemu supports the 'flat' output. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_block.c | 4 +++- src/qemu/qemu_monitor.c | 7 +++++-- src/qemu/qemu_monitor.h | 3 ++- src/qemu/qemu_monitor_json.c | 5 +++-- src/qemu/qemu_monitor_json.h | 3 ++- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 5bd5c955a4..152c73f1bf 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -2768,11 +2768,13 @@ qemuBlockGetNamedNodeData(virDomainObjPtr vm, qemuDomainObjPrivatePtr priv = vm->privateData; virQEMUDriverPtr driver = priv->driver; g_autoptr(virHashTable) blockNamedNodeData = NULL; + bool supports_flat = virQEMUCapsGet(priv->qemuCaps, + QEMU_CAPS_QMP_QUERY_NAMED_BLOCK_NODES_FLAT); if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0) return NULL; - blockNamedNodeData = qemuMonitorBlockGetNamedNodeData(priv->mon); + blockNamedNodeData = qemuMonitorBlockGetNamedNodeData(priv->mon, supports_flat); if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockNamedNodeData) return NULL; diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c index 6a543a3093..c2a61ec587 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c @@ -2199,17 +2199,20 @@ qemuMonitorBlockStatsUpdateCapacityBlockdev(qemuMonitorPtr mon, /** * qemuMonitorBlockGetNamedNodeData: * @mon: monitor object + * @supports_flat: don't query data for backing store * * Uses 'query-named-block-nodes' to retrieve information about individual * storage nodes and returns them in a hash table of qemuBlockNamedNodeDataPtrs * filled with the data. The hash table keys are node names. */ virHashTablePtr -qemuMonitorBlockGetNamedNodeData(qemuMonitorPtr mon) +qemuMonitorBlockGetNamedNodeData(qemuMonitorPtr mon, + bool supports_flat) { QEMU_CHECK_MONITOR_NULL(mon); + VIR_DEBUG("supports_flat=%d", supports_flat); - return qemuMonitorJSONBlockGetNamedNodeData(mon); + return qemuMonitorJSONBlockGetNamedNodeData(mon, supports_flat); } diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h index fb09f6606f..4e06447ffa 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h @@ -698,7 +698,8 @@ struct _qemuBlockNamedNodeData { }; virHashTablePtr -qemuMonitorBlockGetNamedNodeData(qemuMonitorPtr mon); +qemuMonitorBlockGetNamedNodeData(qemuMonitorPtr mon, + bool supports_flat); int qemuMonitorBlockResize(qemuMonitorPtr mon, const char *device, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 5ae8d783ee..451e1afef5 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -3014,11 +3014,12 @@ qemuMonitorJSONBlockGetNamedNodeDataJSON(virJSONValuePtr nodes) virHashTablePtr -qemuMonitorJSONBlockGetNamedNodeData(qemuMonitorPtr mon) +qemuMonitorJSONBlockGetNamedNodeData(qemuMonitorPtr mon, + bool supports_flat) { g_autoptr(virJSONValue) nodes = NULL; - if (!(nodes = qemuMonitorJSONQueryNamedBlockNodes(mon, false))) + if (!(nodes = qemuMonitorJSONQueryNamedBlockNodes(mon, supports_flat))) return NULL; return qemuMonitorJSONBlockGetNamedNodeDataJSON(nodes); diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h index 71aaa471e1..ed48600b82 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h @@ -91,7 +91,8 @@ virHashTablePtr qemuMonitorJSONBlockGetNamedNodeDataJSON(virJSONValuePtr nodes); virHashTablePtr -qemuMonitorJSONBlockGetNamedNodeData(qemuMonitorPtr mon); +qemuMonitorJSONBlockGetNamedNodeData(qemuMonitorPtr mon, + bool supports_flat); int qemuMonitorJSONBlockResize(qemuMonitorPtr mon, const char *device, -- 2.24.1