summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/modules/hardware-stats/data/opt/openslx/hardware-stats/collect_hw_info_json.py4
-rwxr-xr-xcore/modules/hardware-stats/data/opt/openslx/scripts/systemd-gather_hw_info30
-rwxr-xr-xcore/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm20
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/download_vm_metadata.inc42
-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/setup_image_access.inc53
-rwxr-xr-xcore/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt37
7 files changed, 146 insertions, 59 deletions
diff --git a/core/modules/hardware-stats/data/opt/openslx/hardware-stats/collect_hw_info_json.py b/core/modules/hardware-stats/data/opt/openslx/hardware-stats/collect_hw_info_json.py
index f110a792..3f0002b2 100644
--- a/core/modules/hardware-stats/data/opt/openslx/hardware-stats/collect_hw_info_json.py
+++ b/core/modules/hardware-stats/data/opt/openslx/hardware-stats/collect_hw_info_json.py
@@ -97,9 +97,9 @@ def file_get_contents(path, strip_lf = True):
s = s[:-1]
return s
except FileNotFoundError:
- print("File not found: " + path)
+ eprint("File not found: " + path)
except IOError:
- print("IO Error reading file " + path)
+ eprint("IO Error reading file " + path)
return ""
# Get CD/DVD Information
diff --git a/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-gather_hw_info b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-gather_hw_info
index cdeb6d63..ae35b33a 100755
--- a/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-gather_hw_info
+++ b/core/modules/hardware-stats/data/opt/openslx/scripts/systemd-gather_hw_info
@@ -60,7 +60,7 @@ slxfdisk() {
MAC="${SLX_PXE_MAC}"
if [ -z "$MAC" ]; then
# get MAC from sysfs
- MAC="$(cat /sys/class/net/${SLX_PXE_NETIF:-br0}/address)"
+ MAC="$( cat "/sys/class/net/${SLX_PXE_NETIF:-br0}/address" )"
fi
if [ -z "$MAC" ]; then
BOOTIF="$(grep -Po '(?<=BOOTIF=)[0-9a-f\-:]+' /proc/cmdline)"
@@ -89,7 +89,7 @@ CPUSOCKETS=$(grep '^physical id' /proc/cpuinfo | sort -u | wc -l)
# Fallback 1...
if [ -z "$CPUCORES" ] || [ "$CPUCORES" = "0" ]; then
for c in $(dmidecode -t 4 | grep 'Core Enabled' | awk -F ':' '{print $2}'); do
- CPUCORES=$(( $CPUCORES + $c ))
+ CPUCORES=$(( CPUCORES + c ))
done
fi
# Fallback 2...
@@ -108,12 +108,12 @@ echo "$CPUMODEL"
# 4) RAM
#
RAM=$(grep -m1 '^MemTotal:' /proc/meminfo | awk '{print $2}')
-RAM=$(( $RAM / 1024 ))
+RAM=$(( RAM / 1024 ))
if [ -z "$RAM" ] || [ "$RAM" -lt 500 ]; then
# Fallback to dmidecode
RAM=0
for c in $(dmidecode -t 17 | grep -o 'Size:.*MB$' | awk '{print $2}'); do
- RAM=$(( $RAM + $c ))
+ RAM=$(( RAM + c ))
done
fi
echo "$RAM MB RAM"
@@ -173,7 +173,7 @@ if ! slx-tools fs_path_isvolatile "/tmp/virt" ; then
[ "$val" -gt "$ID44" ] && ID44=$val
done
# blockdev reports bytes, convert to MB
- ID44=$(( $ID44 / 1058576 )) # we'd rather underreport
+ ID44=$(( ID44 / 1058576 )) # we'd rather underreport
fi
fi
fi
@@ -183,13 +183,15 @@ echo "Scratch space: $ID44 MB"
# 7) check smart values
#
FDISK=$(mktemp)
-declare -a DISKS
+declare -A DISKS
shopt -s extglob
for disk in /dev/disk/by-path/!(*-part*|*-usb-*); do
[ -L "$disk" ] || continue
+ [ -z "${DISKS["$disk"]}" ] || continue
disk="$( readlink -f "$disk" )"
- DISKS+=("$disk")
- slxfdisk -l "$disk" | sed -r 's/\s+[0-9]+,[0-9]+,[0-9]+/ /g;/^\// s/\s[0-9]+\.?[0-9]+[MGT]\s/ /;s/^Units: /Units =foo= /' | awk '{if ($1 !~ /^[0-9]+$/ || $5 ~ /^[0-9a-f]{4}/) { print $0 } else { $5 = "0700 " $5; print $0 }}' # Work around busybox YET AGAIN changing something in an incompatible way
+ DISKS["$disk"]="$disk"
+ slxfdisk -l "$disk" | sed -r 's/\s+[0-9]+,[0-9]+,[0-9]+/ /g;/^\// s/\s[0-9]+\.?[0-9]+[MGT]\s/ /;s/^Units: /Units =foo= /' \
+ | awk '{if ($1 !~ /^[0-9]+$/ || $5 ~ /^[0-9a-f]{4}/) { print $0 } else { $5 = "0700 " $5; print $0 }}' # Work around busybox YET AGAIN changing something in an incompatible way
done > "$FDISK"
shopt -u extglob
[ -z "$SLX_SMARTCTL_MIN_REALLOC" ] && SLX_SMARTCTL_MIN_REALLOC=0
@@ -207,20 +209,20 @@ if which smartctl; then
cat "$FILE" >> "$ALLSMART"
# parse
OVERALL=$(grep -o "test result: .*$" "$FILE" | cut -c 14-)
- [ "x$OVERALL" = "xPASSED" ] && OVERALL=""
+ [ "$OVERALL" = "PASSED" ] && OVERALL=""
REALLOC=$(grep "^ *5 " "$FILE" | awk '{print $8}')
PENDING=$(grep "^ *197 " "$FILE" | awk '{print $8}')
SPINRETRY_VAL=$(grep "^ *10 " "$FILE" | awk '{print $4}')
SPINRETRY_THR=$(grep "^ *10 " "$FILE" | awk '{print $6}')
- [ -n "$OVERALL" ] && BADSECTORS=$(( $BADSECTORS + 100 ))
+ [ -n "$OVERALL" ] && BADSECTORS=$(( BADSECTORS + 100 ))
if [ -n "$REALLOC" ] && [ "$REALLOC" -gt "0" ]; then
- BADSECTORS=$(( $BADSECTORS + $REALLOC ))
+ BADSECTORS=$(( BADSECTORS + REALLOC ))
fi
if [ -n "$PENDING" ] && [ "$PENDING" -gt "5" ]; then
- BADSECTORS=$(( $BADSECTORS + $PENDING ))
+ BADSECTORS=$(( BADSECTORS + PENDING ))
fi
if [ -n "$SPINRETRY_VAL" ] && [ "$SPINRETRY_VAL" -le "$SPINRETRY_THR" ]; then
- BADSECTORS=$(( $BADSECTORS + 100 ))
+ BADSECTORS=$(( BADSECTORS + 100 ))
fi
done
rm -f -- "$FILE"
@@ -231,7 +233,7 @@ echo "SMART: $OVERALL - $REALLOC reallocated, $PENDING pending"
# 8) Read system model and manufacturer
#
dmidec() {
- local RETVAL=$(dmidecode "$@" 2>/dev/null | grep -v '^#' | grep -v '^Invalid' | sed 's/\s\s*/ /g;s/^ //;s/ $//')
+ local RETVAL=$( dmidecode "$@" 2>/dev/null | grep -v '^#' | grep -v '^Invalid' | sed 's/\s\s*/ /g;s/^ //;s/ $//' )
case "$RETVAL" in
""|*"Product Name"*|*"be filled"*|"unknown"|*"efault string"*|*"efault String"*|*"product name"*|*"anufacturer"*|*"ystem model"*)
RETVAL="Unknown"
diff --git a/core/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm b/core/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm
index 0d3ccc1e..63787309 100755
--- a/core/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm
+++ b/core/modules/pam-bwidm/data/opt/openslx/scripts/pam_bwidm
@@ -11,14 +11,14 @@ export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/o
# grab the password from stdin asap, since there is no guarantee some tool just reads it
unset USER_PASSWORD
-if [ "x$PAM_TYPE" = "xauth" ]; then
+if [ "$PAM_TYPE" = "auth" ]; then
read -r USER_PASSWORD > /dev/null 2>&1
readonly USER_PASSWORD
[ -z "$USER_PASSWORD" ] && echo "No password given." && exit 1
fi
# sanity check on PAM_USER: contains '@'?
-if [ -z "$PAM_USER" ] || [ "x${PAM_USER}" = "x${PAM_USER%@*}" ]; then
+if [ -z "$PAM_USER" ] || [ "${PAM_USER}" = "${PAM_USER%@*}" ]; then
# no @ contained, invalid username, abort
#echo "Invalid username '$PAM_USER'. Aborting."
exit 1
@@ -64,9 +64,9 @@ readonly IDP_QUERY_URL mode
# check if we are allowed to run
. /opt/openslx/config
-if [ "x${SLX_BWIDM_AUTH}" = "xyes" ]; then
+if [ "${SLX_BWIDM_AUTH}" = "yes" ]; then
: # Allow everything
-elif [ "x${SLX_BWIDM_AUTH}" = "xselective" ]; then
+elif [ "${SLX_BWIDM_AUTH}" = "selective" ]; then
if [ -z "${SLX_BWIDM_ORGS}" ]; then
echo "bwIDM selective mode with empty org list - exiting"
exit 1
@@ -83,10 +83,10 @@ readonly USER_ORGANISATION="${PAM_USER#*@}"
[ -z "$USER_USERNAME" ] && echo "Could not parse user from given login: ${PAM_USER}. Aborting." && exit 1
# Check if we're in selective mode and if so, whether the user's organization is whitelisted
-if [ "x${SLX_BWIDM_AUTH}" = "xselective" ]; then
+if [ "${SLX_BWIDM_AUTH}" = "selective" ]; then
FOUND=
for org in ${SLX_BWIDM_ORGS}; do
- if [ "x$org" = "x$USER_ORGANISATION" ]; then
+ if [ "$org" = "$USER_ORGANISATION" ]; then
FOUND=ya
break
fi
@@ -109,7 +109,7 @@ if [ "$mode" = "ecp" ]; then
exit 7
fi
idpret="$(curl --retry 3 --retry-connrefused --retry-delay 1 --retry-max-time 15 -w "%{http_code}" -o "${IDP_QUERY_CACHE}" --connect-timeout 2 --max-time 6 "$IDP_QUERY_URL")"
- if [ "${#idpret}" != 3 ] || [ "x${idpret:0:1}" != "x2" ]; then
+ if [ "${#idpret}" != 3 ] || [ "${idpret:0:1}" != "2" ]; then
echo "Could not download the list of identity providers from '$IDP_QUERY_URL'. Aborting."
rm -f -- "$IDP_QUERY_CACHE"
exit 7
@@ -267,7 +267,7 @@ write_user_data() {
}
# now the pam-type specific part starts
-if [ "x$PAM_TYPE" = "xauth" ]; then
+if [ "$PAM_TYPE" = "auth" ]; then
##### Browser
if [ "$mode" = "browser" ]; then
token="${USER_PASSWORD#shib=}"
@@ -321,7 +321,7 @@ if [ "x$PAM_TYPE" = "xauth" ]; then
exit 1
fi
-if [ "x$PAM_TYPE" = "xaccount" ]; then
+if [ "$PAM_TYPE" = "account" ]; then
# the sanity checks we did before reacting to PAM_TYPE is enough to validate
# the given username as a valid bwIDM username
# ('@' contained and IdP found in the idp list fetched from the masterserver)
@@ -337,7 +337,7 @@ exit 1
# #
## main script
mainret=$?
-if [ "x$mainret" = "x7" ]; then
+if [ "$mainret" = "7" ]; then
# exit code 7 is our marker to push the logfile to the sat
slxlog --delete "pam-bwidm" "Internal error during bwIDM authentication" "${LOGFILE}"
exit 1
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..b18b8a66 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"
+ 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
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/setup_image_access.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc
index 8b166806..9be00cfa 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 -L "${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 'kill $dnbd3pid; exit' SIGTERM
+ trap '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/vmchooser-run_virt b/core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt
index ca881f29..dfebebe7 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,14 +182,45 @@ 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
+ cowgui --session "$DMSD_COW_SESSION" --url "$cowurl" --pid "$DNBD3_PID" && 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
+ [ -n "$vmpidfile" ] && kill "$( cat "$vmpidfile" )"
+ ) &
+ cowpid=$!
+ fi
+
writelog "VM command: ${VIRTCMD} ${VIRTCMDOPTS[*]}"
- # This will start the VM (no eval needed!)
+ # This will start the VM
writelog "---------- BEGIN VM command output ----------"
- local retval
- "${VIRTCMD}" "${VIRTCMDOPTS[@]}" &>> "${LOGFILE}"
+ local retval vmpid
+ "${VIRTCMD}" "${VIRTCMDOPTS[@]}" &>> "${LOGFILE}" &
+ vmpid=$!
+ [ -n "$vmpidfile" ] && echo "$vmpid" > "$vmpidfile"
+ wait "$vmpid"
retval=${?}
writelog "---------- END VM command output ----------"
+ [ -n "$DNBD3_PID" ] && kill "$DNBD3_PID"
+ # If cow, wait for GUI
+ [ -n "$cowpid" ] && wait "$cowpid"
+
run_hooks "post-exec" "$PLUGIN_ID" "$IMGUUID"
writelog "Virtualizer exited with '$retval'. Bye."