From nobody Tue Mar 24 00:58:09 2026 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=1773938389; cv=none; d=zohomail.com; s=zohoarc; b=ntE2UZglKfkkNtoeI6fe6a0RvMhQdQPpPMoydaQchUfq5QdJxqzF3+XoaUZM8X6bAVS16ZOJ4hV2WqPJ+La6/nmH5JPTaGwealCGUdvzpIWitAzgMh1tNzjVQ4ewKL+z47X6/T8bkWuhhEv6H080rBxIZH2pVsnIaq5WBruNGqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773938389; 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=xSmZFgFXggtmz347oYBCs2uJKsGAGY61faUPk26abt4=; b=N4G1g8x7O+ykgr3O+xhELQfLRS6M5FufKO9e2RMhDQvsaofH1rbAclE9Eu9rXLs6BkASmyPP1W8o57tc4fUzD67QvOVFuYWLrajsBrskAnFdslg7Xp/hcsaW9PeBLMCcoMWA23p5f8F/M5pQldwrpFFU1QOdV65lwyixQBU0h60= 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 1773938388917167.32795897041422; Thu, 19 Mar 2026 09:39:48 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 0155C41AD5; Thu, 19 Mar 2026 12:39:48 -0400 (EDT) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id B956B41880; Thu, 19 Mar 2026 12:37:10 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 72AAB4180D; Thu, 19 Mar 2026 12:37:04 -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 ED7233F363 for ; Thu, 19 Mar 2026 12:37:03 -0400 (EDT) Received: from mx-prod-mc-01.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-488-IjNHSBTOMFK0MYhxr5H8nQ-1; Thu, 19 Mar 2026 12:37:02 -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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 72311195608C for ; Thu, 19 Mar 2026 16:37:01 +0000 (UTC) Received: from antique-work.redhat.com (unknown [10.44.33.53]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C014930002E0 for ; Thu, 19 Mar 2026 16:37:00 +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=-2.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,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=1773938223; 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=xSmZFgFXggtmz347oYBCs2uJKsGAGY61faUPk26abt4=; b=J75dnkygGpXMb75P74rExoQZ67N9Y6Cg8HVUOmmF4IXYhFt47BxByjJuRPbpdn51f/EhTo FVxDc6agv1dG5PGih3bQXq4JHnb2JLqh4sEbmKxJ/tKjtjJ31pPz42vyIYJEcYfqqfnGcS 9NjoWucHjzpgWIRGpjLPLvTdoy2RhXQ= X-MC-Unique: IjNHSBTOMFK0MYhxr5H8nQ-1 X-Mimecast-MFC-AGG-ID: IjNHSBTOMFK0MYhxr5H8nQ_1773938221 To: devel@lists.libvirt.org Subject: [libvirt PATCH 02/11] conf: Refactor virHostdevIsPCIDevice Date: Thu, 19 Mar 2026 17:36:48 +0100 Message-ID: In-Reply-To: References: 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: Mnc4R5niKEMyusIAEFwsH6kkZdEAcDlIRhR5RI68J7E_1773938221 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ABILZXA2EL327QR4AACO4TWMY5N25JNW X-Message-ID-Hash: ABILZXA2EL327QR4AACO4TWMY5N25JNW X-MailFrom: phrdina@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: Pavel Hrdina via Devel Reply-To: Pavel Hrdina X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1773938389895158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Pavel Hrdina Future patches will need to check if the host device uses IOMMUFD or not but we also need to keep a function that will check only if it is PCI devic= e. Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/conf/domain_conf.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b1a73afef2..01e2bd631a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -33026,6 +33026,33 @@ virHostdevIsMdevDevice(const virDomainHostdevDef *= hostdev) } =20 =20 +static bool +virHostdevPCIDevHasIOMMUFD(const virDomainHostdevDef *hostdev) +{ + return hostdev->source.subsys.u.pci.driver.name =3D=3D VIR_DEVICE_HOST= DEV_PCI_DRIVER_NAME_VFIO && + hostdev->source.subsys.u.pci.driver.iommufd =3D=3D VIR_TRISTATE_BO= OL_YES; +} + + +static bool +virHostdevIsPCIDeviceImpl(const virDomainHostdevDef *hostdev, + virTristateBool iommufd) +{ + if (hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) + return false; + + if (hostdev->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PC= I) + return false; + + if (iommufd !=3D VIR_TRISTATE_BOOL_ABSENT) { + bool hasIOMMUFD =3D iommufd =3D=3D VIR_TRISTATE_BOOL_YES; + return hasIOMMUFD =3D=3D virHostdevPCIDevHasIOMMUFD(hostdev); + } + + return true; +} + + /** * virHostdevIsPCIDevice: * @hostdev: host device to check @@ -33035,8 +33062,7 @@ virHostdevIsMdevDevice(const virDomainHostdevDef *h= ostdev) bool virHostdevIsPCIDevice(const virDomainHostdevDef *hostdev) { - return hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && - hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= PCI; + return virHostdevIsPCIDeviceImpl(hostdev, VIR_TRISTATE_BOOL_ABSENT); } =20 =20 @@ -33049,9 +33075,7 @@ virHostdevIsPCIDevice(const virDomainHostdevDef *ho= stdev) bool virHostdevIsPCIDeviceWithIOMMUFD(const virDomainHostdevDef *hostdev) { - return virHostdevIsPCIDevice(hostdev) && - hostdev->source.subsys.u.pci.driver.name =3D=3D VIR_DEVICE_HOSTDEV= _PCI_DRIVER_NAME_VFIO && - hostdev->source.subsys.u.pci.driver.iommufd =3D=3D VIR_TRISTATE_BO= OL_YES; + return virHostdevIsPCIDeviceImpl(hostdev, VIR_TRISTATE_BOOL_YES); } =20 =20 --=20 2.53.0