|
|
9119d9 |
From b80814d0e06895d7dce41eb3c65b88fa4ee604b1 Mon Sep 17 00:00:00 2001
|
|
|
9119d9 |
Message-Id: <b80814d0e06895d7dce41eb3c65b88fa4ee604b1@dist-git>
|
|
|
9119d9 |
From: Eric Blake <eblake@redhat.com>
|
|
|
9119d9 |
Date: Wed, 17 Dec 2014 03:09:01 -0700
|
|
|
9119d9 |
Subject: [PATCH] getstats: start giving offline block stats
|
|
|
9119d9 |
|
|
|
9119d9 |
https://bugzilla.redhat.com/show_bug.cgi?id=1041569
|
|
|
9119d9 |
|
|
|
9119d9 |
I noticed that for an offline domain, 'virsh domstats --block $dom'
|
|
|
9119d9 |
was producing just the domain name, with no stats. But the older
|
|
|
9119d9 |
'virsh domblkinfo' works just fine on offline domains. This patch
|
|
|
9119d9 |
starts to get us closer, by at least reporting the disk names for
|
|
|
9119d9 |
an offline domain.
|
|
|
9119d9 |
|
|
|
9119d9 |
With this patch, I now see the following for an offline domain
|
|
|
9119d9 |
with one qcow2 disk and an empty cdrom drive:
|
|
|
9119d9 |
$ virsh domstats --block foo
|
|
|
9119d9 |
Domain: 'foo'
|
|
|
9119d9 |
block.count=2
|
|
|
9119d9 |
block.0.name=hda
|
|
|
9119d9 |
block.1.name=hdc
|
|
|
9119d9 |
|
|
|
9119d9 |
* src/qemu/qemu_driver.c (qemuDomainGetStatsBlock): Don't short-circuit
|
|
|
9119d9 |
output of block name.
|
|
|
9119d9 |
|
|
|
9119d9 |
Signed-off-by: Eric Blake <eblake@redhat.com>
|
|
|
9119d9 |
(cherry picked from commit 56b21dfe0c12867fa1dc3715145a61017e6928f1)
|
|
|
9119d9 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
9119d9 |
---
|
|
|
9119d9 |
src/qemu/qemu_driver.c | 30 +++++++++++++++++-------------
|
|
|
9119d9 |
1 file changed, 17 insertions(+), 13 deletions(-)
|
|
|
9119d9 |
|
|
|
9119d9 |
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
|
|
|
9119d9 |
index 33a93f1..f0935d6 100644
|
|
|
9119d9 |
--- a/src/qemu/qemu_driver.c
|
|
|
9119d9 |
+++ b/src/qemu/qemu_driver.c
|
|
|
9119d9 |
@@ -18019,19 +18019,20 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
|
|
|
9119d9 |
int rc;
|
|
|
9119d9 |
virHashTablePtr stats = NULL;
|
|
|
9119d9 |
qemuDomainObjPrivatePtr priv = dom->privateData;
|
|
|
9119d9 |
+ bool abbreviated = false;
|
|
|
9119d9 |
|
|
|
9119d9 |
- if (!HAVE_JOB(privflags) || !virDomainObjIsActive(dom))
|
|
|
9119d9 |
- return 0; /* it's ok, just go ahead silently */
|
|
|
9119d9 |
+ if (!HAVE_JOB(privflags) || !virDomainObjIsActive(dom)) {
|
|
|
9119d9 |
+ abbreviated = true; /* it's ok, just go ahead silently */
|
|
|
9119d9 |
+ } else {
|
|
|
9119d9 |
+ qemuDomainObjEnterMonitor(driver, dom);
|
|
|
9119d9 |
+ rc = qemuMonitorGetAllBlockStatsInfo(priv->mon, &stats);
|
|
|
9119d9 |
+ ignore_value(qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats));
|
|
|
9119d9 |
+ qemuDomainObjExitMonitor(driver, dom);
|
|
|
9119d9 |
|
|
|
9119d9 |
- qemuDomainObjEnterMonitor(driver, dom);
|
|
|
9119d9 |
- rc = qemuMonitorGetAllBlockStatsInfo(priv->mon, &stats);
|
|
|
9119d9 |
- ignore_value(qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats));
|
|
|
9119d9 |
- qemuDomainObjExitMonitor(driver, dom);
|
|
|
9119d9 |
-
|
|
|
9119d9 |
- if (rc < 0) {
|
|
|
9119d9 |
- virResetLastError();
|
|
|
9119d9 |
- ret = 0; /* still ok, again go ahead silently */
|
|
|
9119d9 |
- goto cleanup;
|
|
|
9119d9 |
+ if (rc < 0) {
|
|
|
9119d9 |
+ virResetLastError();
|
|
|
9119d9 |
+ abbreviated = true; /* still ok, again go ahead silently */
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
}
|
|
|
9119d9 |
|
|
|
9119d9 |
QEMU_ADD_COUNT_PARAM(record, maxparams, "block", dom->def->ndisks);
|
|
|
9119d9 |
@@ -18042,9 +18043,12 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
|
|
|
9119d9 |
|
|
|
9119d9 |
QEMU_ADD_NAME_PARAM(record, maxparams, "block", i, disk->dst);
|
|
|
9119d9 |
|
|
|
9119d9 |
- if (!disk->info.alias ||
|
|
|
9119d9 |
- !(entry = virHashLookup(stats, disk->info.alias)))
|
|
|
9119d9 |
+ if (abbreviated || !disk->info.alias ||
|
|
|
9119d9 |
+ !(entry = virHashLookup(stats, disk->info.alias))) {
|
|
|
9119d9 |
+ /* FIXME: we could still look up sizing by sharing code
|
|
|
9119d9 |
+ * with qemuDomainGetBlockInfo */
|
|
|
9119d9 |
continue;
|
|
|
9119d9 |
+ }
|
|
|
9119d9 |
|
|
|
9119d9 |
QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, i,
|
|
|
9119d9 |
"rd.reqs", entry->rd_req);
|
|
|
9119d9 |
--
|
|
|
9119d9 |
2.2.0
|
|
|
9119d9 |
|