From nobody Tue Mar 3 04:52:43 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=1771245484; cv=none; d=zohomail.com; s=zohoarc; b=eOCvS/EY6dBKX4q84noha/nIk/ncAWu2eu3Ci0F41bUhgauptvAZ1SVeNY0zCJX61yfEPvaSgrIfC4X8DA2VjWcUwZZZyMZZ8qlvY6p1FSdNoUCHYDfcsyZSS3gXBexOMzp5FWKzgomL5ThOfySVJUcB9751bHblNQMkHvJYnsk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771245484; 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=oQiAnioPQxPiFOmQWysfFW+XWmhleaUo0vRIBOjKy2o=; b=ism1uz3iJkL1fJGKsJG5oThYmbltGBGirZa41dYLkvbf7nW9VjFFt9EPjUplijiYbqzH9JXqsqzYrNp9IZIVFizQdGnWAlYchwbpSlQzqhrAeCLAcqfiyjiuH1kkquKysC9J6khrD6rDDaieGNe7ZglA0cfbLhMP7RetWOgBHvE= 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 1771245484025794.4589800409082; Mon, 16 Feb 2026 04:38:04 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 3C9913F361; Mon, 16 Feb 2026 07:38:04 -0500 (EST) Received: from [172.19.199.9] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 1D4C441AD3; Mon, 16 Feb 2026 07:30:03 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id DA0D7418E9; Mon, 16 Feb 2026 07:29:58 -0500 (EST) 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 76CDB4182E for ; Mon, 16 Feb 2026 07:28:29 -0500 (EST) 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-683-nKhAJKtRNYWyXCIyA51ugA-1; Mon, 16 Feb 2026 07:28:27 -0500 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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 34FAD180057E for ; Mon, 16 Feb 2026 12:28:27 +0000 (UTC) Received: from antique-laptop.rosnicka.net (unknown [10.45.242.10]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 8957E3000218 for ; Mon, 16 Feb 2026 12:28:26 +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=-5.0 required=5.0 tests=BAYES_00,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=1771244909; 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=oQiAnioPQxPiFOmQWysfFW+XWmhleaUo0vRIBOjKy2o=; b=Gqj1MsMQQ3tne2+GJms37KUm5FZgQwnhuIp2zQFd+1EPAfZvpRMJeMCT0vN2H4+sELAM18 Ocd3yLFVVJP+2IX/oRKeIkE3B7WL0lzoikPuC8aQLiIs8brfRR4ew8DalWagx8szfOznVR AOfajYDmv9P6kmlHq/MVpDK2B1ox/Jo= X-MC-Unique: nKhAJKtRNYWyXCIyA51ugA-1 X-Mimecast-MFC-AGG-ID: nKhAJKtRNYWyXCIyA51ugA_1771244907 To: devel@lists.libvirt.org Subject: [libvirt PATCH 08/24] conf: Introduce virHostdevIsPCIDeviceWithIOMMUFD Date: Mon, 16 Feb 2026 13:28:00 +0100 Message-ID: <5db8fffc31df8f9c368e4f6f92101d9e768ac8aa.1771244723.git.phrdina@redhat.com> 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: olHh1lwOSERZ9bii5hvRM8D6XMCAzj8MzO08d_I31Yg_1771244907 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: I36WU4FGHFCL55K6X7CVECER5R7QYFNE X-Message-ID-Hash: I36WU4FGHFCL55K6X7CVECER5R7QYFNE 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: 1771245485907158500 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 15 +++++++++++++++ src/conf/domain_conf.h | 3 +++ src/libvirt_private.syms | 1 + src/qemu/qemu_process.c | 5 +---- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index e3c69aee4d..98d34f408d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -32939,6 +32939,21 @@ virHostdevIsPCIDevice(const virDomainHostdevDef *h= ostdev) } =20 =20 +/** + * virHostdevIsPCIDeviceWithIOMMUFD: + * @hostdev: host device to check + * + * Returns true if @hostdev is a PCI device with IOMMUFD enabled, false ot= herwise. + */ +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; +} + + static void virDomainObjGetMessagesIOErrorsSrc(virStorageSource *src, const char *diskdst, diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index be96617981..f98fed650a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -4720,6 +4720,9 @@ virHostdevIsMdevDevice(const virDomainHostdevDef *hos= tdev) bool virHostdevIsPCIDevice(const virDomainHostdevDef *hostdev) ATTRIBUTE_NONNULL(1); +bool +virHostdevIsPCIDeviceWithIOMMUFD(const virDomainHostdevDef *hostdev) + ATTRIBUTE_NONNULL(1); =20 void virDomainObjGetMessagesIOErrorsChain(virStorageSource *src, diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 4d29512e0b..15a56a262a 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -813,6 +813,7 @@ virDomainQemuMonitorEventNew; virDomainQemuMonitorEventStateRegisterID; virHostdevIsMdevDevice; virHostdevIsPCIDevice; +virHostdevIsPCIDeviceWithIOMMUFD; virHostdevIsSCSIDevice; =20 =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2bab46fca6..cfc30dcbe4 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7736,10 +7736,7 @@ qemuProcessOpenVfioFds(virDomainObj *vm) for (i =3D 0; i < vm->def->nhostdevs; i++) { virDomainHostdevDef *hostdev =3D vm->def->hostdevs[i]; =20 - if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && - hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_T= YPE_PCI && - hostdev->source.subsys.u.pci.driver.name =3D=3D VIR_DEVICE_HOS= TDEV_PCI_DRIVER_NAME_VFIO && - hostdev->source.subsys.u.pci.driver.iommufd =3D=3D VIR_TRISTAT= E_BOOL_YES) { + if (virHostdevIsPCIDeviceWithIOMMUFD(hostdev)) { /* Open VFIO device FD */ if (qemuProcessOpenVfioDeviceFd(hostdev) < 0) return -1; --=20 2.53.0