From nobody Tue Mar 3 04:54:34 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=1771245201; cv=none; d=zohomail.com; s=zohoarc; b=EZIOQFRJUJQ5zOdGXApeoM7adIturBUtRuCGBHj+Aex78o8ALiyYQfDgQjLjOoJ8I6Jl+V7L716gLvrwZ0BuWVT7Q0Q0VR3u0idt2k+Zcj+vtL6fIeWrN7oMqAC0DUZdTJERkHWDcya/NskWzg7QwDMjpK/skl6hlW8gYSgCYrc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771245201; 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=pIARDYrLEGX3FOrPISGfxHBymK07yf9fgsyRXdINK0k=; b=CDcaTo+rUC/sVhii2iNHCqoWJhTHxycVYyPpkLR9VhyrvZ5wZtE7uCSpgkdLZ8u9zm31moTN7kyQGWuCfMFTediLR9NsNsh8E96SBG8Wgy5VyvWAOLHO1MfyAb2yMhbuE3acP7NKP/yBLh07uZ/CP4+PCyGfcEDUs1wqO2BLXv4= 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 1771245201118635.8950742001058; Mon, 16 Feb 2026 04:33:21 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 6A82241816; Mon, 16 Feb 2026 07:33:20 -0500 (EST) Received: from [172.19.199.9] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id D1A293F950; Mon, 16 Feb 2026 07:28:36 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id C36063F311; Mon, 16 Feb 2026 07:28:24 -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 402DD3F311 for ; Mon, 16 Feb 2026 07:28:24 -0500 (EST) Received: from mx-prod-mc-03.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-635-9cBM0UIFMJqERVnyrlIC0g-1; Mon, 16 Feb 2026 07:28:22 -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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B6C9919560B2 for ; Mon, 16 Feb 2026 12:28:21 +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 13E2830001A5 for ; Mon, 16 Feb 2026 12:28:20 +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=1771244903; 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=pIARDYrLEGX3FOrPISGfxHBymK07yf9fgsyRXdINK0k=; b=XRGPyUhSTr1j+NXBNRTKGQ9wNeGCBT+gAwB/ivll8uwTo7rL7yVko3mwJqy5GpnZhXoskY 0ntyjg4wSpYfqVrvn+3l35l5Oc+WTxZTGCQN/BTw1XUngcfPQ1whb25Eou4Ua5/0mR00If yrW7ViiQQQySc+wf69mEz2PEe+/1rzM= X-MC-Unique: 9cBM0UIFMJqERVnyrlIC0g-1 X-Mimecast-MFC-AGG-ID: 9cBM0UIFMJqERVnyrlIC0g_1771244901 To: devel@lists.libvirt.org Subject: [libvirt PATCH 03/24] util: Move openning IOMMU device to viriommufd Date: Mon, 16 Feb 2026 13:27:55 +0100 Message-ID: <877425a6556da7a793b666ec79b9e0b187acdbd8.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: KkbQddfCiSD2C2A0vOv1UHz4BBa16GqVJJ_882-qRoM_1771244901 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: TYHEJLAF5H62AMNF4NPFTNQLMTXRLRUX X-Message-ID-Hash: TYHEJLAF5H62AMNF4NPFTNQLMTXRLRUX 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: 1771245203490154100 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Pavel Hrdina --- src/libvirt_private.syms | 2 +- src/qemu/qemu_process.c | 9 +-------- src/util/viriommufd.c | 22 +++++++++++++++++++--- src/util/viriommufd.h | 2 +- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 2f9fdc04ad..576b1f6595 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2648,7 +2648,7 @@ virInitctlFifos; virInitctlSetRunLevel; =20 # util/viriommufd.h -virIOMMUFDSetRLimitMode; +virIOMMUFDOpenDevice; virIOMMUFDSupported; =20 # util/viriscsi.h diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index fd400ae8a6..9b459f47ca 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7693,15 +7693,8 @@ qemuProcessOpenIommuFd(virDomainObj *vm) =20 VIR_DEBUG("Opening IOMMU FD for domain %s", vm->def->name); =20 - if ((fd =3D open(VIR_IOMMU_DEV_PATH, O_RDWR | O_CLOEXEC)) < 0) { - virReportSystemError(errno, "%s", _("cannot open /dev/iommu")); + if ((fd =3D virIOMMUFDOpenDevice()) < 0) return -1; - } - - if (virIOMMUFDSetRLimitMode(fd, true) < 0) { - VIR_FORCE_CLOSE(fd); - return -1; - } =20 VIR_DEBUG("Opened IOMMU FD %d for domain %s", fd, vm->def->name); return fd; diff --git a/src/util/viriommufd.c b/src/util/viriommufd.c index 44b30029a5..1f3353eab4 100644 --- a/src/util/viriommufd.c +++ b/src/util/viriommufd.c @@ -1,5 +1,7 @@ #include =20 +#include + #include "viriommufd.h" #include "virlog.h" #include "virerror.h" @@ -54,7 +56,7 @@ struct iommu_option { * * Returns: 0 on success, -1 on error */ -int +static int virIOMMUFDSetRLimitMode(int fd, bool processAccounting) { struct iommu_option option =3D { @@ -77,10 +79,24 @@ virIOMMUFDSetRLimitMode(int fd, bool processAccounting) return 0; } =20 +int +virIOMMUFDOpenDevice(void) +{ + int fd =3D -1; + + if ((fd =3D open(VIR_IOMMU_DEV_PATH, O_RDWR | O_CLOEXEC)) < 0) + virReportSystemError(errno, "%s", _("cannot open IOMMUFD device")); + + if (virIOMMUFDSetRLimitMode(fd, true) < 0) + return -1; + + return fd; +} + #else =20 -int virIOMMUFDSetRLimitMode(int fd G_GNUC_UNUSED, - bool processAccounting G_GNUC_UNUSED) +int +virIOMMUFDOpenDevice(void) { virReportError(VIR_ERR_NO_SUPPORT, "%s", _("IOMMUFD is not supported on this platform")); diff --git a/src/util/viriommufd.h b/src/util/viriommufd.h index ec6be9fa66..223f44eb5c 100644 --- a/src/util/viriommufd.h +++ b/src/util/viriommufd.h @@ -22,6 +22,6 @@ =20 #define VIR_IOMMU_DEV_PATH "/dev/iommu" =20 -int virIOMMUFDSetRLimitMode(int fd, bool processAccounting); +int virIOMMUFDOpenDevice(void); =20 bool virIOMMUFDSupported(void); --=20 2.53.0