9119d9
From 4dc81b3be7488e24a61358e97c7a19faa27c9ed2 Mon Sep 17 00:00:00 2001
9119d9
Message-Id: <4dc81b3be7488e24a61358e97c7a19faa27c9ed2@dist-git>
9119d9
From: Michal Privoznik <mprivozn@redhat.com>
9119d9
Date: Wed, 17 Dec 2014 03:09:03 -0700
9119d9
Subject: [PATCH] qemuMonitorJSONBlockStatsUpdateCapacity: Don't skip disks
9119d9
9119d9
https://bugzilla.redhat.com/show_bug.cgi?id=1041569
9119d9
9119d9
The function queries the block devices visible to qemu
9119d9
('query-block') and parses the qemu's output. The info is
9119d9
returned in a hash table which is expected to be pre-filled by
9119d9
qemuMonitorJSONGetAllBlockStatsInfo(). However, in the next patch
9119d9
we are not going to call the latter function at all, so we should
9119d9
make the former function add devices into the hash table if not
9119d9
found there.
9119d9
9119d9
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9119d9
(cherry picked from commit a714533b2bd2de81b9319bb753e74cc9210ca647)
9119d9
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9119d9
---
9119d9
 src/qemu/qemu_monitor_json.c | 14 ++++++++++----
9119d9
 1 file changed, 10 insertions(+), 4 deletions(-)
9119d9
9119d9
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
9119d9
index 34fb91f..3cf67aa 100644
9119d9
--- a/src/qemu/qemu_monitor_json.c
9119d9
+++ b/src/qemu/qemu_monitor_json.c
9119d9
@@ -2032,15 +2032,21 @@ int qemuMonitorJSONBlockStatsUpdateCapacity(qemuMonitorPtr mon,
9119d9
         if (STRPREFIX(dev_name, QEMU_DRIVE_HOST_PREFIX))
9119d9
             dev_name += strlen(QEMU_DRIVE_HOST_PREFIX);
9119d9
 
9119d9
-        /* ignore missing info */
9119d9
-        if (!(bstats = virHashLookup(stats, dev_name)))
9119d9
-            continue;
9119d9
-
9119d9
         /* drive may be empty */
9119d9
         if (!(inserted = virJSONValueObjectGet(dev, "inserted")) ||
9119d9
             !(image = virJSONValueObjectGet(inserted, "image")))
9119d9
             continue;
9119d9
 
9119d9
+        if (!(bstats = virHashLookup(stats, dev_name))) {
9119d9
+            if (VIR_ALLOC(bstats) < 0)
9119d9
+                goto cleanup;
9119d9
+
9119d9
+            if (virHashAddEntry(stats, dev_name, bstats) < 0) {
9119d9
+                VIR_FREE(bstats);
9119d9
+                goto cleanup;
9119d9
+            }
9119d9
+        }
9119d9
+
9119d9
         if (virJSONValueObjectGetNumberUlong(image, "virtual-size",
9119d9
                                              &bstats->capacity) < 0)
9119d9
             continue;
9119d9
-- 
9119d9
2.2.0
9119d9