mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 12:35:17 +00:00
getstats: report block sizes for offline domains
The prior refactoring can now be put to use. With the same domain as the earlier commit 7b49926 (one qcow2 disk and an empty cdrom drive): $ virsh domstats --block foo Domain: 'foo' block.count=2 block.0.name=hda block.0.path=/var/lib/libvirt/images/foo.qcow2 block.0.allocation=1309614080 block.0.capacity=42949672960 block.0.physical=1309671424 block.1.name=hdc * src/qemu/qemu_driver.c (qemuDomainGetStatsBlock): Use qemuStorageLimitsRefresh to report offline statistics. Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
8de6544e98
commit
596a137134
@ -18565,6 +18565,7 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
|
||||
virHashTablePtr stats = NULL;
|
||||
qemuDomainObjPrivatePtr priv = dom->privateData;
|
||||
bool abbreviated = false;
|
||||
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
|
||||
|
||||
if (!HAVE_JOB(privflags) || !virDomainObjIsActive(dom)) {
|
||||
abbreviated = true; /* it's ok, just go ahead silently */
|
||||
@ -18594,8 +18595,19 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
|
||||
|
||||
if (abbreviated || !disk->info.alias ||
|
||||
!(entry = virHashLookup(stats, disk->info.alias))) {
|
||||
/* FIXME: we could still look up sizing by sharing code
|
||||
* with qemuDomainGetBlockInfo */
|
||||
if (virStorageSourceIsEmpty(disk->src))
|
||||
continue;
|
||||
if (qemuStorageLimitsRefresh(driver, cfg, dom, disk->src) < 0)
|
||||
goto cleanup;
|
||||
if (disk->src->allocation)
|
||||
QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, i,
|
||||
"allocation", disk->src->allocation);
|
||||
if (disk->src->capacity)
|
||||
QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, i,
|
||||
"capacity", disk->src->capacity);
|
||||
if (disk->src->physical)
|
||||
QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, i,
|
||||
"physical", disk->src->physical);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -18632,6 +18644,7 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
|
||||
|
||||
cleanup:
|
||||
virHashFree(stats);
|
||||
virObjectUnref(cfg);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user