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(a)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)
+ 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