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

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



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;
+        }
+    }
+
+    if (!disk) {
+        qemuReportError(VIR_ERR_INVALID_ARG,
+                        _("invalid path %s not assigned to domain"), path);
+        goto cleanup;
+    }
+
     /* The path is correct, now try to open it and get its size. */
     fd = open(path, O_RDONLY);
     if (fd == -1) {
-- 
1.7.3.4


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