render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
9119d9
From 248157defba2872ca75f3055d518e956daa33697 Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <248157defba2872ca75f3055d518e956daa33697@dist-git>
9119d9
From: Eric Blake <eblake@redhat.com>
9119d9
Date: Wed, 17 Dec 2014 03:09:08 -0700
9119d9
Subject: [PATCH] getstats: split block stats reporting for easier recursion
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1041569
9119d9
9119d9
In order to report stats on backing chains, we need to separate
9119d9
the output of stats for one block from how we traverse blocks.
9119d9
9119d9
* src/qemu/qemu_driver.c (qemuDomainGetStatsBlock): Split...
9119d9
(qemuDomainGetStatsOneBlock): ...into new helper.
9119d9
9119d9
Signed-off-by: Eric Blake <eblake@redhat.com>
9119d9
(cherry picked from commit c2d380bff8f1bad8e6df047c34ab1a4f8f623e3e)
9119d9
9119d9
Conflicts:
9119d9
	src/qemu/qemu_driver.c - no offline stats (commit 596a137)
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/qemu/qemu_driver.c | 107 +++++++++++++++++++++++++++++++------------------
9119d9
 1 file changed, 67 insertions(+), 40 deletions(-)
9119d9
9119d9
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
9119d9
index 6be180e..a2535f4 100644
9119d9
--- a/src/qemu/qemu_driver.c
9119d9
+++ b/src/qemu/qemu_driver.c
9119d9
@@ -18007,6 +18007,69 @@ do { \
9119d9
         goto cleanup; \
9119d9
 } while (0)
9119d9
 
9119d9
+
9119d9
+static int
9119d9
+qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver ATTRIBUTE_UNUSED,
9119d9
+                           virQEMUDriverConfigPtr cfg ATTRIBUTE_UNUSED,
9119d9
+                           virDomainObjPtr dom ATTRIBUTE_UNUSED,
9119d9
+                           virDomainStatsRecordPtr record,
9119d9
+                           int *maxparams,
9119d9
+                           virDomainDiskDefPtr disk,
9119d9
+                           virStorageSourcePtr src,
9119d9
+                           size_t block_idx,
9119d9
+                           bool abbreviated,
9119d9
+                           virHashTablePtr stats)
9119d9
+{
9119d9
+    qemuBlockStats *entry;
9119d9
+    int ret = -1;
9119d9
+
9119d9
+    QEMU_ADD_NAME_PARAM(record, maxparams, "block", "name", block_idx,
9119d9
+                        disk->dst);
9119d9
+    if (virStorageSourceIsLocalStorage(src) && src->path)
9119d9
+        QEMU_ADD_NAME_PARAM(record, maxparams, "block", "path",
9119d9
+                            block_idx, src->path);
9119d9
+
9119d9
+    if (abbreviated || !disk->info.alias ||
9119d9
+        !(entry = virHashLookup(stats, disk->info.alias))) {
9119d9
+        /* FIXME: we could still look up sizing by sharing code
9119d9
+         * with qemuDomainGetBlockInfo */
9119d9
+        ret = 0;
9119d9
+        goto cleanup;
9119d9
+    }
9119d9
+
9119d9
+    QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx,
9119d9
+                            "rd.reqs", entry->rd_req);
9119d9
+    QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx,
9119d9
+                            "rd.bytes", entry->rd_bytes);
9119d9
+    QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx,
9119d9
+                            "rd.times", entry->rd_total_times);
9119d9
+    QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx,
9119d9
+                            "wr.reqs", entry->wr_req);
9119d9
+    QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx,
9119d9
+                            "wr.bytes", entry->wr_bytes);
9119d9
+    QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx,
9119d9
+                            "wr.times", entry->wr_total_times);
9119d9
+    QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx,
9119d9
+                            "fl.reqs", entry->flush_req);
9119d9
+    QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx,
9119d9
+                            "fl.times", entry->flush_total_times);
9119d9
+
9119d9
+    QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
9119d9
+                             "allocation", entry->wr_highest_offset);
9119d9
+
9119d9
+    if (entry->capacity)
9119d9
+        QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
9119d9
+                                 "capacity", entry->capacity);
9119d9
+    if (entry->physical)
9119d9
+        QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, block_idx,
9119d9
+                                 "physical", entry->physical);
9119d9
+
9119d9
+    ret = 0;
9119d9
+ cleanup:
9119d9
+    return ret;
9119d9
+}
9119d9
+
9119d9
+
9119d9
 static int
9119d9
 qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
9119d9
                         virDomainObjPtr dom,
9119d9
@@ -18044,48 +18107,12 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
9119d9
     QEMU_ADD_COUNT_PARAM(record, maxparams, "block", 0);
9119d9
 
9119d9
     for (i = 0; i < dom->def->ndisks; i++) {
9119d9
-        qemuBlockStats *entry;
9119d9
         virDomainDiskDefPtr disk = dom->def->disks[i];
9119d9
 
9119d9
-        QEMU_ADD_NAME_PARAM(record, maxparams, "block", "name", i, disk->dst);
9119d9
-        if (virStorageSourceIsLocalStorage(disk->src) && disk->src->path)
9119d9
-            QEMU_ADD_NAME_PARAM(record, maxparams, "block", "path",
9119d9
-                                i, disk->src->path);
9119d9
-
9119d9
-        if (abbreviated || !disk->info.alias ||
9119d9
-            !(entry = virHashLookup(stats, disk->info.alias))) {
9119d9
-            /* FIXME: we could still look up sizing by sharing code
9119d9
-             * with qemuDomainGetBlockInfo */
9119d9
-            continue;
9119d9
-        }
9119d9
-
9119d9
-        QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, i,
9119d9
-                                "rd.reqs", entry->rd_req);
9119d9
-        QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, i,
9119d9
-                                "rd.bytes", entry->rd_bytes);
9119d9
-        QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, i,
9119d9
-                                "rd.times", entry->rd_total_times);
9119d9
-        QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, i,
9119d9
-                                "wr.reqs", entry->wr_req);
9119d9
-        QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, i,
9119d9
-                                "wr.bytes", entry->wr_bytes);
9119d9
-        QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, i,
9119d9
-                                "wr.times", entry->wr_total_times);
9119d9
-        QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, i,
9119d9
-                                "fl.reqs", entry->flush_req);
9119d9
-        QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, i,
9119d9
-                                "fl.times", entry->flush_total_times);
9119d9
-
9119d9
-        QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, i,
9119d9
-                                 "allocation", entry->wr_highest_offset);
9119d9
-
9119d9
-        if (entry->capacity)
9119d9
-            QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, i,
9119d9
-                                     "capacity", entry->capacity);
9119d9
-        if (entry->physical)
9119d9
-            QEMU_ADD_BLOCK_PARAM_ULL(record, maxparams, i,
9119d9
-                                     "physical", entry->physical);
9119d9
-
9119d9
+        if (qemuDomainGetStatsOneBlock(driver, NULL, dom, record, maxparams,
9119d9
+                                       disk, disk->src, i, abbreviated,
9119d9
+                                       stats) < 0)
9119d9
+            goto cleanup;
9119d9
     }
9119d9
 
9119d9
     record->params[count_index].value.ui = i;
9119d9
-- 
9119d9
2.2.0
9119d9