提交 b222ce30 编写于 作者: P Peter Krempa

qemu: Explicitly find disks for stats totals

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: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 93fad53d
...@@ -11021,13 +11021,9 @@ qemuDomainBlockResize(virDomainPtr dom, ...@@ -11021,13 +11021,9 @@ qemuDomainBlockResize(virDomainPtr dom,
static int static int
qemuDomainBlockStatsGatherTotals(void *payload, qemuDomainBlockStatsGatherTotals(qemuBlockStatsPtr data,
const void *name ATTRIBUTE_UNUSED, qemuBlockStatsPtr total)
void *opaque)
{ {
qemuBlockStatsPtr data = payload;
qemuBlockStatsPtr total = opaque;
#define QEMU_BLOCK_STAT_TOTAL(NAME) \ #define QEMU_BLOCK_STAT_TOTAL(NAME) \
if (data->NAME > 0) \ if (data->NAME > 0) \
total->NAME += data->NAME total->NAME += data->NAME
...@@ -11068,6 +11064,7 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver, ...@@ -11068,6 +11064,7 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver,
virDomainDiskDefPtr disk; virDomainDiskDefPtr disk;
virHashTablePtr blockstats = NULL; virHashTablePtr blockstats = NULL;
qemuBlockStatsPtr stats; qemuBlockStatsPtr stats;
size_t i;
int nstats; int nstats;
const char *entryname = NULL; const char *entryname = NULL;
int ret = -1; int ret = -1;
...@@ -11109,7 +11106,21 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver, ...@@ -11109,7 +11106,21 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver,
**retstats = *stats; **retstats = *stats;
} else { } 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; ret = nstats;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册