From nobody Sun Sep 7 23:35:45 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 From nobody Sun Sep 7 23:35:45 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=1756276944; cv=none; d=zohomail.com; s=zohoarc; b=nSXwNXr74XJgFA80KrUuNM57OqqFBqnoBqrxQaKtrpeKnq2oaAiXoI9Zq51/CHYoJsxZdAWAjsLw8ZrEKkiloMMfM/MxYoHMCjAazYnpG5joSgbrn2B83j1ZEtNt51BtrzlmM2v0XVxZk6v5Tw1r0iL5eQ4OjFV5MmesksuxUAw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756276944; 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=R8pwc9oEfm+31tfSP3dov7KcGkTt7wEKN0bazD9W9vU=; b=d2ZHdn/GvJUDYpmGGSFVzTEf4AkWjHva8l6jd07f0M6CaXcFv2qKE9hhLk5nC/AC5N8tCkhaeuDZr64crNy2YQGlYo8Nf97yaK4mhoySAXKXN5XogDa+7cVFdiTG1qTWK6ptB2M9/HVF8xhFvRN3+jrOXCsrjgv6GNboWOyKqkQ= 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 1756276944488996.3839736476377; Tue, 26 Aug 2025 23:42:24 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 9FF5043F40; Wed, 27 Aug 2025 02:42:23 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 3BF81440D3; Wed, 27 Aug 2025 02:38:37 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 139EF43F37; Wed, 27 Aug 2025 02:38:15 -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 E4A1F43F34 for ; Wed, 27 Aug 2025 02:38:13 -0400 (EDT) Received: from mx-prod-mc-08.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-687-CWGGY4zAOxqXXw8uqvMjnQ-1; Wed, 27 Aug 2025 02:38:11 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5A2D91800446 for ; Wed, 27 Aug 2025 06:38:10 +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 E46E019560AB 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=1756276693; 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=R8pwc9oEfm+31tfSP3dov7KcGkTt7wEKN0bazD9W9vU=; b=JRixZciBuQp0kNUgP6yDnHfcaMmH1WlkA3fMu8yzWAjhRwO6IaioLGtWogMhRlh5gMsmTz 8aqbqlfx+uCwx5Vd09aqfedUG776HTqhJPYmEbzl1/78EJo2u18wiYPVTXFbIFNqueJm8X XZ0xkHel4eAOeNiEPSXIRorVEvjq3+g= X-MC-Unique: CWGGY4zAOxqXXw8uqvMjnQ-1 X-Mimecast-MFC-AGG-ID: CWGGY4zAOxqXXw8uqvMjnQ_1756276690 To: devel@lists.libvirt.org Subject: [PATCH 2/3] conf: improve error message when a PCI controller can't be auto-added Date: Wed, 27 Aug 2025 02:38:06 -0400 Message-ID: <20250827063807.99334-3-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: 8SKuS3fsheIqduWWQR4St1sFPSirhldE9gR4pcUch-k_1756276690 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 46P6WV2SGYR6GFVDTZWPUYREHPQQBLFI X-Message-ID-Hash: 46P6WV2SGYR6GFVDTZWPUYREHPQQBLFI 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: 1756276946796116600 Content-Type: text/plain; charset="utf-8"; x-default="true" Log a slightly different message when the missing-but-required slot is conventional PCI vs PCIe. Also correct/improve the comments about why auto-add of a PCI controller isn't supported when we're trying to create a slot for various different pci controllers. Signed-off-by: Laine Stump --- src/conf/domain_addr.c | 37 +++++++++++++++---- .../pcie-root-port-too-many.x86_64-latest.err | 2 +- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 7d58e2222a..ef1b2bd69a 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -704,7 +704,7 @@ virDomainPCIAddressSetGrow(virDomainPCIAddressSet *addr= s, * and we can't automatically decide which numa node to * associate it with) * - * VIR_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT - we ndon't + * VIR_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT - we don't * support this, because it can only plug into an * upstream-port, and the upstream port might need a * root-port; supporting this extra layer needlessly @@ -717,20 +717,41 @@ virDomainPCIAddressSetGrow(virDomainPCIAddressSet *ad= drs, * devices on the host, and are also outside the scope of our * "automatic-bus-expansion". * - * VIR_PCI_CONNECT_TYPE_PCI_BRIDGE (when the root bus is - * pci-root) - see the comment above in the case that handles - * adding a slot for pci-bridge to a guest with pcie-root. + * VIR_PCI_CONNECT_TYPE_PCI_BRIDGE if the root bus is pci-root + * but there are no free slots already available to plug in a + * pci-bridge, then the battle is already lost - the only way + * to get another open slot would be to auto-add a pci-bridge + * device, but that's what we're already trying to do - by + * definition either we wouldn't get here in the first place, + * or it's already too late. + * + * Alternatively if the root bus *isn't* pci-root, then + * either the root bus is pcie-root (in which case the user + * should be using a pcie-to-pci-bridge instead), or there is + * no PCI supported *at all*, and in both of those cases we + * should fail. + * + * Additionally, we obviously can't auto-add any type of PCIe + * controller if the root bus is pci-root, or if there is no + * PCI supported at all. * */ int existingContModel =3D virDomainPCIControllerConnectTypeToModel= (flags); =20 if (existingContModel >=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("a PCI slot is needed to connect a PCI contro= ller model=3D'%1$s', but none is available, and it cannot be automatically = added"), - virDomainControllerModelPCITypeToString(existin= gContModel)); + if (existingContModel =3D=3D VIR_PCI_CONNECT_TYPE_PCI_EXPANDER= _BUS || + existingContModel =3D=3D VIR_PCI_CONNECT_TYPE_PCI_BRIDGE) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("a conventional PCI slot is needed to con= nect a PCI controller model=3D'%1$s', but none is available, and it cannot = be automatically added"), + virDomainControllerModelPCITypeToString(exi= stingContModel)); + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("a PCIe slot is needed to connect a PCI c= ontroller model=3D'%1$s', but none is available, and it cannot be automatic= ally added"), + virDomainControllerModelPCITypeToString(exi= stingContModel)); + } } else { virReportError(VIR_ERR_INTERNAL_ERROR, - _("Cannot automatically add a new PCI bus for a= device with connect flags %1$.2x"), + _("Cannot automatically add a new PCI bus for a= device with unrecognized connect flags %1$.2x"), flags); } return -1; diff --git a/tests/qemuxmlconfdata/pcie-root-port-too-many.x86_64-latest.er= r b/tests/qemuxmlconfdata/pcie-root-port-too-many.x86_64-latest.err index 9b24cfb7e0..e1d543a50a 100644 --- a/tests/qemuxmlconfdata/pcie-root-port-too-many.x86_64-latest.err +++ b/tests/qemuxmlconfdata/pcie-root-port-too-many.x86_64-latest.err @@ -1 +1 @@ -internal error: a PCI slot is needed to connect a PCI controller model=3D'= pcie-root-port', but none is available, and it cannot be automatically added +internal error: a PCIe slot is needed to connect a PCI controller model=3D= 'pcie-root-port', but none is available, and it cannot be automatically add= ed --=20 2.51.0 From nobody Sun Sep 7 23:35:45 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=1756276877; cv=none; d=zohomail.com; s=zohoarc; b=QcuskNgSVUOCQwq3yKdAlM78TdnYffaGJ7QAYgxfQzUX4T4s+m8eFr6iwiL6pCQjdJSOWPpPecK4sEYyhstaP8qIisc9Rb3wtdt41FS2rFbfjFP8sO123QtzAUdabToIk0zLF7kaKx8nSjV4kHx5szdp7/i652oXeb9wqjt5Msk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756276877; 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=xUUolvabg5MOm2xG7kCJJNPh7ZWdPkH8/tq0jdrOvbg=; b=AlmzsRyGz1Z2NTZSdLyHpfRYy6rXNL6ycGMU4jUcW8S9GvG9YIv1oof4hrCMtD22DZf1GGRtUJa3OCY6G2Y3fUs3VZt+l83zFbjNaMsQF+yxnB9NPw5/v0rTDktGOZ2BfefaCiluffwB+OAfhhGmzM2/KxZ2IlL5Uhqsld3DESg= 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 1756276877157888.864169202333; Tue, 26 Aug 2025 23:41:17 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 5B57943F9D; Wed, 27 Aug 2025 02:41:15 -0400 (EDT) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 3718243FCC; Wed, 27 Aug 2025 02:38:31 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 9E46843F3E; Wed, 27 Aug 2025 02:38:14 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 EAC6743F37 for ; Wed, 27 Aug 2025 02:38:13 -0400 (EDT) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-416-8ytajHLAOoGmabjfqedoSg-1; Wed, 27 Aug 2025 02:38:11 -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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1760219560AE for ; Wed, 27 Aug 2025 06:38:11 +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 A111F19560AB for ; Wed, 27 Aug 2025 06:38:10 +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=1756276693; 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=xUUolvabg5MOm2xG7kCJJNPh7ZWdPkH8/tq0jdrOvbg=; b=WZJBEz4bYBgqZ2AJ1C1Whj6yeSvUAtvh51vt4t0a7RpZXP+/GOkDYzoOwcmPim+kxflnJJ 6KrbI7NJu9wEQYCFcTAEGtSs3LiArqgagUD6+s6StF+ThDIE8qlg5W8D2s3po5g+NjlU7q XdthciEy1+nUaPomCMaSgY1VSzWhbZs= X-MC-Unique: 8ytajHLAOoGmabjfqedoSg-1 X-Mimecast-MFC-AGG-ID: 8ytajHLAOoGmabjfqedoSg_1756276691 To: devel@lists.libvirt.org Subject: [PATCH 3/3] conf: auto-add a pcie-root-port when needed while plugging in pcie-to-pci-bridge Date: Wed, 27 Aug 2025 02:38:07 -0400 Message-ID: <20250827063807.99334-4-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: YVYM__5cKdqrr_78z2Sa6rYZCk-6yz4wkPSTvQfXh8Y_1756276691 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: AGNTCHHYFLJDVXAQ7EFBIK7HAYVDHQGE X-Message-ID-Hash: AGNTCHHYFLJDVXAQ7EFBIK7HAYVDHQGE 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: 1756276888580124100 Content-Type: text/plain; charset="utf-8"; x-default="true" This will almost surely never come up during any normal operation[*], which is likely why this wasn't done when pcie-to-pci-bridge support was added back in the before-fore times. It's pretty simple to support though - a pcie-to-pci-bridge plugs into a pcie-root-port just like any other pcie device, and if there isn't an open slot on an existing pcie-root-port, we can just add one. ([*] in real life, a pcie-to-pci-bridge is only auto-added by libvirt itself, while this function is dealing with the followup to *user added* devices. Also each pcie-to-pci-bridge has 32 slots, and it's unlikely a domain with pcie support would be wanting more than 32 conventional PCI (i.e. not PCIe) devices) Signed-off-by: Laine Stump --- src/conf/domain_addr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index ef1b2bd69a..6aa5ac1b9f 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -691,7 +691,8 @@ virDomainPCIAddressSetGrow(virDomainPCIAddressSet *addr= s, } } } else if (flags & (VIR_PCI_CONNECT_TYPE_PCIE_DEVICE | - VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT)) { + VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT | + VIR_PCI_CONNECT_TYPE_PCIE_TO_PCI_BRIDGE)) { model =3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT; } else { /* The types of devices that we can't auto-add a controller for: --=20 2.51.0