[libvirt] [PATCH] tools/virt-host-validate: Fix IOMMU check on s390x
Bjoern Walk
bwalk at linux.ibm.com
Wed Feb 27 09:15:28 UTC 2019
With further testing...
Thomas Huth <thuth at redhat.com> [2019-02-26, 12:02PM +0100]:
> 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 <thuth at redhat.com>
> ---
> 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-common.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 = NULL;
> - bool isAMD = false, isIntel = false, isPPC = false;
> + bool isAMD = false, isIntel = false, isPPC, isS390;
> flags = virHostValidateGetCPUFlags();
>
> if (flags && virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_VMX))
> @@ -348,6 +348,7 @@ int virHostValidateIOMMU(const char *hvname,
> virBitmapFree(flags);
>
> isPPC = ARCH_IS_PPC64(virArchFromHost());
> + isS390 = ARCH_IS_S390(virArchFromHost());
>
> if (isIntel) {
> virHostMsgCheck(hvname, "%s", _("for device assignment IOMMU support"));
> @@ -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 <= 2)
... this doesn't seem to work, no? The files in /sys/bus/pci/devices are
actually soft-links and are not counted by stat, am I wrong? At least on
my setup with a PCI device and populated sysfs it will still skip the
check.
> + return 0;
> } else {
> virHostMsgFail(level,
> "Unknown if this platform has IOMMU support");
> @@ -391,7 +398,7 @@ int virHostValidateIOMMU(const char *hvname,
>
> virHostMsgCheck(hvname, "%s", _("if IOMMU is enabled by kernel"));
> if (sb.st_nlink <= 2) {
> - if (!isPPC)
> + if (bootarg)
> virHostMsgFail(level,
> "IOMMU appears to be disabled in kernel. "
> "Add %s to kernel cmdline arguments", bootarg);
> --
> 1.8.3.1
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
>
--
IBM Systems
Linux on Z & Virtualization Development
--------------------------------------------------
IBM Deutschland Research & Development GmbH
Schönaicher Str. 220, 71032 Böblingen
Phone: +49 7031 16 1819
--------------------------------------------------
Vorsitzende des Aufsichtsrats: Matthias Hartmann
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 902 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190227/64749673/attachment-0001.sig>
More information about the libvir-list
mailing list