diff options
author | Manuel Bentele | 2021-07-01 09:34:31 +0200 |
---|---|---|
committer | Manuel Bentele | 2021-07-01 09:34:31 +0200 |
commit | fe94feb0301a16e6f9ba83e5c13ddb67174599e1 (patch) | |
tree | b9fb1701b8075e84a3b90065362ca2ff88f2920e | |
parent | Merge branch 'master' into installer (diff) | |
parent | [qemu] Enable shared folders if global support is active (diff) | |
download | mltk-fe94feb0301a16e6f9ba83e5c13ddb67174599e1.tar.gz mltk-fe94feb0301a16e6f9ba83e5c13ddb67174599e1.tar.xz mltk-fe94feb0301a16e6f9ba83e5c13ddb67174599e1.zip |
Merge branch 'master' into installer
10 files changed, 47 insertions, 199 deletions
diff --git a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/run-virt.include b/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/run-virt.include index b7e43df9..c9d2856c 100644 --- a/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/run-virt.include +++ b/core/modules/qemu/data/opt/openslx/vmchooser/plugins/qemu/run-virt.include @@ -27,27 +27,31 @@ run_plugin() { local vm_final_run_file="/tmp/qemu-last-config.xml" # call the Libvirt Java tool to finalize configuration and start VM - declare -rg VIRTCMD="java -jar /opt/openslx/share/java/runvirt-plugin-qemu.jar" + declare -rg VIRTCMD="java" + VIRTCMDOPTS=( "-jar" "/opt/openslx/vmchooser/plugins/qemu/runvirt-plugin-qemu.jar" ) - isset DEBUG && VIRTCMDOPTS+=( "-debug" "${DEBUG}" ) - isset VM_CLEANNAME && VIRTCMDOPTS+=( "-vmname" "${VM_CLEANNAME}" ) - isset VM_DISPLAYNAME && VIRTCMDOPTS+=( "-vmdsplname" "${VM_DISPLAYNAME}" ) - isset VM_OS_TYPE && VIRTCMDOPTS+=( "-vmos" "${VM_OS_TYPE}" ) - isset VM_RUN_FILE && VIRTCMDOPTS+=( "-vmcfginp" "${VM_RUN_FILE}" ) - isset vm_final_run_file && VIRTCMDOPTS+=( "-vmcfgout" "${vm_final_run_file}" ) - isset IMGUUID && VIRTCMDOPTS+=( "-vmuuid" "${IMGUUID}" ) - isset CPU_CORES && VIRTCMDOPTS+=( "-vmncpus" "${CPU_CORES}" ) - isset VM_MEM && VIRTCMDOPTS+=( "-vmmem" "${VM_MEM}" ) - isset VM_MAC_ADDR && VIRTCMDOPTS+=( "-vmmac0" "${VM_MAC_ADDR}" ) - isset VM_DISKFILE_RO && VIRTCMDOPTS+=( "-vmhdd0" "${VM_DISKFILE_RO}" ) - isset FLOPPY_0 && VIRTCMDOPTS+=( "-vmfloppy0" "${FLOPPY_0}" ) - isset SLX_FLOPPY_IMG && VIRTCMDOPTS+=( "-vmfloppy1" "${SLX_FLOPPY_IMG}" ) - isset CDROM_0 && VIRTCMDOPTS+=( "-vmcdrom0" "${CDROM_0}" ) - isset CDROM_1 && VIRTCMDOPTS+=( "-vmcdrom1" "${CDROM_1}" ) - isset SERIAL0 && VIRTCMDOPTS+=( "-vmserial0" "${SERIAL0}" ) - isset PARALLEL0 && VIRTCMDOPTS+=( "-vmparallel0" "${PARALLEL0}" ) - isset HOME_SHARE_PATH && VIRTCMDOPTS+=( "-vmfssrc0" "${HOME_SHARE_PATH}" ) - isset HOME_SHARE_NAME && VIRTCMDOPTS+=( "-vmfstgt0" "${HOME_SHARE_NAME}" ) - isset COMMON_SHARE_PATH && VIRTCMDOPTS+=( "-vmfssrc1" "${COMMON_SHARE_PATH}" ) - isset COMMON_SHARE_NAME && VIRTCMDOPTS+=( "-vmfstgt1" "${COMMON_SHARE_NAME}" ) + notempty DEBUG && VIRTCMDOPTS+=( "-debug" "${DEBUG}" ) + notempty VM_CLEANNAME && VIRTCMDOPTS+=( "-vmname" "${VM_CLEANNAME}" ) + notempty VM_DISPLAYNAME && VIRTCMDOPTS+=( "-vmdsplname" "${VM_DISPLAYNAME}" ) + notempty VM_OS_TYPE && VIRTCMDOPTS+=( "-vmos" "${VM_OS_TYPE}" ) + notempty VM_RUN_FILE && VIRTCMDOPTS+=( "-vmcfginp" "${VM_RUN_FILE}" ) + notempty vm_final_run_file && VIRTCMDOPTS+=( "-vmcfgout" "${vm_final_run_file}" ) + notempty IMGUUID && VIRTCMDOPTS+=( "-vmuuid" "${IMGUUID}" ) + notempty CPU_CORES && VIRTCMDOPTS+=( "-vmncpus" "${CPU_CORES}" ) + notempty VM_MEM && VIRTCMDOPTS+=( "-vmmem" "${VM_MEM}" ) + notempty VM_MAC_ADDR && VIRTCMDOPTS+=( "-vmmac0" "${VM_MAC_ADDR}" ) + notempty VM_DISKFILE_RO && VIRTCMDOPTS+=( "-vmhdd0" "${VM_DISKFILE_RO}" ) + notempty FLOPPY_0 && VIRTCMDOPTS+=( "-vmfloppy0" "${FLOPPY_0}" ) + notempty SLX_FLOPPY_IMG && VIRTCMDOPTS+=( "-vmfloppy1" "${SLX_FLOPPY_IMG}" ) + notempty CDROM_0 && VIRTCMDOPTS+=( "-vmcdrom0" "${CDROM_0}" ) + notempty CDROM_1 && VIRTCMDOPTS+=( "-vmcdrom1" "${CDROM_1}" ) + notempty SERIAL0 && VIRTCMDOPTS+=( "-vmserial0" "${SERIAL0}" ) + notempty PARALLEL0 && VIRTCMDOPTS+=( "-vmparallel0" "${PARALLEL0}" ) + + if [ "${SHARE_REMAP_MODE}" -gt 1 ]; then + notempty HOME_SHARE_PATH && VIRTCMDOPTS+=( "-vmfssrc0" "${HOME_SHARE_PATH}" ) + notempty HOME_SHARE_NAME && VIRTCMDOPTS+=( "-vmfstgt0" "${HOME_SHARE_NAME}" ) + notempty COMMON_SHARE_PATH && VIRTCMDOPTS+=( "-vmfssrc1" "${COMMON_SHARE_PATH}" ) + notempty COMMON_SHARE_NAME && VIRTCMDOPTS+=( "-vmfstgt1" "${COMMON_SHARE_NAME}" ) + fi } diff --git a/core/modules/qemu/module.build b/core/modules/qemu/module.build index 4d86de96..d2ccb921 100644 --- a/core/modules/qemu/module.build +++ b/core/modules/qemu/module.build @@ -15,7 +15,7 @@ build() { # install qemu runvirt plugin local build_artifact_filename="runvirt-plugin-qemu-1.0-SNAPSHOT.jar" - local install_dir="${MODULE_BUILD_DIR}/opt/openslx/share/java" + local install_dir="${MODULE_BUILD_DIR}/opt/openslx/vmchooser/plugins/qemu" local install_filename="runvirt-plugin-qemu.jar" mkdir -p "${install_dir}" cp "${build_dir}/target/${build_artifact_filename}" "${install_dir}/${install_filename}" || perror "Could not install runvirt-plugin-qemu!" diff --git a/core/modules/qemu/module.conf b/core/modules/qemu/module.conf index c1cdf05d..1914cffe 100644 --- a/core/modules/qemu/module.conf +++ b/core/modules/qemu/module.conf @@ -8,3 +8,7 @@ REQUIRED_MODULES=" REQUIRED_BINARIES="" REQUIRED_LIBRARIES="" REQUIRED_DIRECTORIES="" + +REQUIRED_FILES=" + /opt/openslx/vmchooser/plugins/qemu/runvirt-plugin-qemu.jar +" diff --git a/core/modules/qemu/runvirt-plugin-qemu/pom.xml b/core/modules/qemu/runvirt-plugin-qemu/pom.xml index d8bb9743..36f62796 100644 --- a/core/modules/qemu/runvirt-plugin-qemu/pom.xml +++ b/core/modules/qemu/runvirt-plugin-qemu/pom.xml @@ -12,6 +12,7 @@ <url>https://git.openslx.org/openslx-ng/mltk.git/</url> <properties> + <main.class>org.openslx.runvirt.plugin.qemu.App</main.class> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> @@ -145,6 +146,13 @@ </execution> </executions> <configuration> + <archive> + <manifest> + <mainClass>${main.class}</mainClass> + <addDefaultImplementationEntries>true</addDefaultImplementationEntries> + <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries> + </manifest> + </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> diff --git a/core/modules/qemukvm/data/opt/openslx/scripts/systemd-qemukvm_env b/core/modules/qemukvm/data/opt/openslx/scripts/systemd-qemukvm_env deleted file mode 100755 index 7717394d..00000000 --- a/core/modules/qemukvm/data/opt/openslx/scripts/systemd-qemukvm_env +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/ash -# ----------------------------------------------------------------------------- -# -# Copyright (c) 2017..2018 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 support@bwlehrpool.de. -# -# General information about bwLehrpool can be found at https://bwlehrpool.de -# -# ----------------------------------------------------------------------------- -# systemd-qemukvm_env -# - This is the preparation script for the configuration of Linux Qemu/KVM. -################################################################################ - -# lazy load all kvm related modules -modprobe kvm -modprobe kvm_amd -modprobe kvm_intel - -if [ ! -e /dev/kvm ]; then - slxlog "qemukvm-modules" "/dev/kvm not found! Missing kvm kernel module(s)?" - exit 1 -fi - diff --git a/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/finalize_start_command.inc b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/finalize_start_command.inc deleted file mode 100644 index eff764fe..00000000 --- a/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/finalize_start_command.inc +++ /dev/null @@ -1,49 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# Copyright (c) 2009..2018 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 support@bwlehrpool.de. -# -# General information about bwLehrpool can be found at https://bwlehrpool.de -# -# ----------------------------------------------------------------------------- -# run-virt.include -# - Include script for running the QEMU/Linux KVM virtual machine on an -# OpenSLX client via the run-virt.sh or run-vmgrid.sh -################################################################################ - -# set options that depend on previous includes -# and build the final start command -finalize_start_command() { - - # set cpu type - VIRTCMDOPTS+=( "-cpu" "host" ) - # set cpu cores - VIRTCMDOPTS+=( "-smp" "${CPU_CORES}" ) - - # set RAM - VIRTCMDOPTS+=( "-m" "${VM_MEM}" ) - - # special feature for real and virtual floppy disks - isset FLOPPY_0 && VIRTCMDOPTS+=( "-fda" "${FLOPPY_0}" ) - isset SLX_FLOPPY_IMG && VIRTCMDOPTS+=( "-fdb" "${SLX_FLOPPY_IMG}" ) - - # add optical drive if available - isset CDROM_0 && VIRTCMDOPTS+=( "-cdrom" "${CDROM_0}" ) - - # audio - isset SOUND_DEV && VIRTCMDOPTS+=( "-soundhw" "${SOUND_DEV}" ) - - # serial devices TODO test - if isset SERIAL_PORTS; then - for DEV in $SERIAL_PORTS; do - : # buggeh: VIRTCMDOPTS+=( "-serial" "${DEV}" ) - done - fi -} - -call_post_source finalize_start_command diff --git a/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/init_core.inc b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/init_core.inc deleted file mode 100644 index 53f214bd..00000000 --- a/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/includes/init_core.inc +++ /dev/null @@ -1,54 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# Copyright (c) 2009..2018 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 support@bwlehrpool.de. -# -# General information about bwLehrpool can be found at https://bwlehrpool.de -# -# ----------------------------------------------------------------------------- -# run-virt.include -# - Include script for running the QEMU/Linux KVM virtual machine on an -# OpenSLX client via the run-virt.sh or run-vmgrid.sh -################################################################################ - -# check if kvm kernel module are available -if [ ! -c /dev/kvm ]; then - writelog "KVM kernel modules not loaded!" - EXIT_TYPE="internal" EXIT_REASON="QEMU/KVM Virtualisierer nicht initialisiert!" cleanexit 1 -fi - -# check if qemu binaries are available -if ! check_dep qemu-system-{i386,x86_64}; then - writelog "QEMU binaries not available!" - EXIT_TYPE="internal" EXIT_REASON="QEMU/KVM Virtualisierer nicht initialisiert!" cleanexit 1 -fi - -# set general purpose options here, mostly evaluates information -# contained in /opt/openslx/vmchooser/config/virtualization.conf - -# TODO some options should come from the server, in particular -# - disk controller type (virtio, scsi, ide...) -# - arch to emulate (x86_64, i386, ...) -# - graphics mode? -# - sound dev? -# - tbd - -# display name, remove blanks because of cmdline problems -declare -rg CMD_DISPLAYNAME=$(echo ${VM_DISPLAYNAME} | sed -e "s, ,-,g;s,(,[,g;s,),],g") -VIRTCMDOPTS+=( "-name" "${CMD_DISPLAYNAME}" ) - -# graphical start: vga, vmware, qxl, spice? -VIRTCMDOPTS+=( "-vga" "std" "-full-screen" ) - -# hot keys ALT+CTRL+SHIFT (does not work properly!?) -VIRTCMDOPTS+=( "-alt-grab" ) - -# TODO support other types of boot? any usecase for network boot? -# for now just boot from disk -VIRTCMDOPTS+=( "-boot" "c" ) - diff --git a/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include b/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include deleted file mode 100644 index a1a41499..00000000 --- a/core/modules/qemukvm/data/opt/openslx/vmchooser/plugins/qemukvm/run-virt.include +++ /dev/null @@ -1,44 +0,0 @@ -# ----------------------------------------------------------------------------- -# -# Copyright (c) 2009..2018 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 support@bwlehrpool.de. -# -# General information about bwLehrpool can be found at https://bwlehrpool.de -# -# ----------------------------------------------------------------------------- -# run-virt.include -# - qemu/kvm plugin for vmchooser run-virt -################################################################################ - -# BASH_SOURCE[0] contains the file being sourced, namely this one -declare -rg QEMUKVM_PLUGIN_DIR="$(dirname "${BASH_SOURCE[0]}")" -declare -rg QEMUKVM_INCLUDE_DIR="${QEMUKVM_PLUGIN_DIR}/includes" - -# TODO make this part of the metadata coming from the server -# TBD: "firewall printer usb slxfloppy sound netshares" -declare -rg PLUGIN_FEATURES="slxfloppy" - -run_plugin() { - # declaration of default functions and variables for vmware - $(safesource --exit "${QEMUKVM_INCLUDE_DIR}/init_core.inc") - - # determine limitations wrt RAM and CPU count of VM - $(safesource "${QEMUKVM_INCLUDE_DIR}/determine_hardware_limitations.inc") - - # setup networking - $(safesource "${QEMUKVM_INCLUDE_DIR}/setup_network.inc") - - # setup rw layer for ro image - $(safesource "${QEMUKVM_INCLUDE_DIR}/setup_rw_layer.inc") - - # build the final start command - $(safesource "${QEMUKVM_INCLUDE_DIR}/finalize_start_command.inc") - - # print summary - needs writelog() from vmchooser-run_virt - $(safesource "${QEMUKVM_INCLUDE_DIR}/log_config_summary.inc") -} diff --git a/core/modules/run-virt/README b/core/modules/run-virt/README index 2f300630..b04dd07e 100644 --- a/core/modules/run-virt/README +++ b/core/modules/run-virt/README @@ -35,6 +35,13 @@ from $VMCHOOSER_DIR/plugins/$PLUGIN_ID/* Absolute path to the main run-virt script. Should usually be /opt/openslx/vmchooser/vmchooser-run_virt +# $SHARE_REMAP_MODE +How to map network shares into guest +0 = disabled +1 = mount normally in guest (openslx.exe) +2 = mount normally in gues, but fall back to shared folders if it fails +3 = use shared folders feature of virtualizer + # $SRC_IMG_ABSOLUTE Absolute path to the VMs HDD image. When using DNBD3, which requires $SRC_IMG_RELATIVE to be set, this file might not actually exist. diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/get_xml_file_variables.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/get_xml_file_variables.inc index ff5c736c..b4ab4c1c 100644 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/get_xml_file_variables.inc +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/get_xml_file_variables.inc @@ -49,7 +49,7 @@ parse_xml() { readonly VM_DISPLAYNAME # Define VM_CLEANNAME since VM_DISPLAYNAME can be long and contain weird characters - declare -rg VM_CLEANNAME=$(echo "${VM_DISPLAYNAME:0:32}" | sed -r 's/[^0-9a-zA-Z_-\.]+/_/g') + declare -rg VM_CLEANNAME=$(echo "${VM_DISPLAYNAME:0:32}" | sed -r 's/[^0-9a-zA-Z_\-\.]+/_/g') # image is for the following virtual machine declare -rg PLUGIN_ID=$(get_xml "virtualmachine") |