]> xenbits.xensource.com Git - libvirt.git/commitdiff
virt-host-validate: warn if kvm_hv is not loaded for POWER hosts
authorDaniel Henrique Barboza <danielhb413@gmail.com>
Fri, 13 Mar 2020 17:48:03 +0000 (14:48 -0300)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 16 Mar 2020 09:38:21 +0000 (10:38 +0100)
POWER hosts does not implement CPU virtualization extensions like
x86 or s390x. Instead, all bare-metal POWER hosts are considered
to be virtualization ready.

For POWER, the validation is done by checking if the virtualization
module kvm_hv is loaded in the host. If not, we should warn the
user about it.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/virt-host-validate-common.c
tools/virt-host-validate-common.h
tools/virt-host-validate-qemu.c

index dc7523dd86378d1eb85ac2508a2d7a5e8316f202..fbefbada966a79b1d212c995173325c63e241b66 100644 (file)
@@ -412,3 +412,30 @@ int virHostValidateIOMMU(const char *hvname,
     virHostMsgPass();
     return 0;
 }
+
+
+bool virHostKernelModuleIsLoaded(const char *module)
+{
+    FILE *fp;
+    bool ret = false;
+
+    if (!(fp = fopen("/proc/modules", "r")))
+        return false;
+
+    do {
+        char line[1024];
+
+        if (!fgets(line, sizeof(line), fp))
+            break;
+
+        if (STRPREFIX(line, module)) {
+            ret = true;
+            break;
+        }
+
+    } while (1);
+
+    VIR_FORCE_FCLOSE(fp);
+
+    return ret;
+}
index a20470fa72c318f14b0eaa8d69211392045fdf96..8ae60a21de03a2762ad2fdc77bea85b195d3a7a6 100644 (file)
@@ -82,3 +82,5 @@ int virHostValidateCGroupControllers(const char *hvname,
 
 int virHostValidateIOMMU(const char *hvname,
                          virHostValidateLevel level);
+
+bool virHostKernelModuleIsLoaded(const char *module);
index ff3c1f02315b562fbc5a4a9a24c0d39840a03886..bd717a604edd2e0bbf84c335879101fb6130a88d 100644 (file)
@@ -57,6 +57,11 @@ int virHostValidateQEMU(void)
         if (virBitmapIsBitSet(flags, VIR_HOST_VALIDATE_CPU_FLAG_SIE))
             hasHwVirt = true;
         break;
+    case VIR_ARCH_PPC64:
+    case VIR_ARCH_PPC64LE:
+        hasVirtFlag = true;
+        hasHwVirt = true;
+        break;
     default:
         hasHwVirt = false;
     }
@@ -84,6 +89,16 @@ int virHostValidateQEMU(void)
             ret = -1;
     }
 
+    if (arch == VIR_ARCH_PPC64 || arch == VIR_ARCH_PPC64LE) {
+        virHostMsgCheck("QEMU", "%s", _("for PowerPC KVM module loaded"));
+
+        if (!virHostKernelModuleIsLoaded("kvm_hv"))
+            virHostMsgFail(VIR_HOST_VALIDATE_WARN,
+                          _("Load kvm_hv for better performance"));
+        else
+            virHostMsgPass();
+    }
+
     virBitmapFree(flags);
 
     if (virHostValidateDeviceExists("QEMU", "/dev/vhost-net",