From nobody Sun Oct 5 01:49:59 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=1758826056; cv=none; d=zohomail.com; s=zohoarc; b=GwF7tup4Vxn3wA/OH0AR2+Wy1of2CySIYe6xDY2CXr4caL5+u0lLtsOfKEsiK5WpaB9ohbCFfFCc+0g3YYXlZQy7wZW2UKtqk6ktMALdnYPrDMopTuxp2HSGamd+B8EJ8qM7Av5ydkx6WbnkSQqD+LkUI10zgHZ6UfqWrIQVA0g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1758826056; 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=goQvEpbLNuLVXm2GilXs+T8pt/cPE+0PLqdTiZ0wSSA=; b=jk3PMi31Oo2qfQsRgFpW7dgXTUmKZFUGDrOJbnELSUtxS8Kiso+2qap/hJhA0gQB7tsQumTLGURLg9LjFJtCVmtj5VjbH2auc5Jfv7QXe54klb0xPyyZTgsYoc4lgjy3IEf9DdkmVAUu9xsjvnwBwfyKUdi3m/KfBp288AThCeI= 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 1758826055998398.6901294070134; Thu, 25 Sep 2025 11:47:35 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 1E62241964; Thu, 25 Sep 2025 14:47:35 -0400 (EDT) Received: from [172.19.199.14] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id A4BDD41AB2; Thu, 25 Sep 2025 14:13:58 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 0E3F743FB2; Thu, 25 Sep 2025 14:12:06 -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 C27F244080 for ; Thu, 25 Sep 2025 14:07:51 -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-18-hFLbKV9sOeiY0A-icUxw_w-1; Thu, 25 Sep 2025 14:07:50 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 38855180048E for ; Thu, 25 Sep 2025 18:07:49 +0000 (UTC) Received: from harajuku.usersys.redhat.com.homenet.telecomitalia.it (unknown [10.45.225.196]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 65B83300021A for ; Thu, 25 Sep 2025 18:07:48 +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=1758823671; 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=goQvEpbLNuLVXm2GilXs+T8pt/cPE+0PLqdTiZ0wSSA=; b=as5M8bhzHdudYVX+wRbMGVfDDc/fIvy6KlraqPemga5k8rAEVVjW/NEUTy8NWP0lzjohKX r8QTmJo//ibz8WIPXa9SC82jeo6kC4SN0HTg+2r3u0lYqHyL7uj49v/OWIWRZSqeenScy1 l/BdkI0ZYMUq7Q2Zt4wbS210WLLuKmg= X-MC-Unique: hFLbKV9sOeiY0A-icUxw_w-1 X-Mimecast-MFC-AGG-ID: hFLbKV9sOeiY0A-icUxw_w_1758823669 To: devel@lists.libvirt.org Subject: [PATCH v2 15/38] qemu: Introduce qemuDomainNetIsPCI() Date: Thu, 25 Sep 2025 20:07:01 +0200 Message-ID: <20250925180724.500758-16-abologna@redhat.com> In-Reply-To: <20250925180724.500758-1-abologna@redhat.com> References: <20250925180724.500758-1-abologna@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: aUM-2jr6kZdQIwOQenwygL9DBxGNKhZHEHHoca1_6P4_1758823669 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: FCGKRBTD6DFJUQJMLJYQCMTQK2WY423Z X-Message-ID-Hash: FCGKRBTD6DFJUQJMLJYQCMTQK2WY423Z X-MailFrom: abologna@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: Andrea Bolognani via Devel Reply-To: Andrea Bolognani X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1758826058083116600 Content-Type: text/plain; charset="utf-8"; x-default="true" This centralizes the knowledge about which network interface models are PCI devices and thus need to have a PCI address allocated by libvirt, and expands said knowledge to include the fact that models such as spapr-vlan and smc91c111 are not PCI devices. Signed-off-by: Andrea Bolognani Reviewed-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/qemu/qemu_domain_address.c | 59 +++++++++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 96a9ca9b14..ebf6a38fde 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -499,6 +499,55 @@ qemuDomainDeviceCalculatePCIAddressExtensionFlags(virQ= EMUCaps *qemuCaps, } =20 =20 +static bool +qemuDomainNetIsPCI(const virDomainNetDef *net) +{ + switch ((virDomainNetModelType)net->model) { + case VIR_DOMAIN_NET_MODEL_USB_NET: + case VIR_DOMAIN_NET_MODEL_SPAPR_VLAN: + case VIR_DOMAIN_NET_MODEL_LAN9118: + case VIR_DOMAIN_NET_MODEL_SMC91C111: + /* The models above are not PCI devices */ + return false; + + case VIR_DOMAIN_NET_MODEL_RTL8139: + case VIR_DOMAIN_NET_MODEL_VIRTIO: + case VIR_DOMAIN_NET_MODEL_E1000: + case VIR_DOMAIN_NET_MODEL_E1000E: + case VIR_DOMAIN_NET_MODEL_IGB: + case VIR_DOMAIN_NET_MODEL_VIRTIO_TRANSITIONAL: + case VIR_DOMAIN_NET_MODEL_VIRTIO_NON_TRANSITIONAL: + case VIR_DOMAIN_NET_MODEL_VMXNET3: + /* The models above are PCI devices */ + return true; + + case VIR_DOMAIN_NET_MODEL_NETFRONT: + case VIR_DOMAIN_NET_MODEL_VMXNET: + case VIR_DOMAIN_NET_MODEL_VMXNET2: + case VIR_DOMAIN_NET_MODEL_VLANCE: + case VIR_DOMAIN_NET_MODEL_AM79C970A: + case VIR_DOMAIN_NET_MODEL_AM79C973: + case VIR_DOMAIN_NET_MODEL_82540EM: + case VIR_DOMAIN_NET_MODEL_82545EM: + case VIR_DOMAIN_NET_MODEL_82543GC: + case VIR_DOMAIN_NET_MODEL_UNKNOWN: + /* The models above are probably not PCI devices, and in fact + * some of them are not even relevant to the QEMU driver, but + * historically we've defaulted to considering all network + * interfaces to be PCI so we preserve that behavior here */ + return true; + + case VIR_DOMAIN_NET_MODEL_LAST: + default: + /* Due to historical reasons, model names for network interfaces + * are not validated as strictly as other devices. When in doubt, + * assume that network interfaces are PCI devices, as that has + * the highest chance of working correctly */ + return true; + } +} + + /** * qemuDomainDeviceCalculatePCIConnectFlags: * @@ -669,10 +718,11 @@ qemuDomainDeviceCalculatePCIConnectFlags(virDomainDev= iceDef *dev, * address is assigned when we're assigning the * addresses for other hostdev devices. */ - if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_HOSTDEV || - net->model =3D=3D VIR_DOMAIN_NET_MODEL_USB_NET) { + if (net->type =3D=3D VIR_DOMAIN_NET_TYPE_HOSTDEV) + return 0; + + if (!qemuDomainNetIsPCI(net)) return 0; - } =20 if (net->model =3D=3D VIR_DOMAIN_NET_MODEL_VIRTIO || net->model =3D=3D VIR_DOMAIN_NET_MODEL_VIRTIO_NON_TRANSITIONAL) @@ -2110,9 +2160,8 @@ qemuDomainAssignDevicePCISlots(virDomainDef *def, for (i =3D 0; i < def->nnets; i++) { virDomainNetDef *net =3D def->nets[i]; =20 - if (net->model =3D=3D VIR_DOMAIN_NET_MODEL_USB_NET) { + if (!qemuDomainNetIsPCI(net)) continue; - } =20 /* type=3D'hostdev' network devices might be USB, and are also * in hostdevs list anyway, so handle them with other hostdevs --=20 2.51.0