Re: [PATCH] qemu: Search for disk in qemuDomainGetBlockInfo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/08/2011 09:55 AM, Michal Privoznik wrote:
The commit 89b6284fd94ce5b13ee6b002f9167f5d9074aa7a caused regression.
Although we now allow users to input e.g. 'hda' instead of whole path,
we still need to search for appropriate disk in VM definition.
---
  src/qemu/qemu_driver.c |   16 ++++++++++++++++
  1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 1925ba5..fec4eeb 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7755,6 +7755,7 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
      virStorageFileMetadata *meta = NULL;
      virDomainDiskDefPtr disk = NULL;
      struct stat sb;
+    int i;
      int format;
      const char *actual;

@@ -7785,6 +7786,21 @@ static int qemuDomainGetBlockInfo(virDomainPtr dom,
      }
      path = actual;

+    /* Check the path belongs to this domain. */
+    for (i = 0 ; i<  vm->def->ndisks ; i++) {
+        if (vm->def->disks[i]->src != NULL&&
+            STREQ (vm->def->disks[i]->src, path)) {
+            disk = vm->def->disks[i];
+            break;
+        }
+    }

NACK. This is open-coding the effects of virDomainDiskIndexByName(). Instead, we should be doing something like:

int i = virDomainDiskIndexByName(vm->def, path, false);
if (i < 0) error;
disk = vm->def->disks[i];

instead of virDomainDiskPathByName().

--
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]