summaryrefslogtreecommitdiffstats
path: root/core/modules/qemu/data/opt/openslx/scripts/systemd-qemu_env
blob: 3355b7a0969f166213084c61e0bd07d87976054d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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