[PATCH v2 6/9] qemu: command: Refactor logic when formatting -drive

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

 



Move all logic depending on whether we are solely formatting -drive (no
-device along with it) into one block.
---
 src/qemu/qemu_command.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index b53faadc15..36b8f3cb7f 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -1657,26 +1657,16 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
                   virQEMUCapsPtr qemuCaps)
 {
     virBuffer opt = VIR_BUFFER_INITIALIZER;
-    bool emitDeviceSyntax = qemuDiskBusNeedsDeviceArg(disk->bus);
-
-    /* if we are using -device this will be checked elsewhere */
-    if (!emitDeviceSyntax &&
-        qemuCheckDiskConfig(disk, qemuCaps) < 0)
-        goto error;

     if (qemuBuildDriveSourceStr(disk, cfg, &opt, qemuCaps) < 0)
         goto error;

-    if (emitDeviceSyntax)
-        virBufferAddLit(&opt, "if=none");
-    else
-        virBufferAsprintf(&opt, "if=%s",
-                          virDomainDiskQEMUBusTypeToString(disk->bus));
-
-    if (emitDeviceSyntax) {
+    if (qemuDiskBusNeedsDeviceArg(disk->bus)) {
         char *drivealias = qemuAliasFromDisk(disk);
         if (!drivealias)
             goto error;
+
+        virBufferAddLit(&opt, "if=none");
         virBufferAsprintf(&opt, ",id=%s", drivealias);
         VIR_FREE(drivealias);
     } else {
@@ -1687,6 +1677,13 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk,
                            _("unsupported disk type '%s'"), disk->dst);
             goto error;
         }
+
+        /* if we are using -device this will be checked elsewhere */
+        if (qemuCheckDiskConfig(disk, qemuCaps) < 0)
+            goto error;
+
+        virBufferAsprintf(&opt, "if=%s",
+                          virDomainDiskQEMUBusTypeToString(disk->bus));
         virBufferAsprintf(&opt, ",index=%d", idx);
     }

-- 
2.14.3

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