summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2024-05-08 18:45:20 +0200
committerSimon Rettberg2024-05-08 18:45:20 +0200
commitb57f124784e5bcf4b025a27e20392bafc1ac0546 (patch)
tree05ac2a718a265b9554b4441c8a57f9c041db49d3
parent[lightdm-greeter-bwlp/vmchooser2] Handle cow token (diff)
downloadmltk-b57f124784e5bcf4b025a27e20392bafc1ac0546.tar.gz
mltk-b57f124784e5bcf4b025a27e20392bafc1ac0546.tar.xz
mltk-b57f124784e5bcf4b025a27e20392bafc1ac0546.zip
[run-virt/vmchooser2] Initial support for CoW-sessions
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/download_vm_metadata.inc5
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc6
-rw-r--r--core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/vmchooser_runvirt_functions.inc4
-rwxr-xr-xcore/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt18
-rwxr-xr-xcore/modules/vmchooser2/data/opt/openslx/bin/vmchooser3
5 files changed, 24 insertions, 12 deletions
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 b18b8a66..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
@@ -79,7 +79,7 @@ download_metadata_default() {
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"
+ argx="?cow-user=$cow_token&cow-type=$VMCHOOSER_ADMIN_TYPE"
fi
# Try new unified .tar.gz way
@@ -102,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/setup_image_access.inc b/core/modules/run-virt/data/opt/openslx/vmchooser/run-virt-includes/setup_image_access.inc
index 9be00cfa..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
@@ -58,7 +58,7 @@ setup_dnbd3_cow () {
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
+ 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"
@@ -77,8 +77,8 @@ setup_dnbd3_common () {
local TIMEOUT VM_DISKFILE_REVISION
rm -f -- "${DNBD3_EXITFLAG}"
(
- trap 'kill $dnbd3pid; exit' SIGTERM
- trap 'kill -SIGQUIT $dnbd3pid' SIGQUIT
+ 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}" &
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..80403356 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
@@ -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
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 dfebebe7..21f43301 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
@@ -192,7 +192,8 @@ main() {
(
cntr=0
while true; do
- cowgui --session "$DMSD_COW_SESSION" --url "$cowurl" --pid "$DNBD3_PID" && break
+ writelog "Launching CoW-GUI"
+ cowgui --sessionid "$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
@@ -201,7 +202,8 @@ main() {
[ "$state" = "COMPLETELY_DONE" ] && break
(( cntr++ > 10 )) && break
done
- [ -n "$vmpidfile" ] && kill "$( cat "$vmpidfile" )"
+ writelog "Final cow state: $( curl -m 3 -sS -L "$cowurl/status/$DMSD_COW_SESSION" )"
+ [ -s "$vmpidfile" ] && kill "$( cat "$vmpidfile" )"
) &
cowpid=$!
fi
@@ -215,11 +217,17 @@ main() {
[ -n "$vmpidfile" ] && echo "$vmpid" > "$vmpidfile"
wait "$vmpid"
retval=${?}
- writelog "---------- END VM command output ----------"
+ writelog "------- END VM command output ($retval) --------"
- [ -n "$DNBD3_PID" ] && kill "$DNBD3_PID"
+ if [ -n "$DNBD3_PID" ]; then
+ writelog "Killing dnbd3-fuse"
+ kill "$DNBD3_PID"
+ fi
# If cow, wait for GUI
- [ -n "$cowpid" ] && wait "$cowpid"
+ if [ -n "$cowpid" ]; then
+ writelog "Waiting for CoW-GUI"
+ wait "$cowpid"
+ fi
run_hooks "post-exec" "$PLUGIN_ID" "$IMGUUID"
diff --git a/core/modules/vmchooser2/data/opt/openslx/bin/vmchooser b/core/modules/vmchooser2/data/opt/openslx/bin/vmchooser
index d0555bfe..4889b5de 100755
--- a/core/modules/vmchooser2/data/opt/openslx/bin/vmchooser
+++ b/core/modules/vmchooser2/data/opt/openslx/bin/vmchooser
@@ -94,8 +94,9 @@ if [ -n "$SLX_SCREEN_SAVER_TIMEOUT" ]; then
fi
if [ -s "/run/user/$(id -u)/cow-token" ]; then
- EXTRA+=( "--cow-token" "/run/user/$(id -u)/cow-token" )
+ EXTRA+=( "--cow-token" "$( cat "/run/user/$(id -u)/cow-token" )" )
fi
+set +x
exec vmchooser.real "$@" --url "$URL" --fullscreen --tab "$TAB" --start-uuid "$SLX_EXAM_START" "${EXTRA[@]}"