render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
2d1356
From fdf02246eb2837e144b1929887af94aa9ce9a77e Mon Sep 17 00:00:00 2001
2d1356
Message-Id: <fdf02246eb2837e144b1929887af94aa9ce9a77e@dist-git>
2d1356
From: Peter Krempa <pkrempa@redhat.com>
2d1356
Date: Thu, 26 May 2016 12:54:53 +0200
2d1356
Subject: [PATCH] qemu: driver: Separate bulk stats worker for block devices
2d1356
2d1356
https://bugzilla.redhat.com/show_bug.cgi?id=1339963
2d1356
2d1356
Extract the fallback path that reloads the stats from disk into a
2d1356
separate function.
2d1356
2d1356
(cherry picked from commit 3aa5d51a9530a8737ca584b393c29297dd9bbc37)
2d1356
---
2d1356
 src/qemu/qemu_driver.c | 58 ++++++++++++++++++++++++++++++++------------------
2d1356
 1 file changed, 37 insertions(+), 21 deletions(-)
2d1356
2d1356
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
2d1356
index e403103..1075237 100644
2d1356
--- a/src/qemu/qemu_driver.c
2d1356
+++ b/src/qemu/qemu_driver.c
2d1356
@@ -19329,6 +19329,40 @@ do { \
2d1356
         goto cleanup; \
2d1356
 } while (0)
2d1356
 
2d1356
+/* refresh information by opening images on the disk */
2d1356
+static int
2d1356
+qemuDomainGetStatsOneBlockFallback(virQEMUDriverPtr driver,
2d1356
+                                   virQEMUDriverConfigPtr cfg,
2d1356
+                                   virDomainObjPtr dom,
2d1356
+                                   virDomainStatsRecordPtr record,
2d1356
+                                   int *maxparams,
2d1356
+                                   virStorageSourcePtr src,
2d1356
+                                   size_t block_idx)
2d1356
+{
2d1356
+    int ret = -1;
2d1356
+
2d1356
+    if (virStorageSourceIsEmpty(src))
2d1356
+        return 0;
2d1356
+
2d1356
+    if (qemuStorageLimitsRefresh(driver, cfg, dom, src) < 0) {
2d1356
+        virResetLastError();
2d1356
+        return 0;
2d1356
+    }
2d1356
+
2d1356
+    if (src->allocation)
2d1356
+        QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
2d1356
+                                 "allocation", src->allocation);
2d1356
+    if (src->capacity)
2d1356
+        QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
2d1356
+                                 "capacity", src->capacity);
2d1356
+    if (src->physical)
2d1356
+        QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
2d1356
+                                 "physical", src->physical);
2d1356
+    ret = 0;
2d1356
+ cleanup:
2d1356
+    return ret;
2d1356
+}
2d1356
+
2d1356
 
2d1356
 static int
2d1356
 qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
2d1356
@@ -19358,28 +19392,10 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
2d1356
         QEMU_ADD_BLOCK_PARAM_UI(record, maxparams, block_idx, "backingIndex",
2d1356
                                 backing_idx);
2d1356
 
2d1356
+    /* use fallback path if data is not available */
2d1356
     if (!stats || !alias || !(entry = virHashLookup(stats, alias))) {
2d1356
-        if (virStorageSourceIsEmpty(src)) {
2d1356
-            ret = 0;
2d1356
-            goto cleanup;
2d1356
-        }
2d1356
-
2d1356
-        if (qemuStorageLimitsRefresh(driver, cfg, dom, src) < 0) {
2d1356
-            virResetLastError();
2d1356
-            ret = 0;
2d1356
-            goto cleanup;
2d1356
-        }
2d1356
-
2d1356
-        if (src->allocation)
2d1356
-            QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
2d1356
-                                     "allocation", src->allocation);
2d1356
-        if (src->capacity)
2d1356
-            QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
2d1356
-                                     "capacity", src->capacity);
2d1356
-        if (src->physical)
2d1356
-            QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
2d1356
-                                     "physical", src->physical);
2d1356
-        ret = 0;
2d1356
+        ret = qemuDomainGetStatsOneBlockFallback(driver, cfg, dom, record,
2d1356
+                                                 maxparams, src, block_idx);
2d1356
         goto cleanup;
2d1356
     }
2d1356
 
2d1356
-- 
2d1356
2.8.3
2d1356