From nobody Sun May 5 16:39:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1551438649293170.95284331974904; Fri, 1 Mar 2019 03:10:49 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 739B93088A33; Fri, 1 Mar 2019 11:10:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2DC865D9C5; Fri, 1 Mar 2019 11:10:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5BB773FA48; Fri, 1 Mar 2019 11:10:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x21BAXCc018427 for ; Fri, 1 Mar 2019 06:10:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7C49F1001E64; Fri, 1 Mar 2019 11:10:33 +0000 (UTC) Received: from thuth.com (ovpn-116-112.ams2.redhat.com [10.36.116.112]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01C391001E60; Fri, 1 Mar 2019 11:10:29 +0000 (UTC) From: Thomas Huth To: libvir-list@redhat.com, Pino Toscano Date: Fri, 1 Mar 2019 12:10:26 +0100 Message-Id: <1551438626-12773-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Bjoern Walk , Boris Fiuczynski , Marc Hartmayer Subject: [libvirt] [PATCH v2] tools/virt-host-validate: Fix IOMMU check on s390x X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 01 Mar 2019 11:10:48 +0000 (UTC) Content-Type: text/plain; charset="utf-8" When running virt-host-validate on an s390x host, the tool currently warns that it is "Unknown if this platform has IOMMU support". We can use the common check for entries in /sys/kernel/iommu_groups here, too, but it only makes sense to check it if there are also PCI devices available. It's also common on s390x that there are no PCI devices assigned to the LPAR, and in that case there is no need for the PCI-related IOMMU, so without PCI devices we should simply skip this test. Signed-off-by: Thomas Huth Reviewed-by: Bjoern Walk Reviewed-by: Boris Fiuczynski --- v2: - Use virDirOpen() + virDirRead() instead of stat() - this should hopefully work now as expected. tools/virt-host-validate-common.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-c= ommon.c index 73e3bdb..e27b558 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -337,7 +337,12 @@ int virHostValidateIOMMU(const char *hvname, virBitmapPtr flags; struct stat sb; const char *bootarg =3D NULL; - bool isAMD =3D false, isIntel =3D false, isPPC =3D false; + bool isAMD =3D false, isIntel =3D false; + virArch arch =3D virArchFromHost(); + struct dirent *dent; + DIR *dir; + int rc; + flags =3D virHostValidateGetCPUFlags(); =20 if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_VMX)) @@ -347,8 +352,6 @@ int virHostValidateIOMMU(const char *hvname, =20 virBitmapFree(flags); =20 - isPPC =3D ARCH_IS_PPC64(virArchFromHost()); - if (isIntel) { virHostMsgCheck(hvname, "%s", _("for device assignment IOMMU suppo= rt")); if (access("/sys/firmware/acpi/tables/DMAR", F_OK) =3D=3D 0) { @@ -373,8 +376,17 @@ int virHostValidateIOMMU(const char *hvname, "hardware platform"); return -1; } - } else if (isPPC) { + } else if (ARCH_IS_PPC64(arch)) { /* Empty Block */ + } else if (ARCH_IS_S390(arch)) { + /* On s390x, we skip the IOMMU check if there are no PCI devices + * (which is quite usual on s390x) */ + if (!virDirOpen(&dir, "/sys/bus/pci/devices")) + return 0; + rc =3D virDirRead(dir, &dent, NULL); + VIR_DIR_CLOSE(dir); + if (rc <=3D 0) + return 0; } else { virHostMsgFail(level, "Unknown if this platform has IOMMU support"); @@ -391,7 +403,7 @@ int virHostValidateIOMMU(const char *hvname, =20 virHostMsgCheck(hvname, "%s", _("if IOMMU is enabled by kernel")); if (sb.st_nlink <=3D 2) { - if (!isPPC) + if (bootarg) virHostMsgFail(level, "IOMMU appears to be disabled in kernel. " "Add %s to kernel cmdline arguments", bootarg); --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list