mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 11:35:19 +00:00
qemu: Extract exporting of disk block statistics
Split out the code which converts the stats gathered in qemuDomainGetStatsBlock into typed parameters so that it will look less ugly when extending it. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
196104b91f
commit
1b3a4c807c
@ -20148,6 +20148,51 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
qemuDomainGetStatsBlockExportDisk(virDomainDiskDefPtr disk,
|
||||||
|
virHashTablePtr stats,
|
||||||
|
virHashTablePtr nodestats,
|
||||||
|
virDomainStatsRecordPtr records,
|
||||||
|
int *nrecords,
|
||||||
|
size_t *recordnr,
|
||||||
|
bool visitBacking,
|
||||||
|
virQEMUDriverPtr driver,
|
||||||
|
virQEMUDriverConfigPtr cfg,
|
||||||
|
virDomainObjPtr dom)
|
||||||
|
|
||||||
|
{
|
||||||
|
char *alias = NULL;
|
||||||
|
virStorageSourcePtr src = disk->src;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
while (virStorageSourceIsBacking(src) &&
|
||||||
|
(src == disk->src || visitBacking)) {
|
||||||
|
|
||||||
|
/* alias may be NULL if the VM is not running */
|
||||||
|
if (disk->info.alias &&
|
||||||
|
!(alias = qemuDomainStorageAlias(disk->info.alias, src->id)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
qemuDomainGetStatsOneBlockRefreshNamed(src, alias, stats, nodestats);
|
||||||
|
|
||||||
|
if (qemuDomainGetStatsOneBlock(driver, cfg, dom, records, nrecords,
|
||||||
|
disk->dst, alias, src, *recordnr,
|
||||||
|
stats) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
VIR_FREE(alias);
|
||||||
|
(*recordnr)++;
|
||||||
|
src = src->backingStore;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
VIR_FREE(alias);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
|
qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
|
||||||
virDomainObjPtr dom,
|
virDomainObjPtr dom,
|
||||||
@ -20168,7 +20213,6 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
|
|||||||
int count_index = -1;
|
int count_index = -1;
|
||||||
size_t visited = 0;
|
size_t visited = 0;
|
||||||
bool visitBacking = !!(privflags & QEMU_DOMAIN_STATS_BACKING);
|
bool visitBacking = !!(privflags & QEMU_DOMAIN_STATS_BACKING);
|
||||||
char *alias = NULL;
|
|
||||||
|
|
||||||
if (HAVE_JOB(privflags) && virDomainObjIsActive(dom)) {
|
if (HAVE_JOB(privflags) && virDomainObjIsActive(dom)) {
|
||||||
qemuDomainObjEnterMonitor(driver, dom);
|
qemuDomainObjEnterMonitor(driver, dom);
|
||||||
@ -20200,35 +20244,16 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
|
|||||||
QEMU_ADD_COUNT_PARAM(record, maxparams, "block", 0);
|
QEMU_ADD_COUNT_PARAM(record, maxparams, "block", 0);
|
||||||
|
|
||||||
for (i = 0; i < dom->def->ndisks; i++) {
|
for (i = 0; i < dom->def->ndisks; i++) {
|
||||||
virDomainDiskDefPtr disk = dom->def->disks[i];
|
if (qemuDomainGetStatsBlockExportDisk(dom->def->disks[i], stats, nodestats,
|
||||||
virStorageSourcePtr src = disk->src;
|
record, maxparams, &visited,
|
||||||
|
visitBacking, driver, cfg, dom) < 0)
|
||||||
while (virStorageSourceIsBacking(src) &&
|
goto cleanup;
|
||||||
(src == disk->src || visitBacking)) {
|
|
||||||
|
|
||||||
/* alias may be NULL if the VM is not running */
|
|
||||||
if (disk->info.alias &&
|
|
||||||
!(alias = qemuDomainStorageAlias(disk->info.alias, src->id)))
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
qemuDomainGetStatsOneBlockRefreshNamed(src, alias, stats, nodestats);
|
|
||||||
|
|
||||||
if (qemuDomainGetStatsOneBlock(driver, cfg, dom, record, maxparams,
|
|
||||||
disk->dst, alias, src, visited,
|
|
||||||
stats) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
|
|
||||||
VIR_FREE(alias);
|
|
||||||
visited++;
|
|
||||||
src = src->backingStore;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
record->params[count_index].value.ui = visited;
|
record->params[count_index].value.ui = visited;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(alias);
|
|
||||||
virHashFree(stats);
|
virHashFree(stats);
|
||||||
virHashFree(nodestats);
|
virHashFree(nodestats);
|
||||||
virJSONValueFree(nodedata);
|
virJSONValueFree(nodedata);
|
||||||
|
Loading…
Reference in New Issue
Block a user