summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorManuel Bentele2021-09-30 14:01:50 +0200
committerManuel Bentele2021-10-12 13:12:55 +0200
commit89fa7e5a9c9b24dcaafa2a3affde56f26945030e (patch)
tree404d9b5ead2145fb3d1986ce43588d8bd8a47a65 /core
parent[libvirt-src] Add module for libvirt source build (diff)
downloadmltk-89fa7e5a9c9b24dcaafa2a3affde56f26945030e.tar.gz
mltk-89fa7e5a9c9b24dcaafa2a3affde56f26945030e.tar.xz
mltk-89fa7e5a9c9b24dcaafa2a3affde56f26945030e.zip
[qemu-src] Add module for QEMU source build
Diffstat (limited to 'core')
l---------core/modules/qemu-src/data/lib/systemd/system/multi-user.target.wants/qemu-kvm.service1
-rw-r--r--core/modules/qemu-src/data/lib/systemd/system/qemu-kvm.service16
-rw-r--r--core/modules/qemu-src/data/usr/share/qemu/init/qemu-kvm-init89
-rw-r--r--core/modules/qemu-src/module.build61
-rw-r--r--core/modules/qemu-src/module.conf8
-rw-r--r--core/modules/qemu-src/module.conf.ubuntu50
-rw-r--r--core/modules/qemu/data/etc/systemd/system/qemu.service3
-rw-r--r--core/modules/qemu/module.build3
-rw-r--r--core/modules/qemu/module.conf1
-rw-r--r--core/modules/qemu/module.conf.ubuntu8
l---------core/targets/qemu/qemu-src1
11 files changed, 230 insertions, 11 deletions
diff --git a/core/modules/qemu-src/data/lib/systemd/system/multi-user.target.wants/qemu-kvm.service b/core/modules/qemu-src/data/lib/systemd/system/multi-user.target.wants/qemu-kvm.service
new file mode 120000
index 00000000..cd3c10f2
--- /dev/null
+++ b/core/modules/qemu-src/data/lib/systemd/system/multi-user.target.wants/qemu-kvm.service
@@ -0,0 +1 @@
+../qemu-kvm.service \ No newline at end of file
diff --git a/core/modules/qemu-src/data/lib/systemd/system/qemu-kvm.service b/core/modules/qemu-src/data/lib/systemd/system/qemu-kvm.service
new file mode 100644
index 00000000..f35e3e98
--- /dev/null
+++ b/core/modules/qemu-src/data/lib/systemd/system/qemu-kvm.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=QEMU KVM preparation - module, ksm, hugepages
+DefaultDependencies=no
+After=local-fs.target
+Before=shutdown.target
+Conflicts=shutdown.target
+RequiresMountsFor=/usr
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/usr/share/qemu/init/qemu-kvm-init start
+ExecReload=/usr/share/qemu/init/qemu-kvm-init start
+
+[Install]
+WantedBy=multi-user.target
diff --git a/core/modules/qemu-src/data/usr/share/qemu/init/qemu-kvm-init b/core/modules/qemu-src/data/usr/share/qemu/init/qemu-kvm-init
new file mode 100644
index 00000000..af00b718
--- /dev/null
+++ b/core/modules/qemu-src/data/usr/share/qemu/init/qemu-kvm-init
@@ -0,0 +1,89 @@
+#!/bin/sh
+
+# Detect our host arch
+arch=$(arch)
+test -z "$arch" && exit 0
+
+modlist=""
+case "$arch" in
+ x86_64 | i686)
+ kvm=/usr/bin/qemu-system-x86_64
+ if grep -qs "^flags.* vmx" /proc/cpuinfo; then
+ modlist="kvm_intel $KVM_NESTED"
+ elif grep -qs "^flags.* svm" /proc/cpuinfo; then
+ modlist="kvm_amd"
+ fi
+ ;;
+ ppc*)
+ SMT=$(/usr/sbin/ppc64_cpu --smt 2>&1 | grep "SMT=[248]")
+ if [ -n "$SMT" ]
+ then
+ if grep -q -e '^cpu\s*:\s*POWER8' /proc/cpuinfo; then
+ echo "Error: You must disable SMT if you want to run QEMU/KVM on Power8 based ppc64le architecture"
+ echo "In order to disable SMT, run: # ppc64_cpu --smt=off"
+ fi
+ fi
+ kvm=/usr/bin/qemu-system-ppc64
+ if [ "$(uname -m)" != "ppc64le" ]; then
+ exit 0
+ fi
+ if systemd-detect-virt --quiet --vm; then
+ echo "Info: second level virtualization not supported, kvm-hv load might fail"
+ fi
+ modlist="kvm-hv"
+ ;;
+esac
+
+# Silently exit if the package isn't installed anymore
+if [ -z "$kvm" -o ! -e "$kvm" ]; then
+ exit 0
+fi
+
+# shellcheck disable=SC1091
+[ -r /etc/default/qemu-kvm ] && . /etc/default/qemu-kvm
+
+start() {
+ if [ -n "$modlist" ]; then
+ modprobe -b $modlist || true
+ fi
+
+ if systemd-detect-virt --quiet --container; then
+ mknod /dev/kvm c 10 232 || true
+ chown root:kvm /dev/kvm || true
+ chmod g+rw /dev/kvm || true
+ fi
+
+ # Determine if we are running inside a VM
+ IS_VM=0
+ if command -v systemd-detect-virt >/dev/null 2>&1; then
+ systemd-detect-virt -vq && IS_VM=1
+ fi
+
+ # Enable KSM, respecting the default configuration file. If 'AUTO' is
+ # set, enable only if we aren't running inside a VM.
+ if [ "$KSM_ENABLED" = "1" ] || [ "$KSM_ENABLED" = "AUTO" ] && [ "$IS_VM" = "0" ]; then
+ # shellcheck disable=SC2015
+ [ -w /sys/kernel/mm/ksm/run ] && echo 1 > /sys/kernel/mm/ksm/run || true
+ if [ -w /sys/kernel/mm/ksm/sleep_millisecs ]; then
+ if [ -n "$SLEEP_MILLISECS" ]; then
+ echo "$SLEEP_MILLISECS" > /sys/kernel/mm/ksm/sleep_millisecs || true
+ fi
+ fi
+ else
+ # shellcheck disable=SC2015
+ [ -w /sys/kernel/mm/ksm/run ] && echo 0 > /sys/kernel/mm/ksm/run || true
+ fi
+}
+
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+
+ *)
+ exit 0
+ ;;
+esac
+
+exit $?
diff --git a/core/modules/qemu-src/module.build b/core/modules/qemu-src/module.build
new file mode 100644
index 00000000..5f3fce34
--- /dev/null
+++ b/core/modules/qemu-src/module.build
@@ -0,0 +1,61 @@
+#!/bin/bash
+fetch_source() {
+ autoclone
+ git -C "${MODULE_WORK_DIR}/src/qemu" submodule update --init || perror "Failed to init and update submodules!"
+
+ # patch EDK2 version to retrieve EDK2 submodules
+ git -C "${MODULE_WORK_DIR}/src/qemu/roms/edk2" checkout edk2-stable202108 || perror "Failed to checkout new EDK2 version!"
+ git -C "${MODULE_WORK_DIR}/src/qemu" commit -a -m "Update EDK2 to 08.2021 release" || perror "Failed to update EDK2 version!"
+
+ git -C "${MODULE_WORK_DIR}/src/qemu" submodule update --recursive || perror "Failed to update submodules recursivly!"
+}
+
+build() {
+ local SRCDIR="${MODULE_WORK_DIR}/src/qemu"
+ local DSTDIR="${MODULE_BUILD_DIR}"
+ cde "${SRCDIR}"
+
+ # install meson (>= 0.54.0) since packaged version is too old
+ pip3 install "meson>=0.54.0"
+
+ ./configure \
+ --prefix="/usr" \
+ --sysconfdir="/etc" \
+ --libexecdir="/usr/libexec" \
+ --localstatedir="/var" \
+ --target-list=x86_64-softmmu \
+ --enable-kvm \
+ --disable-xen \
+ --enable-gnutls \
+ --enable-gtk \
+ --enable-vnc \
+ --enable-spice \
+ --enable-libusb \
+ --enable-usb-redir \
+ --enable-lzo \
+ --enable-zstd \
+ --enable-linux-aio \
+ --enable-opengl \
+ --enable-virglrenderer \
+ --enable-vhost-net \
+ --enable-vhost-user \
+ --enable-libudev \
+ --enable-brlapi \
+ --audio-drv-list="pa alsa" \
+ --enable-modules || perror "'configure' failed."
+ make || perror "'make' failed."
+ DESTDIR="${DSTDIR}" make install || perror "'make install' failed."
+
+ # change permissions for the bridge helper
+ chmod u+s "${DSTDIR}/usr/libexec/qemu-bridge-helper"
+
+ # change permission of setup script
+ chmod +x "${DSTDIR}/usr/share/qemu/init/qemu-kvm-init"
+
+ # delete empty run folder to prevent mltk from stopping
+ rm -rf "${DSTDIR}/var/run"
+}
+
+post_copy() {
+ :
+}
diff --git a/core/modules/qemu-src/module.conf b/core/modules/qemu-src/module.conf
new file mode 100644
index 00000000..3de2a5ec
--- /dev/null
+++ b/core/modules/qemu-src/module.conf
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+REQUIRED_GIT="
+ https://gitlab.com/qemu-project/qemu.git||v6.1.0
+"
+
+# copy everything since there is a clean installation done by 'make install'
+REQUIRED_DIRECTORIES="/"
diff --git a/core/modules/qemu-src/module.conf.ubuntu b/core/modules/qemu-src/module.conf.ubuntu
new file mode 100644
index 00000000..9125813b
--- /dev/null
+++ b/core/modules/qemu-src/module.conf.ubuntu
@@ -0,0 +1,50 @@
+#!/bin/bash
+REQUIRED_INSTALLED_PACKAGES="
+ gcc
+ debhelper
+ device-tree-compiler
+ python3
+ python3-pip
+ ninja-build
+ libaio-dev
+ libpulse-dev
+ libasound2-dev
+ libbrlapi-dev
+ libcap-ng-dev
+ libcurl4-gnutls-dev
+ libfdt-dev
+ libgnutls28-dev
+ libgtk-3-dev
+ libvte-2.91-dev
+ libiscsi-dev
+ libncursesw5-dev
+ libvirglrenderer-dev
+ libepoxy-dev
+ libdrm-dev
+ libgbm-dev
+ libnuma-dev
+ libcacard-dev
+ libpixman-1-dev
+ librbd-dev
+ libsasl2-dev
+ libseccomp-dev
+ libslirp-dev
+ libspice-server-dev
+ librdmacm-dev
+ libibverbs-dev
+ libibumad-dev
+ libusb-1.0-0-dev
+ libusbredirparser-dev
+ libssh-dev
+ nettle-dev
+ uuid-dev
+ xfslibs-dev
+ zlib1g-dev
+ libudev-dev
+ libjpeg-dev
+ libpng-dev
+ libpmem-dev
+ libzstd-dev
+ libbz2-dev
+ libfuse3-dev
+"
diff --git a/core/modules/qemu/data/etc/systemd/system/qemu.service b/core/modules/qemu/data/etc/systemd/system/qemu.service
index 4d0e7a19..1776d63c 100644
--- a/core/modules/qemu/data/etc/systemd/system/qemu.service
+++ b/core/modules/qemu/data/etc/systemd/system/qemu.service
@@ -11,3 +11,6 @@ After=qemu-kvm.service
Type=oneshot
RemainAfterExit=yes
ExecStart=/opt/openslx/scripts/systemd-qemu_env start
+
+[Install]
+WantedBy=graphical.target
diff --git a/core/modules/qemu/module.build b/core/modules/qemu/module.build
index 801d1d4b..cc7eaee0 100644
--- a/core/modules/qemu/module.build
+++ b/core/modules/qemu/module.build
@@ -25,7 +25,4 @@ post_copy() {
# change access rights of the qemu bridge helper config
chown root:kvm /etc/qemu/bridge.conf
chmod 0664 /etc/qemu/bridge.conf
-
- # set UID to avoid operation not permitted errors
- chmod u+s /usr/lib/qemu/qemu-bridge-helper
}
diff --git a/core/modules/qemu/module.conf b/core/modules/qemu/module.conf
index 1e272eb4..d4169c39 100644
--- a/core/modules/qemu/module.conf
+++ b/core/modules/qemu/module.conf
@@ -1,6 +1,7 @@
#!/bin/bash
REQUIRED_MODULES="
+ qemu-src
libvirt
openjdk-8-jre-headless
looking-glass-client
diff --git a/core/modules/qemu/module.conf.ubuntu b/core/modules/qemu/module.conf.ubuntu
index 8edc5df4..1853bdf8 100644
--- a/core/modules/qemu/module.conf.ubuntu
+++ b/core/modules/qemu/module.conf.ubuntu
@@ -6,13 +6,5 @@ REQUIRED_INSTALLED_PACKAGES="
"
REQUIRED_CONTENT_PACKAGES="
- qemu
- qemu-kvm
- qemu-system-common
- qemu-system-arm
- qemu-system-x86
- qemu-utils
- seabios
- ovmf
jq
"
diff --git a/core/targets/qemu/qemu-src b/core/targets/qemu/qemu-src
new file mode 120000
index 00000000..d50a48b1
--- /dev/null
+++ b/core/targets/qemu/qemu-src
@@ -0,0 +1 @@
+../../modules/qemu-src \ No newline at end of file