]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: domain: Properly lookup top of chain in qemuDomainGetStorageSourceByDevstr
authorPeter Krempa <pkrempa@redhat.com>
Wed, 29 Mar 2017 14:56:05 +0000 (16:56 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 29 Mar 2017 14:56:05 +0000 (16:56 +0200)
When idx is 0 virStorageFileChainLookup returns the base (bottom) of the
backing chain rather than the top. This is expected by the callers of
qemuDomainGetStorageSourceByDevstr.

Add a special case for idx == 0

src/qemu/qemu_domain.c

index 458bb5f9a431db2567666f73148a82954ef2c525..589eb188993ff0eaa7eac0abc1883106489a17f6 100644 (file)
@@ -8605,7 +8605,10 @@ qemuDomainGetStorageSourceByDevstr(const char *devstr,
         goto cleanup;
     }
 
-    src = virStorageFileChainLookup(disk->src, NULL, NULL, idx, NULL);
+    if (idx == 0)
+        src = disk->src;
+    else
+        src = virStorageFileChainLookup(disk->src, NULL, NULL, idx, NULL);
 
  cleanup:
     VIR_FREE(target);