From c5788c0b4073bc510b3084dbbff2cea73b2f55cf Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Mon, 8 Feb 2021 09:17:46 +0100 Subject: [qemu] Replace lazy load of KVM kernel modules --- .../qemu/data/opt/openslx/scripts/systemd-qemu_env | 29 ++++++++++++++++++---- 1 file 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 -- cgit v1.2.3-55-g7522