]> xenbits.xensource.com Git - libvirt.git/commitdiff
getstats: prepare for dynamic block.count stat
authorEric Blake <eblake@redhat.com>
Fri, 5 Dec 2014 23:19:00 +0000 (16:19 -0700)
committerEric Blake <eblake@redhat.com>
Wed, 17 Dec 2014 07:20:21 +0000 (00:20 -0700)
A coming patch will make it optionally possible to list backing
chain block stats; in this mode of operation, block.counts is no
longer the number of <disks> in the domain, but the number of
blocks in the array being reported.  We still want block.count
listed first, but rather than iterate the tree twice (once to
count, and once to list stats), it's easier to just touch things
up after the fact.

* src/qemu/qemu_driver.c (qemuDomainGetStatsBlock): Compute count
after the fact.

Signed-off-by: Eric Blake <eblake@redhat.com>
src/qemu/qemu_driver.c

index e7625ef39eb83eb166224236b18d0f824dd400ab..db0cc3365694d282693295e59629af2791ed2327 100644 (file)
@@ -18566,6 +18566,7 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
     qemuDomainObjPrivatePtr priv = dom->privateData;
     bool abbreviated = false;
     virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+    int count_index = -1;
 
     if (!HAVE_JOB(privflags) || !virDomainObjIsActive(dom)) {
         abbreviated = true; /* it's ok, just go ahead silently */
@@ -18582,7 +18583,11 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
         }
     }
 
-    QEMU_ADD_COUNT_PARAM(record, maxparams, "block", dom->def->ndisks);
+    /* When listing backing chains, it's easier to fix up the count
+     * after the iteration than it is to iterate twice; but we still
+     * want count listed first.  */
+    count_index = record->nparams;
+    QEMU_ADD_COUNT_PARAM(record, maxparams, "block", 0);
 
     for (i = 0; i < dom->def->ndisks; i++) {
         qemuBlockStats *entry;
@@ -18640,6 +18645,7 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
 
     }
 
+    record->params[count_index].value.ui = i;
     ret = 0;
 
  cleanup: