[libvirt] [PATCH 01/11] qemu: move out legacy USB controller formatting

Ján Tomko jtomko at redhat.com
Wed Jan 16 07:56:06 UTC 2019


Move out the code formatting "-usb" on the QEMU command line.

Signed-off-by: Ján Tomko <jtomko at redhat.com>
---
 src/qemu/qemu_command.c | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 822d5f8669..d6b7d11cc6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3021,6 +3021,26 @@ qemuBuildControllerDevStr(const virDomainDef *domainDef,
 }
 
 
+static int
+qemuBuildLegacyUSBControllerCommandLine(virCommandPtr cmd,
+                                        const virDomainDef *def,
+                                        int usbcontroller)
+{
+    if (usbcontroller == 0 &&
+        !qemuDomainIsQ35(def) &&
+        !qemuDomainIsARMVirt(def) &&
+        !qemuDomainIsRISCVVirt(def) &&
+        !ARCH_IS_S390(def->os.arch)) {
+        /* We haven't added any USB controller yet, but we haven't been asked
+         * not to add one either. Add a legacy USB controller, unless we're
+         * creating a kind of guest we want to keep legacy-free */
+        virCommandAddArg(cmd, "-usb");
+    }
+
+    return 0;
+}
+
+
 /**
  * qemuBuildSkipController:
  * @controller: Controller to check
@@ -3156,16 +3176,8 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
         }
     }
 
-    if (usbcontroller == 0 &&
-        !qemuDomainIsQ35(def) &&
-        !qemuDomainIsARMVirt(def) &&
-        !qemuDomainIsRISCVVirt(def) &&
-        !ARCH_IS_S390(def->os.arch)) {
-        /* We haven't added any USB controller yet, but we haven't been asked
-         * not to add one either. Add a legacy USB controller, unless we're
-         * creating a kind of guest we want to keep legacy-free */
-        virCommandAddArg(cmd, "-usb");
-    }
+    if (qemuBuildLegacyUSBControllerCommandLine(cmd, def, usbcontroller) < 0)
+        goto cleanup;
 
     ret = 0;
 
-- 
2.20.1




More information about the libvir-list mailing list