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