qemu: Don't request nested entries in qemuBlockGetNamedNodeData

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@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2020-01-21 16:51:40 +01:00
parent 855211bbf3
commit 95080cc8b4
5 changed files with 15 additions and 7 deletions

View File

@ -2768,11 +2768,13 @@ qemuBlockGetNamedNodeData(virDomainObjPtr vm,
qemuDomainObjPrivatePtr priv = vm->privateData; qemuDomainObjPrivatePtr priv = vm->privateData;
virQEMUDriverPtr driver = priv->driver; virQEMUDriverPtr driver = priv->driver;
g_autoptr(virHashTable) blockNamedNodeData = NULL; 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) if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
return NULL; return NULL;
blockNamedNodeData = qemuMonitorBlockGetNamedNodeData(priv->mon); blockNamedNodeData = qemuMonitorBlockGetNamedNodeData(priv->mon, supports_flat);
if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockNamedNodeData) if (qemuDomainObjExitMonitor(driver, vm) < 0 || !blockNamedNodeData)
return NULL; return NULL;

View File

@ -2199,17 +2199,20 @@ qemuMonitorBlockStatsUpdateCapacityBlockdev(qemuMonitorPtr mon,
/** /**
* qemuMonitorBlockGetNamedNodeData: * qemuMonitorBlockGetNamedNodeData:
* @mon: monitor object * @mon: monitor object
* @supports_flat: don't query data for backing store
* *
* Uses 'query-named-block-nodes' to retrieve information about individual * Uses 'query-named-block-nodes' to retrieve information about individual
* storage nodes and returns them in a hash table of qemuBlockNamedNodeDataPtrs * storage nodes and returns them in a hash table of qemuBlockNamedNodeDataPtrs
* filled with the data. The hash table keys are node names. * filled with the data. The hash table keys are node names.
*/ */
virHashTablePtr virHashTablePtr
qemuMonitorBlockGetNamedNodeData(qemuMonitorPtr mon) qemuMonitorBlockGetNamedNodeData(qemuMonitorPtr mon,
bool supports_flat)
{ {
QEMU_CHECK_MONITOR_NULL(mon); QEMU_CHECK_MONITOR_NULL(mon);
VIR_DEBUG("supports_flat=%d", supports_flat);
return qemuMonitorJSONBlockGetNamedNodeData(mon); return qemuMonitorJSONBlockGetNamedNodeData(mon, supports_flat);
} }

View File

@ -698,7 +698,8 @@ struct _qemuBlockNamedNodeData {
}; };
virHashTablePtr virHashTablePtr
qemuMonitorBlockGetNamedNodeData(qemuMonitorPtr mon); qemuMonitorBlockGetNamedNodeData(qemuMonitorPtr mon,
bool supports_flat);
int qemuMonitorBlockResize(qemuMonitorPtr mon, int qemuMonitorBlockResize(qemuMonitorPtr mon,
const char *device, const char *device,

View File

@ -3014,11 +3014,12 @@ qemuMonitorJSONBlockGetNamedNodeDataJSON(virJSONValuePtr nodes)
virHashTablePtr virHashTablePtr
qemuMonitorJSONBlockGetNamedNodeData(qemuMonitorPtr mon) qemuMonitorJSONBlockGetNamedNodeData(qemuMonitorPtr mon,
bool supports_flat)
{ {
g_autoptr(virJSONValue) nodes = NULL; g_autoptr(virJSONValue) nodes = NULL;
if (!(nodes = qemuMonitorJSONQueryNamedBlockNodes(mon, false))) if (!(nodes = qemuMonitorJSONQueryNamedBlockNodes(mon, supports_flat)))
return NULL; return NULL;
return qemuMonitorJSONBlockGetNamedNodeDataJSON(nodes); return qemuMonitorJSONBlockGetNamedNodeDataJSON(nodes);

View File

@ -91,7 +91,8 @@ virHashTablePtr
qemuMonitorJSONBlockGetNamedNodeDataJSON(virJSONValuePtr nodes); qemuMonitorJSONBlockGetNamedNodeDataJSON(virJSONValuePtr nodes);
virHashTablePtr virHashTablePtr
qemuMonitorJSONBlockGetNamedNodeData(qemuMonitorPtr mon); qemuMonitorJSONBlockGetNamedNodeData(qemuMonitorPtr mon,
bool supports_flat);
int qemuMonitorJSONBlockResize(qemuMonitorPtr mon, int qemuMonitorJSONBlockResize(qemuMonitorPtr mon,
const char *device, const char *device,