From nobody Tue Mar 24 01:17:08 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=1773938788; cv=none; d=zohomail.com; s=zohoarc; b=JIh4xZnYn+n6W18kEJqcTbF3kqCO/IrV3d4/ugOGnJlI07eKdUetjbDG3ij+D5/Dm8WWRja7i2StkSVhOx69iDDL2WmxEDpaOMbXlQRlzpZEyNSaltNKuBHHV8zJWGm0uDqnXWfKFmzpLuOGNaFNthkpQokkpqArYhZHCyfOXfE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773938788; 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=AaANdqwsP8tWZutdwAsKavsQcyzhk/adE9ED6e0X2Eg=; b=OJqsqckH59eQf2wvYBo1U8QcPdrTVAAOuuN7e/Pof3ZKi6w6n3eeKY6mZGCbgnp3JGaGDUjLoPusNPXa/s0XdexLjyYzLdhd8iM2Hj3BgqCaVunR+TnhlvEVy/BKSChgbi0+VrAedduCB0lD+Z2RZAxUu/yZW9YNwZqZFOGZD64= 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 1773938788247115.55707132802604; Thu, 19 Mar 2026 09:46:28 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id BB71241819; Thu, 19 Mar 2026 12:46:27 -0400 (EDT) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 6A2A841D73; Thu, 19 Mar 2026 12:40:48 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 2121D41822; Thu, 19 Mar 2026 12:40:43 -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 02C06418C1 for ; Thu, 19 Mar 2026 12:37:14 -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-41-0PgPuYgyP86Y84JknUW4bw-1; Thu, 19 Mar 2026 12:37:12 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A2DDE18005BB for ; Thu, 19 Mar 2026 16:37:11 +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 F075D30002E2 for ; Thu, 19 Mar 2026 16:37: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=-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=1773938234; 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=AaANdqwsP8tWZutdwAsKavsQcyzhk/adE9ED6e0X2Eg=; b=RbT2DTthLIPC0nK+E849XSU1Qm16w9jAaz8oBvKQNaaRRlBubcg8WhfbuA8HfPSg5m/gkE k3mGz3vGmZF/OG/DlamO2QfT6uC12E7mlEf0WnNkQU6rhOFK5Jnsc+T8NYZABy6c24VgLq 3E60z4pEkGGREY39WHeaKNVSKuUCKa8= X-MC-Unique: 0PgPuYgyP86Y84JknUW4bw-1 X-Mimecast-MFC-AGG-ID: 0PgPuYgyP86Y84JknUW4bw_1773938231 To: devel@lists.libvirt.org Subject: [libvirt PATCH 11/11] tests: Add iommufd fdgroup test Date: Thu, 19 Mar 2026 17:36:57 +0100 Message-ID: <22eb53973dd9fff0234362d64a6afe82f53cbc50.1773938045.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: Jes39lG4hRQLhGwMoBdnZ-djFoyiZ-1MMfg6WieRojk_1773938231 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: LMTMUEOBYEVW4TOHPHXRHKYFWA4HJOQL X-Message-ID-Hash: LMTMUEOBYEVW4TOHPHXRHKYFWA4HJOQL 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: 1773938790910154100 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Pavel Hrdina Signed-off-by: Pavel Hrdina Reviewed-by: Peter Krempa --- src/qemu/qemu_process.c | 12 ++-- src/qemu/qemu_processpriv.h | 2 + .../iommufd-q35-fd.x86_64-latest.args | 41 +++++++++++++ .../iommufd-q35-fd.x86_64-latest.xml | 60 +++++++++++++++++++ tests/qemuxmlconfdata/iommufd-q35-fd.xml | 38 ++++++++++++ tests/qemuxmlconftest.c | 9 ++- 6 files changed, 157 insertions(+), 5 deletions(-) create mode 100644 tests/qemuxmlconfdata/iommufd-q35-fd.x86_64-latest.args create mode 100644 tests/qemuxmlconfdata/iommufd-q35-fd.x86_64-latest.xml create mode 100644 tests/qemuxmlconfdata/iommufd-q35-fd.xml diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index c78fb4273c..14bc88b5cc 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7751,7 +7751,7 @@ qemuProcessOpenIommuFd(virDomainObj *vm) * * Returns: 0 on success, -1 on failure */ -static int +int qemuProcessPrepareIommuFd(virDomainObj *vm) { qemuDomainObjPrivate *priv =3D vm->privateData; @@ -7771,10 +7771,14 @@ qemuProcessPrepareIommuFd(virDomainObj *vm) return -1; } =20 - iommufd =3D dup(fdt->fds[0]); + if (fdt->testfds) { + iommufd =3D dup2(fdt->fds[0], fdt->testfds[0]); + } else { + iommufd =3D dup(fdt->fds[0]); =20 - if (qemuSecuritySetImageFDLabel(priv->driver->securityManager, vm->def= , iommufd) < 0) - return -1; + if (qemuSecuritySetImageFDLabel(priv->driver->securityManager, vm-= >def, iommufd) < 0) + return -1; + } =20 priv->iommufd =3D qemuFDPassDirectNew("iommufd", &iommufd); =20 diff --git a/src/qemu/qemu_processpriv.h b/src/qemu/qemu_processpriv.h index 0ba5897f40..39cb7dd0dc 100644 --- a/src/qemu/qemu_processpriv.h +++ b/src/qemu/qemu_processpriv.h @@ -37,3 +37,5 @@ void qemuProcessHandleDeviceDeleted(qemuMonitor *mon, const char *devAlias); =20 int qemuProcessQMPInitMonitor(qemuMonitor *mon); + +int qemuProcessPrepareIommuFd(virDomainObj *vm); diff --git a/tests/qemuxmlconfdata/iommufd-q35-fd.x86_64-latest.args b/test= s/qemuxmlconfdata/iommufd-q35-fd.x86_64-latest.args new file mode 100644 index 0000000000..7df3d173f3 --- /dev/null +++ b/tests/qemuxmlconfdata/iommufd-q35-fd.x86_64-latest.args @@ -0,0 +1,41 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/var/lib/libvirt/qemu/domain--1-q35-test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/var/lib/libvirt/qemu/domain--1-q35-test/.local/share \ +XDG_CACHE_HOME=3D/var/lib/libvirt/qemu/domain--1-q35-test/.cache \ +XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-q35-test/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Dq35-test,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/va= r/lib/libvirt/qemu/domain--1-q35-test/master-key.aes"}' \ +-machine q35,usb=3Doff,dump-guest-core=3Doff,memory-backend=3Dpc.ram,acpi= =3Doff \ +-accel tcg \ +-cpu qemu64 \ +-m size=3D2097152k \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":2147483648}= ' \ +-overcommit mem-lock=3Doff \ +-smp 2,sockets=3D2,cores=3D1,threads=3D1 \ +-uuid 11dbdcdd-4c3b-482b-8903-9bdb8c0a2774 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot strict=3Don \ +-device '{"driver":"pcie-root-port","port":16,"chassis":1,"id":"pci.1","bu= s":"pcie.0","multifunction":true,"addr":"0x2"}' \ +-device '{"driver":"pcie-root-port","port":17,"chassis":2,"id":"pci.2","bu= s":"pcie.0","addr":"0x2.0x1"}' \ +-device '{"driver":"qemu-xhci","id":"usb","bus":"pci.1","addr":"0x0"}' \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","no= de-name":"libvirt-1-storage","read-only":false}' \ +-device '{"driver":"ide-hd","bus":"ide.0","drive":"libvirt-1-storage","id"= :"sata0-0-0","bootindex":1}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"qxl-vga","id":"video0","max_outputs":1,"ram_size":6710= 8864,"vram_size":33554432,"vram64_size_mb":0,"vgamem_mb":8,"bus":"pcie.0","= addr":"0x1"}' \ +-global ICH9-LPC.noreboot=3Doff \ +-watchdog-action reset \ +-object '{"qom-type":"iommufd","id":"iommufd0","fd":"20"}' \ +-device '{"driver":"vfio-pci","id":"hostdev0","iommufd":"iommufd0","fd":"0= ","bus":"pcie.0","addr":"0x3"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxmlconfdata/iommufd-q35-fd.x86_64-latest.xml b/tests= /qemuxmlconfdata/iommufd-q35-fd.x86_64-latest.xml new file mode 100644 index 0000000000..a6be49cbb3 --- /dev/null +++ b/tests/qemuxmlconfdata/iommufd-q35-fd.x86_64-latest.xml @@ -0,0 +1,60 @@ + + q35-test + 11dbdcdd-4c3b-482b-8903-9bdb8c0a2774 + 2097152 + 2097152 + 2 + + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + +
+ + + + + +
+ + + + +
+ + +
+ + +
+ + + +