From nobody Sun May 5 16:43:31 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 1551178953097976.6594342683445; Tue, 26 Feb 2019 03:02:33 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5029F811DE; Tue, 26 Feb 2019 11:02:31 +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 20F8D60C1A; Tue, 26 Feb 2019 11:02:31 +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 D4F433FB11; Tue, 26 Feb 2019 11:02:30 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1QB2Twq030550 for ; Tue, 26 Feb 2019 06:02:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2405B5D9D1; Tue, 26 Feb 2019 11:02:29 +0000 (UTC) Received: from thuth.com (ovpn-116-138.ams2.redhat.com [10.36.116.138]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B1875D9CC; Tue, 26 Feb 2019 11:02:25 +0000 (UTC) From: Thomas Huth To: libvir-list@redhat.com, Pino Toscano Date: Tue, 26 Feb 2019 12:02:20 +0100 Message-Id: <1551178940-28328-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: Stefan Zimmermann , Farhan Ali , Boris Fiuczynski , Marc Hartmayer , Bjoern Walk , Viktor Mihajlovski Subject: [libvirt] [PATCH] 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 26 Feb 2019 11:02:31 +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 --- tools/virt-host-validate-common.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-c= ommon.c index 73e3bdb..75c7cfc 100644 --- a/tools/virt-host-validate-common.c +++ b/tools/virt-host-validate-common.c @@ -337,7 +337,7 @@ 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, isPPC, isS390; flags =3D virHostValidateGetCPUFlags(); =20 if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_VMX)) @@ -348,6 +348,7 @@ int virHostValidateIOMMU(const char *hvname, virBitmapFree(flags); =20 isPPC =3D ARCH_IS_PPC64(virArchFromHost()); + isS390 =3D ARCH_IS_S390(virArchFromHost()); =20 if (isIntel) { virHostMsgCheck(hvname, "%s", _("for device assignment IOMMU suppo= rt")); @@ -375,6 +376,12 @@ int virHostValidateIOMMU(const char *hvname, } } else if (isPPC) { /* Empty Block */ + } else if (isS390) { + /* On s390x, we skip the IOMMU check if there are no PCI devices + * (which is quite usual on s390x) */ + if (stat("/sys/bus/pci/devices", &sb) < 0 || !S_ISDIR(sb.st_mode) = || + sb.st_nlink <=3D 2) + return 0; } else { virHostMsgFail(level, "Unknown if this platform has IOMMU support"); @@ -391,7 +398,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