[PATCH v2 13/17] qemu: Drop all code dealing with the legacy USB controller

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

 



With the recent changes, we have ensured that all situations
that would have until now caused this code to be executed are
either handled by dropping the USB controller or by raising
an error.

Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 78 -----------------------------------------
 src/qemu/qemu_domain.c  | 11 ------
 2 files changed, 89 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index a544a3ccdc..28bdcf8d99 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2855,62 +2855,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)
-{
-    size_t i;
-    size_t nlegacy = 0;
-    size_t nusb = 0;
-
-    for (i = 0; i < def->ncontrollers; i++) {
-        virDomainControllerDef *cont = def->controllers[i];
-
-        if (cont->type != VIR_DOMAIN_CONTROLLER_TYPE_USB)
-            continue;
-
-        /* If we have mode='none', there are no other USB controllers */
-        if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE)
-            return 0;
-
-        if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT)
-            nlegacy++;
-        else
-            nusb++;
-    }
-
-    if (nlegacy > 1) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                       _("Multiple legacy USB controllers are not supported"));
-        return -1;
-    }
-
-    if (nusb == 0 &&
-        nlegacy > 0 &&
-        !qemuBuildDomainForbidLegacyUSBController(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
@@ -2997,25 +2941,6 @@ qemuBuildControllersByTypeCommandLine(virCommand *cmd,
             continue;
         }
 
-        if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB &&
-            cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT &&
-            !qemuBuildDomainForbidLegacyUSBController(def)) {
-
-            /* An appropriate default USB controller model should already
-             * have been selected in qemuDomainDeviceDefPostParse(); if
-             * we still have no model by now, we have to fall back to the
-             * legacy USB controller.
-             *
-             * Note that we *don't* want to end up with the legacy USB
-             * controller for q35 and virt machines, so we go ahead and
-             * fail in qemuBuildControllerDevProps(); on the other hand,
-             * for s390 machines we want to ignore any USB controller
-             * (see 548ba43028 for the full story), so we skip
-             * qemuBuildControllerDevProps() but we don't ultimately end
-             * up adding the legacy USB controller */
-            continue;
-        }
-
         if (qemuBuildControllerDevProps(def, cont, qemuCaps, &props) < 0)
             return -1;
 
@@ -3071,9 +2996,6 @@ qemuBuildControllersCommandLine(virCommand *cmd,
             return -1;
     }
 
-    if (qemuBuildLegacyUSBControllerCommandLine(cmd, def) < 0)
-        return -1;
-
     return 0;
 }
 
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 03ad590759..c194928ed1 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -5653,17 +5653,6 @@ qemuDomainControllerDefPostParse(virDomainControllerDef *cont,
 
     case VIR_DOMAIN_CONTROLLER_TYPE_USB:
         if (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT && qemuCaps) {
-            /* Pick a suitable default model for the USB controller if none
-             * has been selected by the user and we have the qemuCaps for
-             * figuring out which controllers are supported.
-             *
-             * We rely on device availability instead of setting the model
-             * unconditionally because, for some machine types, there's a
-             * chance we will get away with using the legacy USB controller
-             * when the relevant device is not available.
-             *
-             * See qemuBuildControllersCommandLine() */
-
             /* Default USB controller is piix3-uhci if available. */
             if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI))
                 cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI;
-- 
2.43.0
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[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