summaryrefslogtreecommitdiffstats
path: root/core/modules/run-virt/data/opt
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/run-virt/data/opt')
-rwxr-xr-xcore/modules/run-virt/data/opt/openslx/scripts/vmchooser-xml_filter75
-rwxr-xr-xcore/modules/run-virt/data/opt/openslx/system-check/hooks.d/30-run-virt2
-rwxr-xr-xcore/modules/run-virt/data/opt/openslx/vmchooser/data/linux/includes/00_vars.inc7
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/data/linux/includes/10_functions.inc50
-rwxr-xr-xcore/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exebin62976 -> 63488 bytes
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/download_vm_metadata.inc45
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/get_xml_file_variables.inc19
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc14
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc53
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc29
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_firewall.inc3
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_network_shares.inc17
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_sound.inc5
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_virtual_floppy.inc8
-rwxr-xr-xcore/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt55
15 files changed, 202 insertions, 180 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/scripts/vmchooser-xml_filter b/core/modules/run-virt/data/opt/openslx/scripts/vmchooser-xml_filter
deleted file mode 100755
index 2d2df304..00000000
--- a/core/modules/run-virt/data/opt/openslx/scripts/vmchooser-xml_filter
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/bin/bash
-# Probably needs bash somewhere
-# -----------------------------------------------------------------------------
-#
-# Copyright (c) 2007..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
-#
-# -----------------------------------------------------------------------------
-# xmlfilter.sh
-# - This script is invoked by the vmchooser tool. It simply filters xml-
-# files (taking the path to these files in $1). You might modify it in any
-# way to match your needs, e.g. ask some database instead. You can re-
-# implement it in any other programming language too. You simply have to
-# return a list of proper xml files to be interpreted by the vmchooser
-# binary). Please check for vmchooser.sh too ...
-# -----------------------------------------------------------------------------
-
-# This script .
-#
-# currently:
-# - filter for slxgrp (which comes from /etc/machine-setup)
-#
-
-# include default directories
-. /opt/openslx/config
-
-if [ -f "${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.conf" ]; then
- . "${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.conf"
-fi
-
-function handlePersistentVM() {
- if grep --extended-regexp -q "<persistent param=\"(|.+:)$USER(|:.+)\"" "$1"; then
- # If this virtual machine is useable as persistent version for current
- # user we provide an additional persistent version.
- # TODO: This evil black magic needs to be rewritten some day (by someone who understands it)
- local originalImagePath=$(grep -io '<image_name param=.*"' "$1" | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }')
- local imageName=$(basename "$originalImagePath")
- eval export SLX_VM_PERSISTENT_PATH="${SLX_VM_PERSISTENT_PATH}" && \
- local imagePath="${SLX_VM_PERSISTENT_PATH}${imageName}"
- local persistentConfigVersionFilePath="$(mktemp --directory)/$(basename "$1")"
- local vmchooserFilePath="$(dirname "$0")/vmchooser-clc"
- if [ ! -f "$vmchooserFilePath" ]; then
- vmchooserFilePath='/opt/openslx/scripts/vmchooser-clc'
- fi
- "$vmchooserFilePath" "$1" "$persistentConfigVersionFilePath" \
- --create-persistent-config "$imagePath" && \
- echo "$persistentConfigVersionFilePath"
- fi
-}
-
-for FILE in $(find -L "$1" -iname "*.xml"); do
- # filter all xmls which aren't set active
- grep -i -q "<active param=.*true.*" "$FILE" || continue
- # HACK: filter all virtualbox images, as vbox is not ready yet
- grep -i -q "<virtualmachine param=.*virtualbox.*" "$FILE" && continue
- if [ -n "${SLX_VM_POOL_FILTER}" ]; then
- # filter all xmls with pool-param not equal to vmchooser::env
- if [ $(grep "<pools param=\"${SLX_VM_POOL_FILTER}\"" "$FILE" | wc -l) -eq 1 ]; then
- handlePersistentVM "$FILE"
- echo "$FILE"
- fi
- else
- handlePersistentVM "$FILE"
- # if there is no pool set, just take all available xmls
- echo "$FILE"
- fi
-done
-
diff --git a/core/modules/run-virt/data/opt/openslx/system-check/hooks.d/30-run-virt b/core/modules/run-virt/data/opt/openslx/system-check/hooks.d/30-run-virt
index 27d85164..61cba10b 100755
--- a/core/modules/run-virt/data/opt/openslx/system-check/hooks.d/30-run-virt
+++ b/core/modules/run-virt/data/opt/openslx/system-check/hooks.d/30-run-virt
@@ -2,7 +2,7 @@
. /opt/openslx/config
. /opt/openslx/bin/slx-tools
-. /run/hwinfo
+. /run/openslx/hwinfo
if [ -n "$1" ]; then
exec >> "$1"
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/data/linux/includes/00_vars.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/data/linux/includes/00_vars.inc
index cf6592f1..df76c93e 100755
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/data/linux/includes/00_vars.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/data/linux/includes/00_vars.inc
@@ -57,6 +57,13 @@ SCRIPTEXT=$(grep scriptExt "$DISKMOUNTDIR/openslx.ini" | cut -f 2 -d "=")
MUTESOUND=$(grep muteSound "$DISKMOUNTDIR/openslx.ini" | cut -f 2 -d "=")
SOUNDVOL="100%"
+# Edit mode, VM is persistent
+val=$( grep '^persistentMode=' "$SLXCONFIGFILE" | cut -d '=' -f 2)
+PERSISTENT_MODE=
+if [ -n "$val" ] && [ "$val" -ne 0 ]; then
+ PERSISTENT_MODE=1
+fi
+
##### Programs interfering with resolution setting #####
KILLRESPROGS="kscreen_backend_launcher"
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/data/linux/includes/10_functions.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/data/linux/includes/10_functions.inc
index 8b394334..85f185a3 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/data/linux/includes/10_functions.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/data/linux/includes/10_functions.inc
@@ -121,18 +121,19 @@ function mount_share()
unset PASSWD
fi
if [ "$ERR" -eq 0 ]; then
- logger "openslx sharemapper: Linking ${SHARENAME}, if possible."
+ if [ -z "$PERSISTENT_MODE" ]; then
+ logger "openslx sharemapper: Linking ${SHARENAME}, if possible."
- if [ -n "${SHARENAME}" ]; then
- ln -s "$USERSHAREDIR" "${USERDESKTOP}"/"$SHARENAME"
- chown "$LOCALUSER" "${USERDESKTOP}"/"$SHARENAME"
- logger "openslx sharemapper: ${SHARENAME} linked."
- elif [ -n "${SHARELETTER}" ]; then
- ln -s "$USERSHAREDIR" "${USERDESKTOP}"/"$SHARELETTER"
- chown "$LOCALUSER" "${USERDESKTOP}"/"$SHARELETTER"
- logger "openslx sharemapper: No sharename found, share letter ${SHARELETTER} linked."
+ if [ -n "${SHARENAME}" ]; then
+ ln -sn "$USERSHAREDIR" "${USERDESKTOP}"/"$SHARENAME"
+ chown "$LOCALUSER" "${USERDESKTOP}"/"$SHARENAME"
+ logger "openslx sharemapper: ${SHARENAME} linked."
+ elif [ -n "${SHARELETTER}" ]; then
+ ln -sn "$USERSHAREDIR" "${USERDESKTOP}"/"$SHARELETTER"
+ chown "$LOCALUSER" "${USERDESKTOP}"/"$SHARELETTER"
+ logger "openslx sharemapper: No sharename found, share letter ${SHARELETTER} linked."
+ fi
fi
-
else
logger "openslx sharemapper: deleting previously creates share mount dir $USERSHAREDIR."
rmdir "$USERSHAREDIR" 2>/dev/null
@@ -150,21 +151,28 @@ function mount_home()
unset USER
unset PASSWD
- case $ERR in 1) logger "openslx sharemapper: could not mount home share."
+ case $ERR in
+ 1)
+ logger "openslx sharemapper: could not mount home share."
echo "Konnte Home-Laufwerk nicht einhängen!" >> "$USERLOGFILE"
;;
- 2) logger "openslx sharemapper: home share seems to be already mounted."
+ 2)
+ logger "openslx sharemapper: home share seems to be already mounted."
;;
- 0) logger "openslx sharemapper: Linking ${USERDESKTOP}/$(basename $USERHOMEDIR), if possible."
- # Changed: Link on Desktop no longer "Home-verz.", but same
- # name as last part of $USERHOMEDIR (-->PERSISTENT)
- # ln -s "$USERHOMEDIR" "${USERDESKTOP}"/"$SHARENAME"
- ln -s "$USERHOMEDIR" "${USERDESKTOP}"/$(basename "$USERHOMEDIR")
- chown "$LOCALUSER" "${USERDESKTOP}"/$(basename "$USERHOMEDIR")
- logger "openslx sharemapper: "${USERDESKTOP}"/$(basename "$USERHOMEDIR") linked."
+ 0)
+ if [ -z "$PERSISTENT_MODE" ]; then
+ logger "openslx sharemapper: Linking ${USERDESKTOP}/$(basename $USERHOMEDIR), if possible."
+ # Changed: Link on Desktop no longer "Home-verz.", but same
+ # name as last part of $USERHOMEDIR (-->PERSISTENT)
+ # ln -s "$USERHOMEDIR" "${USERDESKTOP}"/"$SHARENAME"
+ ln -sn "$USERHOMEDIR" "${USERDESKTOP}"/$(basename "$USERHOMEDIR")
+ chown "$LOCALUSER" "${USERDESKTOP}"/$(basename "$USERHOMEDIR")
+ logger "openslx sharemapper: "${USERDESKTOP}"/$(basename "$USERHOMEDIR") linked."
+ fi
+ ;;
+ *)
+ logger "openslx sharemapper: Unknown error level mounting home share."
;;
- *) logger "openslx sharemapper: Unknown error level mounting home share."
- ;;
esac
}
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe b/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe
index 7a9e5e6c..73c19530 100755
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe
Binary files differ
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/download_vm_metadata.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/download_vm_metadata.inc
index a35d328b..c378cd5b 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/download_vm_metadata.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/download_vm_metadata.inc
@@ -32,23 +32,63 @@ Die Metadaten der Lehrumgebung konnten nicht umkopiert werden.
Wenden Sie sich an den Support, wenn das Problem bestehen bleibt.
$EXTRA_ERROR" cleanexit 1
fi
+ if [ -s "$CONFDIR/config.inc" ]; then
+ $( safesource "$CONFDIR/config.inc" )
+ notempty DMSD_IMAGE_PATH && SRC_IMG_RELATIVE="$DMSD_IMAGE_PATH"
+ fi
+
+ # Validate metadata from XML, now that it has potentially been augmented
+ readonly SRC_IMG_RELATIVE
+
+ if isempty SRC_IMG_ABSOLUTE SRC_IMG_RELATIVE; then
+ writelog "Error parsing XML: Neither relative nor absolute path for image found!"
+ EXIT_TYPE="user" EXIT_REASON="Konnte keinen Pfad zur ausgewählten virtuellen Maschine ermitteln!" cleanexit 1
+ fi
+
+ if isempty SRC_IMG_ABSOLUTE && notempty VMSTORE_PATH; then
+ SRC_IMG_ABSOLUTE="${VMSTORE_PATH}/${SRC_IMG_RELATIVE}"
+ fi
+ readonly SRC_IMG_ABSOLUTE
+
+ declare -rg IMG_BASENAME=$(basename "$SRC_IMG_ABSOLUTE")
+
+ notempty VM_DISPLAYNAME || VM_DISPLAYNAME="${IMG_BASENAME}"
+ 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')
+
+ #
return 0
}
download_metadata_default() {
local TRIES WLOG TMPFILE RET ERRCODE CMDLINE
+ local cow_token argx
# Sanity checks
if ! check_dep curl; then
writelog "Could not find 'curl' in PATH: $PATH"
EXIT_TYPE="internal" EXIT_REASON="Fehlendes Dienstprogramm 'curl'!" cleanexit 1
fi
+ # Admin-mode (Edit-Mode)
+ argx=
+ if is_on "$VMCHOOSER_ADMIN_MODE"; then
+ cow_token=$( cat "/run/user/$( id -u )/cow-token" )
+ if isempty cow_token; then
+ writelog "No cow token found in edit mode"
+ EXIT_TYPE=user EXIT_REASON="Admin-Modus aktiviert, aber kein cow-token vorgefunden." cleanexit 1
+ fi
+ argx="?cow-user=$cow_token&cow-type=$VMCHOOSER_ADMIN_TYPE"
+ fi
+
# Try new unified .tar.gz way
TMPFILE="$TMPDIR/metadata.tgz"
WLOG="$TMPDIR/curl-metadata.log"
CMDLINE=
curl --help | grep -q -- --retry-connrefused && CMDLINE="--retry-connrefused"
- curl -L -o "$TMPFILE" -w '\nretval:%{http_code}\n' --retry 3 $CMDLINE --max-time 8 --retry-max-time 15 "${url_lecture_metadata}" &> "$WLOG"
+ curl -L -o "$TMPFILE" -w '\nretval:%{http_code}\n' --retry 3 $CMDLINE --max-time 8 --retry-max-time 15 \
+ "${url_lecture_metadata}${argx}" &> "$WLOG"
ERRCODE=$( awk -F: '{ if ($1 == "retval") print $2 }' "$WLOG" )
RET=$?
if [ "$RET" = 0 ] && [ -n "$ERRCODE" ] && [ "$ERRCODE" -ge 200 ] && [ "$ERRCODE" -lt 300 ]; then
@@ -62,6 +102,9 @@ download_metadata_default() {
writelog "Downloading metadata.tgz failed (RET=$RET, HTTP=$ERRCODE). Cannot start VM.
$( cat $WLOG )"
#
+ if [ -s "$TMPFILE" ] && grep -q --binary-files=without-match -E '[a-z]'; then
+ EXTRA_ERROR="$( cat "$TMPFILE" )"
+ fi
fi
}
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 b4ab4c1c..17f0e8ed 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
@@ -24,32 +24,15 @@ parse_xml() {
[ -n "$url_lecture_runscript" ] && readonly url_lecture_runscript="${url_lecture_runscript//%UUID%/${IMGUUID}}"
# Relative / Absolute path to image
- declare -rg SRC_IMG_RELATIVE=$(get_xml "image_name")
+ declare -g SRC_IMG_RELATIVE=$(get_xml "image_name")
declare -g SRC_IMG_ABSOLUTE=$(get_xml "image_path")
- if isempty SRC_IMG_ABSOLUTE SRC_IMG_RELATIVE; then
- writelog "Error parsing XML: Neither relative nor absolute path for image found!"
- EXIT_TYPE="user" EXIT_REASON="Konnte kein Pfad zur ausgewählten virtuellen Maschine ermitteln!" cleanexit 1
- fi
-
if notempty SRC_IMG_ABSOLUTE && [ "${SRC_IMG_ABSOLUTE:0:1}" != "/" ]; then
writelog "Error parsing XML: Parsed value for absolute path doesn't start with '/': '$SRC_IMG_ABSOLUTE'"
EXIT_TYPE="user" EXIT_REASON="Ungültiger asboluter Pfad zur virtuellen Maschine!" cleanexit 1
fi
- if isempty SRC_IMG_ABSOLUTE && notempty VMSTORE_PATH; then
- SRC_IMG_ABSOLUTE="${VMSTORE_PATH}/${SRC_IMG_RELATIVE}"
- fi
- readonly SRC_IMG_ABSOLUTE
-
- declare -rg IMG_BASENAME=$(basename "$SRC_IMG_ABSOLUTE")
-
VM_DISPLAYNAME=$(get_xml "short_description")
- notempty VM_DISPLAYNAME || VM_DISPLAYNAME="${IMG_BASENAME}"
- 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')
# image is for the following virtual machine
declare -rg PLUGIN_ID=$(get_xml "virtualmachine")
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc
index 918a767f..2ae010b3 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/set_runvirt_hardware_variables.inc
@@ -13,11 +13,11 @@
# Use: 00:FF:00 for firtual machines ;)
## Functions ##
-# Import /run/hwinfo variables
+# Import /run/openslx/hwinfo variables
import_hwinfo() {
- $(safesource "/run/hwinfo")
+ $(safesource "/run/openslx/hwinfo")
}
-# Sets the VM's hostname to the original hostname prefixed with a fixed string and its ID
+# Sets the VM's hostname to the original hostname prefixed with a fixed string and its ID
set_virt_hostname() {
declare -rg HOSTNAME="virt${VM_ID}-$(hostname)"
writelog "\tVM Hostname:\t\t$HOSTNAME"
@@ -115,10 +115,10 @@ set_virt_mac() {
# If the variables in virtualization.conf is set, "TRUE" is assigned,
# "FALSE" otherwise.
check_optical_drives() {
- # TODO This should only handle exam mode here, maybe even have one function
- # that prepares all exam mode related stuff. Then create the TRUE/FALSE
- # variables somewhere in the vmware plugin, since it's specific to that
- # plugin.
+ # TODO This should not handle exam mode here (and special cases in
+ # 100 other places), maybe have one function that prepares all exam
+ # mode related stuff. Then create the TRUE/FALSE variables somewhere
+ # in the vmware plugin, since it's specific to that plugin.
FLOPPY0="FALSE"
CDROM0="FALSE"
CDROM1="FALSE"
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc
index 8b166806..9f18d0ec 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc
@@ -40,34 +40,67 @@ setup_dnbd3_proxy () {
}
setup_dnbd3 () {
+ local dnbd3_tmplog="${TMPDIR}/dnbd3fuse.log"
+ local dnbd3_diskfile=
+ setup_dnbd3_common
+
+ if isempty dnbd3_diskfile; then
+ slxlog "virt-dnbd3" "No dnbd3 server for ${SRC_IMG_RELATIVE} found, trying NFS/CIFS..." "$dnbd3_tmplog"
+ writelog "No working dnbd3 server found :-("
+ return 1
+ fi
+ VM_DISKFILE_RO="$dnbd3_diskfile"
+ return 0
+}
+
+setup_dnbd3_cow () {
+ local dnbd3_tmplog="${TMPDIR}/dnbd3fuse.log"
+ local dnbd3_diskfile=
+
+ mkdir "${TMPDIR}/cow"
+ setup_dnbd3_common -c "${TMPDIR}/cow" -C "${SLX_VMCHOOSER_BASE_URL//"/vmchooser/"/"/cow/"}" --upload-uuid "$DMSD_COW_SESSION" --cow-stats-file --merge
+
+ if isempty dnbd3_diskfile; then
+ slxlog "virt-dnbd3" "Failed to setup dnbd3-fuse with copy-on-write" "$dnbd3_tmplog"
+ writelog "Error setting up CoW"
+ cleanexit 1
+ fi
+ VM_DISKFILE_RW="$dnbd3_diskfile"
+}
+
+setup_dnbd3_common () {
# Mount path for images mounted with dnbd3-fuse
declare -rg DNBD3_MOUNT_POINT="${TMPDIR}/dnbd3fuse.mnt"
mkdir -p "${DNBD3_MOUNT_POINT}"
# start dnbd3-fuse in subshell
- local DNBD3_TMPLOG="${TMPDIR}/dnbd3fuse.log"
local DNBD3_EXITFLAG="${TMPDIR}/dnbd3exit$RANDOM"
local TIMEOUT VM_DISKFILE_REVISION
rm -f -- "${DNBD3_EXITFLAG}"
(
+ trap 'writelog "[dnbd3-fuse] Received TERM"; kill $dnbd3pid; exit' SIGTERM
+ trap 'writelog "[dnbd3-fuse] Received QUIT"; kill -SIGQUIT $dnbd3pid' SIGQUIT
startup="$( date +%s )"
while [ "$( date +%s )" -lt "$(( startup + 4 ))" ]; do
- dnbd3-fuse -f -o allow_other,max_readahead=262144 -h "${SLX_DNBD3_SERVERS}" -i "${SRC_IMG_RELATIVE}" "${DNBD3_MOUNT_POINT}" > "${DNBD3_TMPLOG}" 2>&1
+ dnbd3-fuse -f -o allow_other,max_readahead=262144 -h "${SLX_DNBD3_SERVERS}" -i "${SRC_IMG_RELATIVE}" "$@" "${DNBD3_MOUNT_POINT}" &> "${dnbd3_tmplog}" &
+ dnbd3pid=$!
+ wait "$dnbd3pid"
RET=$?
done
touch "${DNBD3_EXITFLAG}"
if [ "$RET" != "0" ]; then
writelog "dnbd3-fuse stopped working (Exit code $RET)"
- slxlog "virt-dnbd3-fuse" "dnbd3-fuse stopped/refused serving '${SRC_IMG_RELATIVE}' from '${SLX_DNBD3_SERVERS}' with error code: $RET" "${DNBD3_TMPLOG}"
+ slxlog "virt-dnbd3-fuse" "dnbd3-fuse stopped/refused serving '${SRC_IMG_RELATIVE}' from '${SLX_DNBD3_SERVERS}' with error code: $RET" "${dnbd3_tmplog}"
fi
) &
+ declare -rg DNBD3_PID=$!
# give it a bit of time
usleep 250000
# check if we have the image
for TIMEOUT in 0.5 1 1 1 1 2 OUT; do
if [ -r "${DNBD3_MOUNT_POINT}/img" ]; then
VM_DISKFILE_REVISION="$(grep -m 1 "^Revision:" "${DNBD3_MOUNT_POINT}/status" | cut -d" " -f2)"
- VM_DISKFILE_RO="${DNBD3_MOUNT_POINT}/img"
- writelog "DNBD3: ${SRC_IMG_RELATIVE} on ${VM_DISKFILE_RO} with rid ${VM_DISKFILE_REVISION}"
+ dnbd3_diskfile="${DNBD3_MOUNT_POINT}/img"
+ writelog "DNBD3: ${SRC_IMG_RELATIVE} on ${dnbd3_diskfile} with rid ${VM_DISKFILE_REVISION}"
add_cleanup "cleanup_dnbd3"
break
fi
@@ -76,11 +109,6 @@ setup_dnbd3 () {
fi
sleep "$TIMEOUT"
done
-
- if isempty VM_DISKFILE_RO; then
- slxlog "virt-dnbd3" "No dnbd3 server for ${SRC_IMG_RELATIVE} found, trying NFS/CIFS..." "$DNBD3_TMPLOG"
- writelog "No working dnbd3 server found :-("
- fi
}
setup_fallback() {
@@ -143,6 +171,9 @@ setup_image_access_default() {
writelog "\tCan't use dnbd3 as SRC_IMG_RELATIVE is not set"
elif isempty SLX_DNBD3_SERVERS || [ "x${SLX_VM_DNBD3}" != "xyes" ]; then
writelog "\tCan't use dnbd3 as no servers are given in config, or SLX_VM_DNBD3 is not set to yes"
+ elif [ -n "$DMSD_COW_SESSION" ]; then
+ writelog "Setting up DNBD3 CoW session"
+ setup_dnbd3_cow
elif setup_dnbd3_proxy; then
writelog "\tImage setup done."
elif ! check_dep dnbd3-fuse fusermount; then
@@ -152,7 +183,7 @@ setup_image_access_default() {
writelog "Trying image access via DNBD3..."
setup_dnbd3
fi
-
+
# VM_DISKFILE_RO will be empty if dnbd3 is not used or failed to connect.
if isempty VM_DISKFILE_RO; then
# try to fallback to access the image via NFS/CIFS filesystem
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
index 3bfa8bb5..081c2e79 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc
@@ -66,7 +66,7 @@ $BODY"
TITLE="ERROR"
fi
# Zenity should yield the nicest result
- # TODO the title is only set as the window name,
+ # Note: the title is only set as the window name,
# which cannot be seen without a window manager
zenity --error --title "$TITLE" --text "$BODY"
local RET=$?
@@ -151,7 +151,7 @@ cleanexit() {
done
fi
- # kill potential remaining background jobs
+ writelog "Killing remaining background jobs"
kill $(jobs -p)
# If we're not in debug mode AND got a clean exit code, remove all temporary files
@@ -276,7 +276,7 @@ safesource() {
while [ $# -gt 0 ]; do
# sanitze filename just to be sure as it is part of the eval coming later
# alphanumeric and - _ . should be enough for common file naming scheme
- if [[ ! "$1" =~ ^[a-zA-Z0-9./_-]+$ ]]; then
+ if [[ ! "$1" =~ ^[a-zA-Z0-9./_@-]+$ ]]; then
writelog "'$1' is a weird filename to source! Ignoring."
return 1
fi
@@ -330,14 +330,17 @@ call_post_source() {
# Helper called after sourcing the file via safesource. It just calls the
# functions in the same order they were registered.
run_post_source() {
- [ $# -ne 1 ] && writelog "'${FUNCNAME[0]}' expects one argument only! $# given." && return 1
+ if [ $# -ne 1 ]; then
+ writelog "'${FUNCNAME[0]}' expects one argument only! $# given."
+ EXIT_REASON="Interner Fehler in run_post_source" cleanexit 1
+ fi
local TASK RET
"$DEBUG" && writelog "Running post-source hooks for ${1}..."
for TASK in ${RUN_POST_SOURCE["${1}"]}; do
# sanity checks
if ! is_function "$TASK"; then
writelog "\tRegistered function '$TASK' is not a function!"
- return 1 # TODO maybe even cleanexit here as this seems very bad...
+ EXIT_REASON="Konnte safesource-hook nicht ausführen" cleanexit 1
fi
"$DEBUG" && writelog " - ${TASK}"
"${TASK}"
@@ -498,22 +501,6 @@ check_dep() {
isset ONEOF && return 1 || return 0
}
-# TODO: This is only used once in the whole script:
-# to cleanup the os string stored in the xml
-# Since the rework of this script, the os strings come from
-# the satellite server which already gives us a sanitized string
-# thus this function might not be needed anymore, as calling it on
-# new gen os strings effectively does nothing.
-# Removes any non-alphanumerical and non-hyphen chars
-# from the given parameters.
-clean_string() {
- if [ "$#" -ge 1 ]; then
- echo "$@" | tr 'A-Z' 'a-z' | tr -d -c 'a-z0-9\-'
- else
- tr 'A-Z' 'a-z' | tr -d -c 'a-z0-9\-'
- fi
-}
-
# Helper to detect given cpu flags.
# If more than one flag is given, assume that matching
# any of them is sufficient.
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_firewall.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_firewall.inc
index 92ff2186..097e9660 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_firewall.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_firewall.inc
@@ -22,6 +22,5 @@ if check_dep slxfwtool; then
reg_feature_handler "firewall" "setup_firewall"
else
writelog "Could not find 'slxfwtool' in PATH: $PATH. Netrules firewall will not work!"
- error_user "Fehler" "Keine Unterstützung von veranstaltungspezifische Firewall-Regeln!"
- # TODO handle
+ error_user "Fehler" "Keine Unterstützung für veranstaltungspezifische Firewall-Regeln!"
fi
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_network_shares.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_network_shares.inc
deleted file mode 100644
index 8809b218..00000000
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_network_shares.inc
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-# TODO this currently is not used.
-# This should be continued when we have a clear idea
-# how we will embed network shares in VMs
-set_network_shares() {
-
- # Add rw share for home dir
- HOME_SHARE_PATH="${HOME}/PERSISTENT"
- HOME_SHARE_NAME="home"
-
- # Add common share
- COMMON_SHARE_PATH="${HOME}/SHARE"
- COMMON_SHARE_NAME="share"
-}
-
-reg_feature_handler "netshares" "set_network_shares"
-
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_sound.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_sound.inc
index 7313ccb6..cb85f7c5 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_sound.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_sound.inc
@@ -6,7 +6,7 @@
## Functions ##
setup_sound() {
unset VOL
- if $(safesource "/run/hwinfo") ; then
+ if $(safesource "/run/openslx/hwinfo") ; then
# On startup, the volume of Master, PCM, Speaker, etc. will be set to 100%
# Some hardware with builtin speakers might be a bit too loud then, so you can
# define an exception table here. Array key is "Manufacturer//Model"
@@ -64,8 +64,9 @@ set_sound_alsa() {
writelog --quiet "\tSound card count: $SOUND_CARD_COUNT"
# Adjust sound volume (playback)... Random mixer names we have encountered during testing
- # TODO instead of trying to set volume blindly, why not use 'amixer scontrols' to find
+ # Instead of trying to set volume blindly, why not use 'amixer scontrols' to find
# which mixer control exists and set these only?
+ # # ^ because lazy
writelog --quiet "Setting up volume to '$VOL' via amixer..."
amixer -q -c "$SOUND_CARD_INDEX" -s <<-EOF
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_virtual_floppy.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_virtual_floppy.inc
index 3b1d9f18..61c98b78 100644
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_virtual_floppy.inc
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt.d/setup_virtual_floppy.inc
@@ -116,6 +116,13 @@ setup_virtual_floppy() {
# Enable openslx.exe debug output if we're running in debug mode
local debug=
$DEBUG && debug=1
+ local editmode=0
+ if is_on "$VMCHOOSER_ADMIN_MODE"; then
+ editmode=1
+ if [ -n "$DMSD_COW_SESSION" ]; then
+ resolution=
+ fi
+ fi
cat > "${FLOPPYDIR}/openslx.ini" <<-EOF
[openslx]
@@ -133,6 +140,7 @@ setup_virtual_floppy() {
noHomeWarn=${SHARE_NO_HOME_WARN}
runMode=${SLX_RUNMODE_MODULE}
debug=${debug}
+ persistentMode=${editmode}
[remap]
documents=${SHARE_DOCUMENTS}
diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt b/core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt
index ca881f29..f2fa4a89 100755
--- a/core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt
+++ b/core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt
@@ -182,13 +182,60 @@ main() {
run_hooks "pre-exec" "$PLUGIN_ID" "$IMGUUID"
+ # Launch COWGUI in CoW-Edit-Mode
+ local cowpid cowurl vmpidfile
+ cowpid=
+ vmpidfile=
+ if [ -n "$DMSD_COW_SESSION" ]; then
+ vmpidfile="$( mktemp -p "/run/user/$( id -u )" )"
+ cowurl="${SLX_VMCHOOSER_BASE_URL//"/vmchooser/"/"/cow/"}"
+ (
+ cntr=0
+ while true; do
+ writelog "Launching CoW-GUI"
+ cowgui --sessionid "$DMSD_COW_SESSION" --url "$cowurl" --pid "$DNBD3_PID" --status "$TMPDIR/cow/status" && break
+ # Unclean exit, let's see if it's worth relaunching
+ state="$( curl -m 3 -sS -L "$cowurl/status/$DMSD_COW_SESSION" | jq -r .state )"
+ [ -z "$state" ] && break
+ [ "$state" = "PROCESSING" ] && break
+ [ "$state" = "ERROR" ] && break
+ [ "$state" = "COMPLETELY_DONE" ] && break
+ (( cntr++ > 10 )) && break
+ done
+ writelog "Final cow state: $( curl -m 3 -sS -L "$cowurl/status/$DMSD_COW_SESSION" )"
+ [ -s "$vmpidfile" ] && kill "$( cat "$vmpidfile" )"
+ ) &
+ cowpid=$!
+ fi
+
writelog "VM command: ${VIRTCMD} ${VIRTCMDOPTS[*]}"
- # This will start the VM (no eval needed!)
+ # Prepare short config dir, needed because libvirt is stupid and likes
+ # to create very long UNIX socket names and then chokes on them.
+ cd="$( mktemp -d "/tmp/lvXXX" )"
+ if [ -z "$cd" ]; then
+ cd="/tmp/lv${UID}$(( RANDOM % 10000 ))"
+ rm -rf -- "$cd"
+ mkdir -p "$cd"
+ fi
+ # This will start the VM
writelog "---------- BEGIN VM command output ----------"
- local retval
- "${VIRTCMD}" "${VIRTCMDOPTS[@]}" &>> "${LOGFILE}"
+ local retval vmpid
+ XDG_CONFIG_HOME="$cd" "${VIRTCMD}" "${VIRTCMDOPTS[@]}" &>> "${LOGFILE}" &
+ vmpid=$!
+ [ -n "$vmpidfile" ] && echo "$vmpid" > "$vmpidfile"
+ wait "$vmpid"
retval=${?}
- writelog "---------- END VM command output ----------"
+ writelog "------- END VM command output ($retval) --------"
+
+ if [ -n "$DNBD3_PID" ]; then
+ writelog "Killing dnbd3-fuse"
+ kill "$DNBD3_PID"
+ fi
+ # If cow, wait for GUI
+ if [ -n "$cowpid" ]; then
+ writelog "Waiting for CoW-GUI"
+ wait "$cowpid"
+ fi
run_hooks "post-exec" "$PLUGIN_ID" "$IMGUUID"