
On 27/02/2019 10.15, Bjoern Walk wrote:
With further testing...
Thomas Huth <thuth@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@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.
Bummer. Stupid thinko. And I don't have a real PCI card for testing here, so I did not notice. So I guess I have to use opendir() + readdir() instead to find out if there are entries in this directory? Thomas