diff options
author | Manuel Bentele | 2021-02-08 09:17:46 +0100 |
---|---|---|
committer | Manuel Bentele | 2021-02-08 09:17:46 +0100 |
commit | c5788c0b4073bc510b3084dbbff2cea73b2f55cf (patch) | |
tree | 3a67ce20c6d6dfd703637c5cdfd1aa033572f601 /core/modules/qemu/data/opt/openslx/scripts/systemd-qemu_env | |
parent | [qemu] Add support to build the qemu runvirt plugin (diff) | |
download | mltk-c5788c0b4073bc510b3084dbbff2cea73b2f55cf.tar.gz mltk-c5788c0b4073bc510b3084dbbff2cea73b2f55cf.tar.xz mltk-c5788c0b4073bc510b3084dbbff2cea73b2f55cf.zip |
[qemu] Replace lazy load of KVM kernel modules
Diffstat (limited to 'core/modules/qemu/data/opt/openslx/scripts/systemd-qemu_env')
-rwxr-xr-x | core/modules/qemu/data/opt/openslx/scripts/systemd-qemu_env | 29 |
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 |