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

[libvirt] [PATCHv2 27/62] qemu: Use proper backingIndex when reporting stats for backing chain



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 redhat com>
---
 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 7456db6468..7b9c19087e 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20033,7 +20033,6 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
                            virDomainDiskDefPtr disk,
                            virStorageSourcePtr src,
                            size_t block_idx,
-                           unsigned int backing_idx,
                            virHashTablePtr stats,
                            virHashTablePtr nodedata)
 {
@@ -20042,16 +20041,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 */
@@ -20168,16 +20167,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


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