]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: bulk stats: Don't access possibly blocked storage
authorPeter Krempa <pkrempa@redhat.com>
Wed, 18 May 2016 12:58:25 +0000 (14:58 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 19 May 2016 14:27:42 +0000 (16:27 +0200)
If the stats for a block device can't be acquired from qemu we've
fallen back to loading them from the file on the disk in libvirt.

If qemu is not cooperating due to being stuck on an inaccessible NFS
share we would then attempt to read the files and get stuck too with
the VM object locked. All other APIs would eventually get stuck waiting
on the VM lock.

Avoid this problem by skipping the block stats if the VM is online but
the monitor did not provide any stats.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1337073

src/qemu/qemu_driver.c

index 48ba7a9d901db40df0709136f8cdd8a41b336960..54a065bc58cc72274e0b0c22f77afb8bce5c96c6 100644 (file)
@@ -19373,13 +19373,22 @@ qemuDomainGetStatsOneBlock(virQEMUDriverPtr driver,
         QEMU_ADD_BLOCK_PARAM_UI(record, maxparams, block_idx, "backingIndex",
                                 backing_idx);
 
-    /* use fallback path if data is not available */
-    if (!stats || !alias || !(entry = virHashLookup(stats, alias))) {
+    /* the VM is offline so we have to go and load the stast from the disk by
+     * ourselves */
+    if (!virDomainObjIsActive(dom)) {
         ret = qemuDomainGetStatsOneBlockFallback(driver, cfg, dom, record,
                                                  maxparams, src, block_idx);
         goto cleanup;
     }
 
+    /* In case where qemu didn't provide the stats we stop here rather than
+     * trying to refresh the stats from the disk. Inability to provide stats is
+     * usually caused by blocked storage so this would make libvirtd hang */
+    if (!stats || !alias || !(entry = virHashLookup(stats, alias))) {
+        ret = 0;
+        goto cleanup;
+    }
+
     QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx,
                             "rd.reqs", entry->rd_req);
     QEMU_ADD_BLOCK_PARAM_LL(record, maxparams, block_idx,