[PATCH 30/55] qemu: domain: Prepare qemuDomainDiskGetBackendAlias for -blockdev

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

 



Pass in the node name as the backend alias when -blockdev is used. As
copy-on-read is expressed by a separate -blockdev backing chain member
we need to decide which node name to use here.

For empty cdroms when using -blockdev there is no backend at all so NULL
is returned.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_domain.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 526634d819..ea3929ce7e 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -8676,12 +8676,29 @@ qemuDomainDetermineDiskChain(virQEMUDriverPtr driver,
  */
 int
 qemuDomainDiskGetBackendAlias(virDomainDiskDefPtr disk,
-                              virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED,
+                              virQEMUCapsPtr qemuCaps,
                               char **backendAlias)
 {
+    qemuDomainDiskPrivatePtr priv = QEMU_DOMAIN_DISK_PRIVATE(disk);
+    const char *nodename = NULL;
     *backendAlias = NULL;

-    if (!(*backendAlias = qemuAliasDiskDriveFromDisk(disk)))
+    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) {
+        if (!(*backendAlias = qemuAliasDiskDriveFromDisk(disk)))
+            return -1;
+
+        return 0;
+    }
+
+    if (virStorageSourceIsEmpty(disk->src))
+        return 0;
+
+    if (disk->copy_on_read == VIR_TRISTATE_SWITCH_ON)
+        nodename = priv->nodeCopyOnRead;
+    else
+        nodename = disk->src->nodeformat;
+
+    if (VIR_STRDUP(*backendAlias, nodename) < 0)
         return -1;

     return 0;
-- 
2.16.2

--
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]

  Powered by Linux