[PATCH RFC 17/39] qemu: Use proper backingIndex when reporting stats for backing chain

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

 



Use the index stored in virStorageSource struct rather than
recalculating it. Currently we'd report proper numbers but that will
change with blockdev.

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

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b81ad7cdbc..0e1047c6ec 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20053,7 +20053,6 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
                            virDomainDiskDefPtr disk,
                            virStorageSourcePtr src,
                            size_t block_idx,
-                           unsigned int backing_idx,
                            virHashTablePtr stats,
                            virHashTablePtr nodedata)
 {
@@ -20062,16 +20061,16 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
     char *alias = NULL;

     if (disk->info.alias)
-        alias = qemuDomainStorageAlias(disk->info.alias, backing_idx);
+        alias = qemuDomainStorageAlias(disk->info.alias, src->id);

     QEMU_ADD_NAME_PARAM(record, maxparams, "block", "name", block_idx,
                         disk->dst);
     if (virStorageSourceIsLocalStorage(src) && src->path)
         QEMU_ADD_NAME_PARAM(record, maxparams, "block", "path",
                             block_idx, src->path);
-    if (backing_idx)
+    if (src->id)
         QEMU_ADD_BLOCK_PARAM_UI(record, maxparams, block_idx, "backingIndex",
-                                backing_idx);
+                                src->id);

     /* the VM is offline so we have to go and load the stast from the disk by
      * ourselves */
@@ -20188,16 +20187,14 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
     for (i = 0; i < dom->def->ndisks; i++) {
         virDomainDiskDefPtr disk = dom->def->disks[i];
         virStorageSourcePtr src = disk->src;
-        unsigned int backing_idx = 0;

         while (virStorageSourceIsBacking(src) &&
-               (backing_idx == 0 || visitBacking)) {
+               (src == disk->src || visitBacking)) {
             if (qemuDomainGetStatsOneBlock(driver, cfg, dom, record, maxparams,
-                                           disk, src, visited, backing_idx,
+                                           disk, src, visited,
                                            stats, nodestats) < 0)
                 goto cleanup;
             visited++;
-            backing_idx++;
             src = src->backingStore;
         }
     }
-- 
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