]> xenbits.xensource.com Git - libvirt.git/commitdiff
blockinfo: fix qemu regression in handling disk name
authorEric Blake <eblake@redhat.com>
Thu, 8 Sep 2011 09:10:14 +0000 (10:10 +0100)
committerEric Blake <eblake@redhat.com>
Thu, 8 Sep 2011 09:52:43 +0000 (10:52 +0100)
Regression introduced in commit 89b6284fd, due to an incorrect
conversion to the new means of converting disk names back to
the correct object.

* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo): Avoid NULL deref.

src/qemu/qemu_driver.c

index 1925ba52362ce34ae99a516cb9e2fec4b68f9050..b94d1c4838a131ccda0195ad87c2ee85d01b7942 100644 (file)
@@ -7755,8 +7755,8 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
     virStorageFileMetadata *meta = NULL;
     virDomainDiskDefPtr disk = NULL;
     struct stat sb;
+    int i;
     int format;
-    const char *actual;
 
     virCheckFlags(0, -1);
 
@@ -7778,12 +7778,19 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
     }
 
     /* Check the path belongs to this domain. */
-    if (!(actual = virDomainDiskPathByName(vm->def, path))) {
+    if ((i = virDomainDiskIndexByName(vm->def, path, false)) < 0) {
         qemuReportError(VIR_ERR_INVALID_ARG,
                         _("invalid path %s not assigned to domain"), path);
         goto cleanup;
     }
-    path = actual;
+    disk = vm->def->disks[i];
+    if (!disk->src) {
+        qemuReportError(VIR_ERR_INVALID_ARG,
+                        _("disk %s does not currently have a source assigned"),
+                        path);
+        goto cleanup;
+    }
+    path = disk->src;
 
     /* The path is correct, now try to open it and get its size. */
     fd = open(path, O_RDONLY);