summaryrefslogtreecommitdiffstats
path: root/core/modules/qemu/data/opt/openslx/scripts/systemd-qemu_env
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/qemu/data/opt/openslx/scripts/systemd-qemu_env')
-rwxr-xr-xcore/modules/qemu/data/opt/openslx/scripts/systemd-qemu_env46
1 files changed, 46 insertions, 0 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
new file mode 100755
index 00000000..3355b7a0
--- /dev/null
+++ b/core/modules/qemu/data/opt/openslx/scripts/systemd-qemu_env
@@ -0,0 +1,46 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+#
+# Copyright (c) 2017..2021 bwLehrpool-Projektteam
+#
+# This program/file is free software distributed under the GPL version 2.
+# See https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
+#
+# If you have any feedback please consult https://bwlehrpool.de and
+# send your feedback to bwlehrpool@hs-offenburg.de.
+#
+# General information about bwLehrpool can be found at https://bwlehrpool.de
+#
+# -----------------------------------------------------------------------------
+# systemd-qemu_env
+# - This is the preparation script for the configuration of QEMU on Linux.
+################################################################################
+
+#
+# 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" "/dev/kvm not found! Missing kvm kernel module(s)?"
+ exit 1
+fi