mirror of https://gitee.com/openkylin/libvirt.git
qemuMonitorJSONQueryBlockstats: query stats for helper images
Use the 'query-nodes' flag to return all stats. The flag was introduced prior to qemu-2.11 so we can always use it, but we invoke it only when querying stats. The other invocation is used for detecting the nodenames which is fragile code. The images without a frontend don't have the device field so the extraction code checks need to be relaxed. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
6448470eca
commit
bc24810c2c
|
@ -2038,14 +2038,14 @@ qemuMonitorGetBlockInfo(qemuMonitor *mon)
|
|||
* qemuMonitorQueryBlockstats:
|
||||
* @mon: monitor object
|
||||
*
|
||||
* Returns data from a call to 'query-blockstats'.
|
||||
* Returns data from a call to 'query-blockstats' without using 'query-nodes'
|
||||
*/
|
||||
virJSONValue *
|
||||
qemuMonitorQueryBlockstats(qemuMonitor *mon)
|
||||
{
|
||||
QEMU_CHECK_MONITOR_NULL(mon);
|
||||
|
||||
return qemuMonitorJSONQueryBlockstats(mon);
|
||||
return qemuMonitorJSONQueryBlockstats(mon, false);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2430,12 +2430,15 @@ qemuMonitorJSONGetOneBlockStatsInfo(virJSONValue *dev,
|
|||
|
||||
|
||||
virJSONValue *
|
||||
qemuMonitorJSONQueryBlockstats(qemuMonitor *mon)
|
||||
qemuMonitorJSONQueryBlockstats(qemuMonitor *mon,
|
||||
bool queryNodes)
|
||||
{
|
||||
g_autoptr(virJSONValue) cmd = NULL;
|
||||
g_autoptr(virJSONValue) reply = NULL;
|
||||
|
||||
if (!(cmd = qemuMonitorJSONMakeCommand("query-blockstats", NULL)))
|
||||
if (!(cmd = qemuMonitorJSONMakeCommand("query-blockstats",
|
||||
"B:query-nodes", queryNodes,
|
||||
NULL)))
|
||||
return NULL;
|
||||
|
||||
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
|
||||
|
@ -2457,7 +2460,7 @@ qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitor *mon,
|
|||
size_t i;
|
||||
g_autoptr(virJSONValue) devices = NULL;
|
||||
|
||||
if (!(devices = qemuMonitorJSONQueryBlockstats(mon)))
|
||||
if (!(devices = qemuMonitorJSONQueryBlockstats(mon, true)))
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < virJSONValueArraySize(devices); i++) {
|
||||
|
@ -2471,16 +2474,11 @@ qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitor *mon,
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (!(dev_name = virJSONValueObjectGetString(dev, "device"))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("blockstats device entry was not "
|
||||
"in expected format"));
|
||||
return -1;
|
||||
if ((dev_name = virJSONValueObjectGetString(dev, "device"))) {
|
||||
if (*dev_name == '\0')
|
||||
dev_name = NULL;
|
||||
}
|
||||
|
||||
if (*dev_name == '\0')
|
||||
dev_name = NULL;
|
||||
|
||||
rc = qemuMonitorJSONGetOneBlockStatsInfo(dev, dev_name, 0, hash);
|
||||
|
||||
if (rc < 0)
|
||||
|
|
|
@ -75,7 +75,8 @@ int qemuMonitorJSONSetMemoryStatsPeriod(qemuMonitor *mon,
|
|||
int qemuMonitorJSONGetBlockInfo(qemuMonitor *mon,
|
||||
GHashTable *table);
|
||||
|
||||
virJSONValue *qemuMonitorJSONQueryBlockstats(qemuMonitor *mon);
|
||||
virJSONValue *qemuMonitorJSONQueryBlockstats(qemuMonitor *mon,
|
||||
bool queryNodes);
|
||||
int qemuMonitorJSONGetAllBlockStatsInfo(qemuMonitor *mon,
|
||||
GHashTable *hash);
|
||||
int qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitor *mon,
|
||||
|
|
Loading…
Reference in New Issue