[PATCH 40/55] qemu: Explicitly find disks for stats totals

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rather than totalling every entry from 'query-block' for stats provided
by qemuDomainBlocksStatsGather total only stats for known disks. This
will allow to return data for nodenames and qdevs in the same hash so
that we can use them with -blockdev.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_driver.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c941e502e5..af347c732c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11037,13 +11037,9 @@ qemuDomainBlockResize(virDomainPtr dom,


 static int
-qemuDomainBlockStatsGatherTotals(void *payload,
-                                 const void *name ATTRIBUTE_UNUSED,
-                                 void *opaque)
+qemuDomainBlockStatsGatherTotals(qemuBlockStatsPtr data,
+                                 qemuBlockStatsPtr total)
 {
-    qemuBlockStatsPtr data = payload;
-    qemuBlockStatsPtr total = opaque;
-
 #define QEMU_BLOCK_STAT_TOTAL(NAME) \
     if (data->NAME > 0) \
         total->NAME += data->NAME
@@ -11084,6 +11080,7 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver,
     virDomainDiskDefPtr disk;
     virHashTablePtr blockstats = NULL;
     qemuBlockStatsPtr stats;
+    size_t i;
     int nstats;
     const char *entryname = NULL;
     int ret = -1;
@@ -11125,7 +11122,21 @@ qemuDomainBlocksStatsGather(virQEMUDriverPtr driver,

         **retstats = *stats;
     } else {
-        virHashForEach(blockstats, qemuDomainBlockStatsGatherTotals, *retstats);
+        for (i = 0; i < vm->def->ndisks; i++) {
+            disk = vm->def->disks[i];
+            entryname = disk->info.alias;
+
+            if (!entryname)
+                continue;
+
+            if (!(stats = virHashLookup(blockstats, entryname))) {
+                virReportError(VIR_ERR_INTERNAL_ERROR,
+                               _("cannot find statistics for device '%s'"), entryname);
+                goto cleanup;
+            }
+
+            qemuDomainBlockStatsGatherTotals(stats, *retstats);
+        }
     }

     ret = nstats;
-- 
2.16.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux