mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
getstats: start giving offline block stats
I noticed that for an offline domain, 'virsh domstats --block $dom' was producing just the domain name, with no stats. But the older 'virsh domblkinfo' works just fine on offline domains. This patch starts to get us closer, by at least reporting the disk names for an offline domain. With this patch, I now see the following for an offline domain with one qcow2 disk and an empty cdrom drive: $ virsh domstats --block foo Domain: 'foo' block.count=2 block.0.name=hda block.1.name=hdc * src/qemu/qemu_driver.c (qemuDomainGetStatsBlock): Don't short-circuit output of block name. Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
f301fe77c6
commit
56b21dfe0c
@ -18495,19 +18495,20 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
|
||||
int rc;
|
||||
virHashTablePtr stats = NULL;
|
||||
qemuDomainObjPrivatePtr priv = dom->privateData;
|
||||
bool abbreviated = false;
|
||||
|
||||
if (!HAVE_JOB(privflags) || !virDomainObjIsActive(dom))
|
||||
return 0; /* it's ok, just go ahead silently */
|
||||
if (!HAVE_JOB(privflags) || !virDomainObjIsActive(dom)) {
|
||||
abbreviated = true; /* it's ok, just go ahead silently */
|
||||
} else {
|
||||
qemuDomainObjEnterMonitor(driver, dom);
|
||||
rc = qemuMonitorGetAllBlockStatsInfo(priv->mon, &stats);
|
||||
ignore_value(qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats));
|
||||
qemuDomainObjExitMonitor(driver, dom);
|
||||
|
||||
qemuDomainObjEnterMonitor(driver, dom);
|
||||
rc = qemuMonitorGetAllBlockStatsInfo(priv->mon, &stats);
|
||||
ignore_value(qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats));
|
||||
qemuDomainObjExitMonitor(driver, dom);
|
||||
|
||||
if (rc < 0) {
|
||||
virResetLastError();
|
||||
ret = 0; /* still ok, again go ahead silently */
|
||||
goto cleanup;
|
||||
if (rc < 0) {
|
||||
virResetLastError();
|
||||
abbreviated = true; /* still ok, again go ahead silently */
|
||||
}
|
||||
}
|
||||
|
||||
QEMU_ADD_COUNT_PARAM(record, maxparams, "block", dom->def->ndisks);
|
||||
@ -18518,9 +18519,12 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
|
||||
|
||||
QEMU_ADD_NAME_PARAM(record, maxparams, "block", i, disk->dst);
|
||||
|
||||
if (!disk->info.alias ||
|
||||
!(entry = virHashLookup(stats, disk->info.alias)))
|
||||
if (abbreviated || !disk->info.alias ||
|
||||
!(entry = virHashLookup(stats, disk->info.alias))) {
|
||||
/* FIXME: we could still look up sizing by sharing code
|
||||
* with qemuDomainGetBlockInfo */
|
||||
continue;
|
||||
}
|
||||
|
||||
QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, i,
|
||||
"rd.reqs", entry->rd_req);
|
||||
|
Loading…
x
Reference in New Issue
Block a user