[PATCH 22/33] qemu: Move qemuDomainForbidLegacyUSBController()

Andrea Bolognani posted 33 patches 8 months, 2 weeks ago
There is a newer version of this series
[PATCH 22/33] qemu: Move qemuDomainForbidLegacyUSBController()
Posted by Andrea Bolognani 8 months, 2 weeks ago
This function is tightly coupled with
qemuDomainDefaultUSBControllerModel(), as whether or not the
legacy '-usb' option is going to be used depends on the return
value of both. As such, it makes sense for them to be close to
one another.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 src/qemu/qemu_command.c | 16 ++--------------
 src/qemu/qemu_domain.c  | 12 ++++++++++++
 src/qemu/qemu_domain.h  |  1 +
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 4aad7066e9..ec4982bbf6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2918,18 +2918,6 @@ qemuBuildControllerDevProps(const virDomainDef *domainDef,
 }
 
 
-static bool
-qemuBuildDomainForbidLegacyUSBController(const virDomainDef *def)
-{
-    if (qemuDomainIsQ35(def) ||
-        qemuDomainIsARMVirt(def) ||
-        qemuDomainIsRISCVVirt(def))
-        return true;
-
-    return false;
-}
-
-
 static int
 qemuBuildLegacyUSBControllerCommandLine(virCommand *cmd,
                                         const virDomainDef *def)
@@ -2961,7 +2949,7 @@ qemuBuildLegacyUSBControllerCommandLine(virCommand *cmd,
     }
 
     if (nusb == 0 &&
-        !qemuBuildDomainForbidLegacyUSBController(def) &&
+        !qemuDomainForbidLegacyUSBController(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
@@ -3061,7 +3049,7 @@ qemuBuildControllersByTypeCommandLine(virCommand *cmd,
 
         if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
             cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT &&
-            !qemuBuildDomainForbidLegacyUSBController(def)) {
+            !qemuDomainForbidLegacyUSBController(def)) {
 
             /* An appropriate default USB controller model should already
              * have been selected in qemuDomainDeviceDefPostParse(); if
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index dcf73c0e08..2b7eae295b 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4258,6 +4258,18 @@ qemuDomainDefaultUSBControllerModel(const virDomainDef *def,
 }
 
 
+bool
+qemuDomainForbidLegacyUSBController(const virDomainDef *def)
+{
+    if (qemuDomainIsQ35(def) ||
+        qemuDomainIsARMVirt(def) ||
+        qemuDomainIsRISCVVirt(def))
+        return true;
+
+    return false;
+}
+
+
 static int
 qemuDomainDefAddDefaultDevices(virQEMUDriver *driver,
                                virDomainDef *def,
diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h
index 48f966fa2a..4e61d741f3 100644
--- a/src/qemu/qemu_domain.h
+++ b/src/qemu/qemu_domain.h
@@ -839,6 +839,7 @@ bool qemuDomainSupportsPCIMultibus(const virDomainDef *def);
 int qemuDomainDefaultSCSIControllerModel(const virDomainDef *def,
                                          const virDomainControllerDef *cont,
                                          virQEMUCaps *qemuCaps);
+bool qemuDomainForbidLegacyUSBController(const virDomainDef *def);
 
 void qemuDomainUpdateCurrentMemorySize(virDomainObj *vm);
 
-- 
2.43.0
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [PATCH 22/33] qemu: Move qemuDomainForbidLegacyUSBController()
Posted by Peter Krempa 8 months, 2 weeks ago
On Wed, Jan 24, 2024 at 20:37:42 +0100, Andrea Bolognani wrote:
> This function is tightly coupled with
> qemuDomainDefaultUSBControllerModel(), as whether or not the
> legacy '-usb' option is going to be used depends on the return
> value of both. As such, it makes sense for them to be close to
> one another.

Honestly this logic has nothing to do in the commandline generator, but
that involves the decisions done when calling this function.

For now:

Reviewed-by: Peter Krempa <pkrempa@redhat.com>

I'll see how I like the further changes. OTherwise it'll be more
beneficial to remove also the rest of the logic and not just this
helper.
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org