From nobody Tue Mar 3 04:54:28 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=1771245145; cv=none; d=zohomail.com; s=zohoarc; b=kr5PqpwUjm+YzXHJFATy0yA2z/zkCfKnzgWc2x7Y/uEZEZj0lwpRq8FHkjRMQKN9FtJY8AOoGxb9PT1Cqd0U1pd6utDqgvlbPt5oWjaZ1wMtcgXvMRgpEXzirKGByeEx6GJTW1qKZP3yPuJsdWYHhIkNLpkoBrToMISXde+H8SU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1771245145; 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=LlKLw1ruAIFGZ35eePq4FnQy3Co/kmVB0vz9wMDBQ5k=; b=ndOhlZnNXkSdpgVsJtZPARQOxN6CkPPpocmFhEWtxcGRqDd9gOxWyS5aZmxo3+23iaxpWXPthfVrfBMJbaZfIZlv1vvP1EIzzILcTbqjDgmAfSp6gaJ+oy8dNkL4jWGZxdkYGiHlD/fJBSvj2RBt1AHaOnKCU1ZygrIy/jSJnP0= 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 1771245145055345.9971568393855; Mon, 16 Feb 2026 04:32:25 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 0B91D418CD; Mon, 16 Feb 2026 07:32:24 -0500 (EST) Received: from [172.19.199.9] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 6758741905; Mon, 16 Feb 2026 07:28:34 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id BA5843F343; Mon, 16 Feb 2026 07:28:23 -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 3E65A3F311 for ; Mon, 16 Feb 2026 07:28:23 -0500 (EST) 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-594-lOqGRWBjMr6mRvYAyepo2A-1; Mon, 16 Feb 2026 07:28:21 -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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9C1431956067 for ; Mon, 16 Feb 2026 12:28:20 +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 EEB8430001A5 for ; Mon, 16 Feb 2026 12:28:19 +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=1771244902; 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=LlKLw1ruAIFGZ35eePq4FnQy3Co/kmVB0vz9wMDBQ5k=; b=gfoZ8OnfkqWkp1KuHmWuCU7FHYXVzYfGsPzUtY8ScG7gWOxzQswC29u1Ip8kbh0ZuIEDRa w+7T6f468A7BnwYGov8oLePas5JYe3Ggr3nBNW06lwlL3pwYpDMS+dAg/KLJwTyUfq1WlL WGaA2Pk/EiXSIPv45Fapta2uJhwLXsU= X-MC-Unique: lOqGRWBjMr6mRvYAyepo2A-1 X-Mimecast-MFC-AGG-ID: lOqGRWBjMr6mRvYAyepo2A_1771244900 To: devel@lists.libvirt.org Subject: [libvirt PATCH 02/24] qemu: Move IOMMUFD validation to qemu_validate Date: Mon, 16 Feb 2026 13:27:54 +0100 Message-ID: <470b6616ebdd99bfc9e1bbb1d1951ab029b44352.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: _KFXkmxDNl5lWDIjkTNm5D7kYW9Yo0wWcqX9ak8GMJA_1771244900 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: I5GZRVMSCFBQI4ZSHCU2ZMJ5E4AFLYUU X-Message-ID-Hash: I5GZRVMSCFBQI4ZSHCU2ZMJ5E4AFLYUU 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: 1771245146042158500 Content-Type: text/plain; charset="utf-8"; x-default="true" Fail early if kernel doesn't support IOMMUFD. Signed-off-by: Pavel Hrdina --- src/libvirt_private.syms | 1 + src/qemu/qemu_process.c | 8 +------- src/qemu/qemu_validate.c | 7 +++++++ src/util/viriommufd.c | 13 +++++++++++++ src/util/viriommufd.h | 2 ++ 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 8554191503..2f9fdc04ad 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2649,6 +2649,7 @@ virInitctlSetRunLevel; =20 # util/viriommufd.h virIOMMUFDSetRLimitMode; +virIOMMUFDSupported; =20 # util/viriscsi.h virISCSIConnectionLogin; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index c3f681f1dd..fd400ae8a6 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7694,13 +7694,7 @@ qemuProcessOpenIommuFd(virDomainObj *vm) 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) { - if (errno =3D=3D ENOENT) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("IOMMU FD support requires /dev/iommu device"= )); - } else { - virReportSystemError(errno, "%s", - _("cannot open /dev/iommu")); - } + virReportSystemError(errno, "%s", _("cannot open /dev/iommu")); return -1; } =20 diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 18700b5a9b..16dd5fef1a 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -27,6 +27,7 @@ #include "qemu_process.h" #include "domain_conf.h" #include "virbitmap.h" +#include "viriommufd.h" #include "virlog.h" #include "virutil.h" =20 @@ -2729,6 +2730,12 @@ qemuValidateDomainDeviceDefHostdev(const virDomainHo= stdevDef *hostdev, _("IOMMUFD is not supported by this= version of qemu")); return -1; } + + if (!virIOMMUFDSupported()) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("IOMMUFD is not supported by host= kernel")); + return -1; + } } } =20 diff --git a/src/util/viriommufd.c b/src/util/viriommufd.c index 5af097683d..44b30029a5 100644 --- a/src/util/viriommufd.c +++ b/src/util/viriommufd.c @@ -88,3 +88,16 @@ int virIOMMUFDSetRLimitMode(int fd G_GNUC_UNUSED, } =20 #endif + +/** + * virIOMMUFDSupported: + * + * Check the presence of IOMMU device. + * + * Retruns: true if it exists, false otherwise + */ +bool +virIOMMUFDSupported(void) +{ + return virFileExists(VIR_IOMMU_DEV_PATH); +} diff --git a/src/util/viriommufd.h b/src/util/viriommufd.h index ebecfe3633..ec6be9fa66 100644 --- a/src/util/viriommufd.h +++ b/src/util/viriommufd.h @@ -23,3 +23,5 @@ #define VIR_IOMMU_DEV_PATH "/dev/iommu" =20 int virIOMMUFDSetRLimitMode(int fd, bool processAccounting); + +bool virIOMMUFDSupported(void); --=20 2.53.0