[libvirt] [PATCH 19/22] qemu: driver: Stop using QEMU_ADD_BLOCK_PARAM_ULL in qemuDomainGetStatsOneBlock

Peter Krempa pkrempa at redhat.com
Thu Sep 19 17:13:22 UTC 2019


Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/qemu/qemu_driver.c | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b703436744..703f07a388 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -21447,42 +21447,42 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
                            virHashTablePtr stats)
 {
     qemuBlockStats *entry;
-    int ret = -1;

     /* the VM is offline so we have to go and load the stast from the disk by
      * ourselves */
     if (!virDomainObjIsActive(dom)) {
-        ret = qemuDomainGetStatsOneBlockFallback(driver, cfg, dom, params,
-                                                 src, block_idx);
-        goto cleanup;
+        return qemuDomainGetStatsOneBlockFallback(driver, cfg, dom, params,
+                                                  src, block_idx);
     }

     /* 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 || !entryname || !(entry = virHashLookup(stats, entryname))) {
-        ret = 0;
-        goto cleanup;
-    }
+    if (!stats || !entryname || !(entry = virHashLookup(stats, entryname)))
+        return 0;

-    QEMU_ADD_BLOCK_PARAM_ULL(params, block_idx,
-                             "allocation", entry->wr_highest_offset);
+    if (virTypedParamListAddULL(params, entry->wr_highest_offset,
+                                "block.%zu.allocation", block_idx) < 0)
+        return -1;
+
+    if (entry->capacity &&
+        virTypedParamListAddULL(params, entry->capacity,
+                                "block.%zu.capacity", block_idx) < 0)
+        return -1;

-    if (entry->capacity)
-        QEMU_ADD_BLOCK_PARAM_ULL(params, block_idx,
-                                 "capacity", entry->capacity);
     if (entry->physical) {
-        QEMU_ADD_BLOCK_PARAM_ULL(params, block_idx,
-                                 "physical", entry->physical);
+        if (virTypedParamListAddULL(params, entry->physical,
+                                    "block.%zu.physical", block_idx) < 0)
+            return -1;
     } else {
-        if (qemuDomainStorageUpdatePhysical(driver, cfg, dom, src) == 0)
-            QEMU_ADD_BLOCK_PARAM_ULL(params, block_idx,
-                                     "physical", src->physical);
+        if (qemuDomainStorageUpdatePhysical(driver, cfg, dom, src) == 0) {
+            if (virTypedParamListAddULL(params, src->physical,
+                                        "block.%zu.physical", block_idx) < 0)
+                return -1;
+        }
     }

-    ret = 0;
- cleanup:
-    return ret;
+    return 0;
 }


-- 
2.21.0




More information about the libvir-list mailing list