[PATCH 04/17] qemu: command: Don't unset QEMU_CAPS_DEVICE for -drive sd

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

 



Since -device can't be used with bus=sd disks, we would unset
QEMU_CAPS_DEVICE temporarily for these disks. However since
QEMU_CAPS_DEVICE is going away, we don't want code to key off that
anymore.

Push the bus=sd check down into BuildDriveStr, and use that to
hit the different code paths.
---
 src/qemu/qemu_command.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index bf6eb9f..dade9f5 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3734,6 +3734,9 @@ qemuBuildDriveStr(virConnectPtr conn,
     int busid = -1, unitid = -1;
     char *source = NULL;
     int actualType = virStorageSourceGetActualType(disk->src);
+    bool usesDeviceArg = (
+        virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) &&
+        (disk->bus != VIR_DOMAIN_DISK_BUS_SD));
 
     if (idx < 0) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -3872,7 +3875,7 @@ qemuBuildDriveStr(virConnectPtr conn,
     }
     VIR_FREE(source);
 
-    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))
+    if (usesDeviceArg)
         virBufferAddLit(&opt, "if=none");
     else
         virBufferAsprintf(&opt, "if=%s", bus);
@@ -3889,7 +3892,7 @@ qemuBuildDriveStr(virConnectPtr conn,
         }
     }
 
-    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
+    if (usesDeviceArg) {
         virBufferAsprintf(&opt, ",id=%s%s", QEMU_DRIVE_HOST_PREFIX, disk->info.alias);
     } else {
         if (busid == -1 && unitid == -1) {
@@ -10184,7 +10187,6 @@ qemuBuildCommandLine(virConnectPtr conn,
         int bootindex = 0;
         virDomainDiskDefPtr disk = def->disks[i];
         bool withDeviceArg = false;
-        bool deviceFlagMasked = false;
 
         /* Unless we have -device, then USB disks need special
            handling */
@@ -10228,24 +10230,16 @@ qemuBuildCommandLine(virConnectPtr conn,
 
         virCommandAddArg(cmd, "-drive");
 
-        /* Unfortunately it is not possible to use
-           -device for floppies, xen PV, or SD
-           devices. Fortunately, those don't need
-           static PCI addresses, so we don't really
-           care that we can't use -device */
+        /* Unfortunately it is not possible to use -device for SD devices.
+           Fortunately, those don't need static PCI addresses, so we don't
+           really care that we can't use -device */
         if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
-            if (disk->bus != VIR_DOMAIN_DISK_BUS_SD) {
+            if (disk->bus != VIR_DOMAIN_DISK_BUS_SD)
                 withDeviceArg = true;
-            } else {
-                virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE);
-                deviceFlagMasked = true;
-            }
         }
         optstr = qemuBuildDriveStr(conn, disk,
                                    emitBootindex ? false : !!bootindex,
                                    qemuCaps);
-        if (deviceFlagMasked)
-            virQEMUCapsSet(qemuCaps, QEMU_CAPS_DEVICE);
         if (!optstr)
             goto error;
         virCommandAddArg(cmd, optstr);
-- 
2.5.0

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