1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-07 17:28:15 +00:00

qemu: blockstats: Add support for totalled block statistics

In the LXC driver, if the disk path is not provided the API returns
total statistics for all disks of the domain. With the new text monitor
implementation this can be now done in the qemu driver too.

Add code that wil total the stats for all disks if the path is not
provided.
This commit is contained in:
Peter Krempa 2015-03-10 15:54:17 +01:00
parent 79966411cd
commit cf093414c5

View File

@ -10481,6 +10481,30 @@ qemuDomainBlockResize(virDomainPtr dom,
} }
static void
qemuDomainBlockStatsGatherTotals(void *payload,
const void *name ATTRIBUTE_UNUSED,
void *opaque)
{
qemuBlockStatsPtr data = payload;
qemuBlockStatsPtr total = opaque;
#define QEMU_BLOCK_STAT_TOTAL(NAME) \
if (data->NAME > 0) \
total->NAME += data->NAME
QEMU_BLOCK_STAT_TOTAL(wr_bytes);
QEMU_BLOCK_STAT_TOTAL(wr_req);
QEMU_BLOCK_STAT_TOTAL(rd_bytes);
QEMU_BLOCK_STAT_TOTAL(rd_req);
QEMU_BLOCK_STAT_TOTAL(flush_req);
QEMU_BLOCK_STAT_TOTAL(wr_total_times);
QEMU_BLOCK_STAT_TOTAL(rd_total_times);
QEMU_BLOCK_STAT_TOTAL(flush_total_times);
#undef QEMU_BLOCK_STAT_TOTAL
}
/** /**
* qemuDomainBlocksStatsGather: * qemuDomainBlocksStatsGather:
* @driver: driver object * @driver: driver object
@ -10523,10 +10547,6 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver,
if (VIR_STRDUP(diskAlias, disk->info.alias) < 0) if (VIR_STRDUP(diskAlias, disk->info.alias) < 0)
goto cleanup; goto cleanup;
} else {
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s",
_("summary statistics are not supported yet"));
goto cleanup;
} }
qemuDomainObjEnterMonitor(driver, vm); qemuDomainObjEnterMonitor(driver, vm);
@ -10537,6 +10557,7 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver,
if (VIR_ALLOC(*retstats) < 0) if (VIR_ALLOC(*retstats) < 0)
goto cleanup; goto cleanup;
if (diskAlias) {
if (!(stats = virHashLookup(blockstats, diskAlias))) { if (!(stats = virHashLookup(blockstats, diskAlias))) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("cannot find statistics for device '%s'"), diskAlias); _("cannot find statistics for device '%s'"), diskAlias);
@ -10544,6 +10565,9 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver,
} }
**retstats = *stats; **retstats = *stats;
} else {
virHashForEach(blockstats, qemuDomainBlockStatsGatherTotals, *retstats);
}
ret = nstats; ret = nstats;