Rather than totalling every entry from 'query-block' for stats provided
by qemuDomainBlocksStatsGather total only stats for known disks. This
will allow to return data for nodenames and qdevs in the same hash so
that we can use them with -blockdev.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
src/qemu/qemu_driver.c | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index f36d4dc37f..e18187b7bb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11023,13 +11023,9 @@ qemuDomainBlockResize(virDomainPtr dom,
static int
-qemuDomainBlockStatsGatherTotals(void *payload,
- const void *name ATTRIBUTE_UNUSED,
- void *opaque)
+qemuDomainBlockStatsGatherTotals(qemuBlockStatsPtr data,
+ qemuBlockStatsPtr total)
{
- qemuBlockStatsPtr data = payload;
- qemuBlockStatsPtr total = opaque;
-
#define QEMU_BLOCK_STAT_TOTAL(NAME) \
if (data->NAME > 0) \
total->NAME += data->NAME
@@ -11070,6 +11066,7 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver,
virDomainDiskDefPtr disk;
virHashTablePtr blockstats = NULL;
qemuBlockStatsPtr stats;
+ size_t i;
int nstats;
const char *entryname = NULL;
int ret = -1;
@@ -11111,7 +11108,21 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver,
**retstats = *stats;
} else {
- virHashForEach(blockstats, qemuDomainBlockStatsGatherTotals, *retstats);
+ for (i = 0; i < vm->def->ndisks; i++) {
+ disk = vm->def->disks[i];
+ entryname = disk->info.alias;
+
+ if (!entryname)
+ continue;
+
+ if (!(stats = virHashLookup(blockstats, entryname))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("cannot find statistics for device
'%s'"), entryname);
+ goto cleanup;
+ }
+
+ qemuDomainBlockStatsGatherTotals(stats, *retstats);
+ }
}
ret = nstats;
--
2.16.2