]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuMonitorJSONBlockStatsUpdateCapacity: Don't skip disks
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 1 Dec 2014 14:31:51 +0000 (15:31 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 2 Dec 2014 16:51:57 +0000 (17:51 +0100)
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>
src/qemu/qemu_monitor_json.c

index 6e251b3073ae283138ce811cacfe30ea129fd355..162579bfd44b0bd0d588347765fae6e069902acf 100644 (file)
@@ -1889,15 +1889,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;