summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Bentele2021-02-08 09:17:46 +0100
committerManuel Bentele2021-02-08 09:17:46 +0100
commitc5788c0b4073bc510b3084dbbff2cea73b2f55cf (patch)
tree3a67ce20c6d6dfd703637c5cdfd1aa033572f601
parent[qemu] Add support to build the qemu runvirt plugin (diff)
downloadmltk-c5788c0b4073bc510b3084dbbff2cea73b2f55cf.tar.gz
mltk-c5788c0b4073bc510b3084dbbff2cea73b2f55cf.tar.xz
mltk-c5788c0b4073bc510b3084dbbff2cea73b2f55cf.zip
[qemu] Replace lazy load of KVM kernel modules
-rwxr-xr-xcore/modules/qemu/data/opt/openslx/scripts/systemd-qemu_env29
1 files changed, 24 insertions, 5 deletions
diff --git a/core/modules/qemu/data/opt/openslx/scripts/systemd-qemu_env b/core/modules/qemu/data/opt/openslx/scripts/systemd-qemu_env
index c8343cd5..3355b7a0 100755
--- a/core/modules/qemu/data/opt/openslx/scripts/systemd-qemu_env
+++ b/core/modules/qemu/data/opt/openslx/scripts/systemd-qemu_env
@@ -16,12 +16,31 @@
# - This is the preparation script for the configuration of QEMU on Linux.
################################################################################
-# lazy load all kvm related modules
-modprobe kvm
-modprobe kvm_amd
-modprobe kvm_intel
+#
+# load general KVM module
+#
+modprobe "kvm" || slxlog "qemu" "Could not load 'kvm' kernel modul!"
+
+#
+# load CPU specific KVM implementation
+#
+virt=$(egrep -m1 -w '^flags[[:blank:]]*:' /proc/cpuinfo | egrep -wo '(vmx|svm)') || true
+if [ "${virt}" = "vmx" ]; then
+ kmod="kvm_intel"
+elif [ "${virt}" = "svm" ]; then
+ kmod="kvm_amd"
+else
+ slxlog "qemu" "CPU does not support KVM extensions!"
+ exit 1
+fi
+
+modprobe "${kmod}" || slxlog "qemu" "Could not load '${kmod}' kernel modul!"
+
+#
+# check that the KVM exposed device exists
+#
if [ ! -e /dev/kvm ]; then
- slxlog "qemu-modules" "/dev/kvm not found! Missing kvm kernel module(s)?"
+ slxlog "qemu" "/dev/kvm not found! Missing kvm kernel module(s)?"
exit 1
fi