[PATCH RFC 35/39] qemu: driver: Don't pass 'virDomainDiskDefPtr' to qemuDomainGetStatsOneBlock

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

 



Allow reuse of qemuDomainGetStatsOneBlock to work with nodenames by
removing the code that looks up the stats data to the caller.

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

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 9a3c4289ba..ebcfdeb417 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -20067,7 +20067,8 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
                            virDomainObjPtr dom,
                            virDomainStatsRecordPtr record,
                            int *maxparams,
-                           virDomainDiskDefPtr disk,
+                           const char *diskdst,
+                           const char *entryname,
                            virStorageSourcePtr src,
                            size_t block_idx,
                            virHashTablePtr stats,
@@ -20075,13 +20076,9 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
 {
     qemuBlockStats *entry;
     int ret = -1;
-    char *alias = NULL;

-    if (disk->info.alias)
-        alias = qemuDomainStorageAlias(disk->info.alias, src->id);
+    QEMU_ADD_NAME_PARAM(record, maxparams, "block", "name", block_idx, diskdst);

-    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);
@@ -20100,7 +20097,7 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
     /* In case where qemu didn't provide the stats we stop here rather than
      * trying to refresh the stats from the disk. Inability to provide stats is
      * usually caused by blocked storage so this would make libvirtd hang */
-    if (!stats || !alias || !(entry = virHashLookup(stats, alias))) {
+    if (!stats || !entryname || !(entry = virHashLookup(stats, entryname))) {
         ret = 0;
         goto cleanup;
     }
@@ -20146,7 +20143,6 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,

     ret = 0;
  cleanup:
-    VIR_FREE(alias);
     return ret;
 }

@@ -20171,6 +20167,7 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
     int count_index = -1;
     size_t visited = 0;
     bool visitBacking = !!(privflags & QEMU_DOMAIN_STATS_BACKING);
+    char *alias = NULL;

     if (HAVE_JOB(privflags) && virDomainObjIsActive(dom)) {
         qemuDomainObjEnterMonitor(driver, dom);
@@ -20207,10 +20204,18 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,

         while (virStorageSourceIsBacking(src) &&
                (src == disk->src || visitBacking)) {
+
+            /* alias may be NULL if the VM is not running */
+            if (disk->info.alias &&
+                !(alias = qemuDomainStorageAlias(disk->info.alias, src->id)))
+                goto cleanup;
+
             if (qemuDomainGetStatsOneBlock(driver, cfg, dom, record, maxparams,
-                                           disk, src, visited,
+                                           disk->dst, alias, src, visited,
                                            stats, nodestats) < 0)
                 goto cleanup;
+
+            VIR_FREE(alias);
             visited++;
             src = src->backingStore;
         }
@@ -20220,6 +20225,7 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
     ret = 0;

  cleanup:
+    VIR_FREE(alias);
     virHashFree(stats);
     virHashFree(nodestats);
     virJSONValueFree(nodedata);
-- 
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