From nobody Mon Sep 8 17:04:35 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1756276820; cv=none; d=zohomail.com; s=zohoarc; b=AZBau93yFY5aW0+D6ralD2L9KuPSvxe7qwjcTJD+peisy+lwGj2kspV3WYr8nM3Fql5J4ihZzdC1ATnI2If4Edg8+Aq1yGEOPbxjLV1ios07zThvcjm4fKbdCEiRtnSutAgui9efwxfbsiGEcIoDuevGNVc4szSXOQB44dMY72c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756276820; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=mt1/Rn6LqwrTCRjSC10UWvI6Y4smDFw/1hSJ41qGULQ=; b=fzRLrHFWk6uvJJlTtI+ua8yFoAAVPQYe2Z9s7MIGNp+ol/XI78ocdbYbYD+bTmtYDpDX2I+IR/OEAv9q3pPOonsDFkDDuD5ypbeBPUI3GuFAKJCLurQ+MA/gxr/qFC008xEWVByJcod1VRmXjq/uQjWto/hPBZ2YKXiTEMigtko= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1756276820807632.3059477920609; Tue, 26 Aug 2025 23:40:20 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id D54F343F6E; Wed, 27 Aug 2025 02:40:19 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 88FF74403A; Wed, 27 Aug 2025 02:38:26 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 97BD343F36; Wed, 27 Aug 2025 02:38:13 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id E898043F3C for ; Wed, 27 Aug 2025 02:38:12 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-651-wtiqiiAcMh6PQyiSGTG9fg-1; Wed, 27 Aug 2025 02:38:10 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9E3D91800286 for ; Wed, 27 Aug 2025 06:38:09 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.22.65.70]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 34B1419560AD for ; Wed, 27 Aug 2025 06:38:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1756276692; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mt1/Rn6LqwrTCRjSC10UWvI6Y4smDFw/1hSJ41qGULQ=; b=HAU+dchDrW7yHzLvdnlLeE9oE64ZzpuyWWQ6EK4JyIWvMiH4tXldu6Ix8oKBScGsBVszDQ N9CJ+55gnmPLFKfSwQgFCgtbJi/1rbPQbsZQh/p1WUeAdduxkIMFhqEnsORPoCKtRkyReP IwojkiE9y0DWEuA7Ug42Ac6FXrPlZhI= X-MC-Unique: wtiqiiAcMh6PQyiSGTG9fg-1 X-Mimecast-MFC-AGG-ID: wtiqiiAcMh6PQyiSGTG9fg_1756276689 To: devel@lists.libvirt.org Subject: [PATCH 1/3] conf: add forgotten clause to virDomainPCIControllerConectTypeToModel() Date: Wed, 27 Aug 2025 02:38:05 -0400 Message-ID: <20250827063807.99334-2-laine@redhat.com> In-Reply-To: <20250827063807.99334-1-laine@redhat.com> References: <20250827063807.99334-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: gYegHTNZB9MDeKkeU_jW_CNFpW27h4uW0BFqLJ3rgp0_1756276689 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: J4KZVSJUTWY3TRLKBOV37RM5GFZ4HRVS X-Message-ID-Hash: J4KZVSJUTWY3TRLKBOV37RM5GFZ4HRVS X-MailFrom: laine@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Laine Stump via Devel Reply-To: Laine Stump X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1756276826310124100 Content-Type: text/plain; charset="utf-8"; x-default="true" When building the PCI topology of a domain that has PCI devices with no assigned PCI addresses, the function virDomainPCIAddressSetGrow() will attempt to add a new PCI controller with the appropriate type of slot to connect a device that doesn't have a PCI address. In some cases this isn't possible (for example, if the device you are attempting to add to the topology requires a type of connection only provided by some controller that *itself* requires a connection of a type not available for the given architecture/machinetype, e.g. if you want to add a pcie-root-port to a domain with a machine type that has a pci-root (no PCIE)). In those cases, an error message is logged by using virDomainPCIControllerConectTypeToModel() to extract the type of device from the "flags" that are sent to virDomainPCIAddressSetGrow(). However, if virDomainPCIControllerConectTypeToModel() doesn't find a device type in the connection flags, it will return -1, and virDomainPCIAddressSetGrow() will log the very generic: Cannot automatically add a new PCI bus for a device with connect flags n= nnn Both of these functions were written prior to libvirt adding support for the pcie-to-pci-bridge controller, and when that support was added (in 2018), a new if() clause wasn't added to virDomainPCIControllerConectTypeToModel(). Seven (!) years later, this omission was noticed by someone adding a new test case to regression testing. This patches remedies the earlier omission, so that now when someone tries to add a pcie-to-pci-bridge controller to a domain that doesn't have PCIE, the message will be: a PCI slot is needed to connect a PCI controller model=3D'pcie-to-pci-bri= dge', but none is available, and it cannot be automatically added This is still not an ideal error message, but is arguably better. (NB: Unfortunately it isn't possible to use a switch() statement with no default case (in order to catch a similar error in the future), since we are converting from bitmapped flags. Fortunately, we haven't needed to add a new PCI controller type in the last 7 1/2 years :-) Resolves: https://issues.redhat.com/browse/RHEL-62032 Fixes: 542f05e7756cc5614eb2ee7b0bac9aabb7aa016c Signed-off-by: Laine Stump --- src/conf/domain_addr.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 8dfa8feca0..7d58e2222a 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -286,6 +286,9 @@ virDomainPCIControllerConnectTypeToModel(virDomainPCICo= nnectFlags flags) if (flags & VIR_PCI_CONNECT_TYPE_PCI_BRIDGE) return VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE; =20 + if (flags & VIR_PCI_CONNECT_TYPE_PCIE_TO_PCI_BRIDGE) + return VIR_DOMAIN_CONTROLLER_MODEL_PCIE_TO_PCI_BRIDGE; + /* some connect types don't correspond to a controller model */ return -1; } --=20 2.51.0