From nobody Tue Mar 3 04:55:51 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=1771245525; cv=none; d=zohomail.com; s=zohoarc; b=K7Y6XVallrDofTr8+RlGgIWy7erF+xPxy2RxQP/g3ieUIYpV+EK1V9Wuf3Fy5LjU5PEO6mGfW+DealEA2mR1mELkTyxLSfdQVGUsETWW2AlrPy9EcQt3Cvm7/7Zu18FT7UN4ttJvMGaSGFrPvooudow11mdX4BYaZNSulswgsDE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771245525; 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=89+udoC1CZpL9wVJdZ0N68pjijBevyxPwz+pFFDsBZw=; b=dceZjY7rZAFH7pHtaUPl65f1TiqKxIS5RkQoJRHQC76o1FEUdPL2hy/azcv6kaAubUIZtHjK6UawCW5EEjAIcuHZomfAIh+3iAkA0f/OhphKRRRZtgOknc7lnSyp/qG9mCJXMLm3EuWabFDDM0fmPZ4D21CXpLFpAxWAyjh1Fiw= 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 177124552516670.83383118162715; Mon, 16 Feb 2026 04:38:45 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 62D534180F; Mon, 16 Feb 2026 07:38:44 -0500 (EST) Received: from [172.19.199.9] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 1DCE541B5B; Mon, 16 Feb 2026 07:30:13 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id ACADE3F8AC; Mon, 16 Feb 2026 07:30:09 -0500 (EST) 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 BBABC3F383 for ; Mon, 16 Feb 2026 07:28:30 -0500 (EST) 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-668-bamcgI7KPDOJCVEV7O-5Aw-1; Mon, 16 Feb 2026 07:28:29 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6575A1800454 for ; Mon, 16 Feb 2026 12:28:28 +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 9E8E830001A5 for ; Mon, 16 Feb 2026 12:28:27 +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=1771244910; 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=89+udoC1CZpL9wVJdZ0N68pjijBevyxPwz+pFFDsBZw=; b=gxQgS0JwUhU8WLS7qe/j9t2DZIvj7TBSFxXHU2xOcBCza/rLpDtJlzb9APHsL9BgUb1gv6 AjHv8ByACvPrfpVii/cC9WirxqDYePE8S6o4gIlxyC5H3yN+QyZ7wWnrFO+Z0/ecBA5myY FK6DyDkj3Kho0R8NKzyfeEpNA0bevxM= X-MC-Unique: bamcgI7KPDOJCVEV7O-5Aw-1 X-Mimecast-MFC-AGG-ID: bamcgI7KPDOJCVEV7O-5Aw_1771244908 To: devel@lists.libvirt.org Subject: [libvirt PATCH 09/24] conf: Introduce virDomainDefHasPCIHostdevWithIOMMUFD Date: Mon, 16 Feb 2026 13:28:01 +0100 Message-ID: <23428b3832d1b946141a74ea3d6997efb1ea9ba7.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: 1leMv78nGeJSilmZTw7Fgnt8Q4PSoXRGqV7dje_kw3Q_1771244908 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: Q26THWN7RP4EPQNNJ3ZB5EG7VMSJNYCM X-Message-ID-Hash: Q26THWN7RP4EPQNNJ3ZB5EG7VMSJNYCM 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: 1771245526318154100 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Pavel Hrdina --- src/conf/domain_conf.c | 14 ++++++++++++++ src/conf/domain_conf.h | 3 +++ src/libvirt_private.syms | 1 + src/qemu/qemu_command.c | 42 ++++++++++++---------------------------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 98d34f408d..453e301041 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -32663,6 +32663,20 @@ virDomainDefHasPCIHostdev(const virDomainDef *def) } =20 =20 +bool +virDomainDefHasPCIHostdevWithIOMMUFD(const virDomainDef *def) +{ + size_t i; + + for (i =3D 0; i < def->nhostdevs; i++) { + if (virHostdevIsPCIDeviceWithIOMMUFD(def->hostdevs[i])) + return true; + } + + return false; +} + + bool virDomainDefHasMdevHostdev(const virDomainDef *def) { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index f98fed650a..a13f6d79e9 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -4662,6 +4662,9 @@ virDomainDefHasNVMeDisk(const virDomainDef *def); bool virDomainDefHasPCIHostdev(const virDomainDef *def); =20 +bool +virDomainDefHasPCIHostdevWithIOMMUFD(const virDomainDef *def); + bool virDomainDefHasMdevHostdev(const virDomainDef *def); =20 diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 15a56a262a..d8ae4f46cd 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -348,6 +348,7 @@ virDomainDefHasNVMeDisk; virDomainDefHasOldStyleROUEFI; virDomainDefHasOldStyleUEFI; virDomainDefHasPCIHostdev; +virDomainDefHasPCIHostdevWithIOMMUFD; virDomainDefHasTimer; virDomainDefHasUSB; virDomainDefHasVcpusOffline; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index c09c883a28..f400835332 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -5356,43 +5356,25 @@ qemuBuildIOMMUFDCommandLine(virCommand *cmd, const virDomainDef *def, virDomainObj *vm) { - size_t i; qemuDomainObjPrivate *priv =3D vm->privateData; g_autofree char *fdstr =3D g_strdup_printf("%d", priv->iommufd); + g_autoptr(virJSONValue) props =3D NULL; =20 + if (!virDomainDefHasPCIHostdevWithIOMMUFD(def)) + return 0; =20 - for (i =3D 0; i < def->nhostdevs; i++) { - virDomainHostdevDef *hostdev =3D def->hostdevs[i]; - virDomainHostdevSubsys *subsys =3D &hostdev->source.subsys; - g_autoptr(virJSONValue) props =3D NULL; + virCommandPassFD(cmd, priv->iommufd, VIR_COMMAND_PASS_FD_CLOSE_PARENT); =20 - if (hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) - continue; + priv->iommufd =3D -1; =20 - if (subsys->type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI) - continue; + if (qemuMonitorCreateObjectProps(&props, "iommufd", + "iommufd0", + "S:fd", fdstr, + NULL) < 0) + return -1; =20 - if (hostdev->info->type =3D=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_UNAS= SIGNED) - continue; - - if (subsys->u.pci.driver.iommufd !=3D VIR_TRISTATE_BOOL_YES) - continue; - - virCommandPassFD(cmd, priv->iommufd, VIR_COMMAND_PASS_FD_CLOSE_PAR= ENT); - - priv->iommufd =3D -1; - - if (qemuMonitorCreateObjectProps(&props, "iommufd", - "iommufd0", - "S:fd", fdstr, - NULL) < 0) - return -1; - - if (qemuBuildObjectCommandlineFromJSON(cmd, props) < 0) - return -1; - - break; - } + if (qemuBuildObjectCommandlineFromJSON(cmd, props) < 0) + return -1; =20 return 0; } --=20 2.53.0