[PATCH 05/11] qemu: separate counting of USB controllers

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

 



qemuBuildLegacyUSBControllerCommandLine is the only place where
we need to count the USB controllers.

Count them again instead of keeping track in a variable passed to
qemuBuildControllerDevStr.

This removes the need for another variable in the loop in
qemuBuildControllerDevCommandLine.

Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 014bd031a8..22f041a956 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3035,11 +3035,11 @@ qemuBuildDomainForbidLegacyUSBController(const virDomainDef *def)
 
 static int
 qemuBuildLegacyUSBControllerCommandLine(virCommandPtr cmd,
-                                        const virDomainDef *def,
-                                        int usbcontroller)
+                                        const virDomainDef *def)
 {
     size_t i;
     size_t nlegacy = 0;
+    size_t nusb = 0;
 
     for (i = 0; i < def->ncontrollers; i++) {
         virDomainControllerDefPtr cont = def->controllers[i];
@@ -3053,6 +3053,8 @@ qemuBuildLegacyUSBControllerCommandLine(virCommandPtr cmd,
 
         if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT)
             nlegacy++;
+        else
+            nusb++;
     }
 
     if (nlegacy > 1) {
@@ -3062,7 +3064,7 @@ qemuBuildLegacyUSBControllerCommandLine(virCommandPtr cmd,
         return -1;
     }
 
-    if (usbcontroller == 0 &&
+    if (nusb == 0 &&
         !qemuBuildDomainForbidLegacyUSBController(def) &&
         !ARCH_IS_S390(def->os.arch)) {
         /* We haven't added any USB controller yet, but we haven't been asked
@@ -3199,7 +3201,7 @@ qemuBuildControllerDevCommandLine(virCommandPtr cmd,
         }
     }
 
-    if (qemuBuildLegacyUSBControllerCommandLine(cmd, def, usbcontroller) < 0)
+    if (qemuBuildLegacyUSBControllerCommandLine(cmd, def) < 0)
         goto cleanup;
 
     ret = 0;
-- 
2.20.1

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