summaryrefslogtreecommitdiffstats
path: root/core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt
diff options
context:
space:
mode:
authorSimon Rettberg2024-05-02 15:37:46 +0200
committerSimon Rettberg2024-05-02 15:37:46 +0200
commitdc2786ff4d4cfc3a9a780451ef2a559e296c05a3 (patch)
tree97b343cc6fe5bf08adee593e7539193172bd22d2 /core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt
parent[pam-bwidm] Remove x prefixes (diff)
downloadmltk-dc2786ff4d4cfc3a9a780451ef2a559e296c05a3.tar.gz
mltk-dc2786ff4d4cfc3a9a780451ef2a559e296c05a3.tar.xz
mltk-dc2786ff4d4cfc3a9a780451ef2a559e296c05a3.zip
[run-virt] Add support for CoW-Mode
Diffstat (limited to 'core/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt')
-rwxr-xr-xcore/modules/run-virt/data/opt/openslx/vmchooser/vmchooser-run_virt37
1 files changed, 34 insertions, 3 deletions
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."