From nobody Wed Jan 15 14:43:05 2025 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1707932635164692.567998761077; Wed, 14 Feb 2024 09:43:55 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id 17DC61BA7; Wed, 14 Feb 2024 12:43:54 -0500 (EST) Received: from lists.libvirt.org.85.43.8.in-addr.arpa (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id E2DA21BF9; Wed, 14 Feb 2024 12:14:16 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id EBF271A1C; Wed, 14 Feb 2024 12:12:00 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 40A9E1A1C for ; Wed, 14 Feb 2024 12:11:38 -0500 (EST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-283-j1iFhQG0Nk-AyQsbzGLZwA-1; Wed, 14 Feb 2024 12:11:36 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E2CA3862DC8 for ; Wed, 14 Feb 2024 17:11:35 +0000 (UTC) Received: from harajuku.usersys.redhat.com (unknown [10.45.226.93]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7A1E61121337 for ; Wed, 14 Feb 2024 17:11:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 X-MC-Unique: j1iFhQG0Nk-AyQsbzGLZwA-1 From: Andrea Bolognani To: devel@lists.libvirt.org Subject: [PATCH v2 13/17] qemu: Drop all code dealing with the legacy USB controller Date: Wed, 14 Feb 2024 18:11:20 +0100 Message-ID: <20240214171124.508000-14-abologna@redhat.com> In-Reply-To: <20240214171124.508000-1-abologna@redhat.com> References: <20240214171124.508000-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Message-ID-Hash: JNKJD45RK3BS7QKMSU4G47LUNZJV6ZRY X-Message-ID-Hash: JNKJD45RK3BS7QKMSU4G47LUNZJV6ZRY X-MailFrom: abologna@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8"; x-default="true" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1707932636236100001 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 --- 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 *doma= inDef, } =20 =20 -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 =3D 0; - size_t nusb =3D 0; - - for (i =3D 0; i < def->ncontrollers; i++) { - virDomainControllerDef *cont =3D def->controllers[i]; - - if (cont->type !=3D VIR_DOMAIN_CONTROLLER_TYPE_USB) - continue; - - /* If we have mode=3D'none', there are no other USB controllers */ - if (cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) - return 0; - - if (cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_USB_DEFAULT) - nlegacy++; - else - nusb++; - } - - if (nlegacy > 1) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Multiple legacy USB controllers are not supporte= d")); - return -1; - } - - if (nusb =3D=3D 0 && - nlegacy > 0 && - !qemuBuildDomainForbidLegacyUSBController(def) && - !ARCH_IS_S390(def->os.arch)) { - /* We haven't added any USB controller yet, but we haven't been as= ked - * 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 *cm= d, continue; } =20 - if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB && - cont->model =3D=3D 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; =20 @@ -3071,9 +2996,6 @@ qemuBuildControllersCommandLine(virCommand *cmd, return -1; } =20 - if (qemuBuildLegacyUSBControllerCommandLine(cmd, def) < 0) - return -1; - return 0; } =20 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(virDomainController= Def *cont, =20 case VIR_DOMAIN_CONTROLLER_TYPE_USB: if (cont->model =3D=3D 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 =3D VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI; --=20 2.43.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org