diff options
Diffstat (limited to 'core/modules/run-virt')
15 files changed, 115 insertions, 156 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 Binary files differindex 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 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/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 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..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 dfebebe7..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 @@ -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" --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 @@ -201,25 +202,40 @@ 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 writelog "VM command: ${VIRTCMD} ${VIRTCMDOPTS[*]}" + # 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 vmpid - "${VIRTCMD}" "${VIRTCMDOPTS[@]}" &>> "${LOGFILE}" & + 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) --------" - [ -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/run-virt/winres/src/winres.c b/core/modules/run-virt/winres/src/winres.c index e8e03947..1011e1e8 100644 --- a/core/modules/run-virt/winres/src/winres.c +++ b/core/modules/run-virt/winres/src/winres.c @@ -74,6 +74,7 @@ static BOOL _passCreds = FALSE; static BOOL _noHomeWarn = FALSE; static BOOL _deletedCredentials = FALSE; static BOOL _scriptDone = TRUE, _mountDone = TRUE; // Will be set to false if we actually wait for something... +static BOOL _persistentMode = FALSE; // VM being edited, don't do any changes to system (shortcuts, regedit, ) static char *shost = NULL, *sport = NULL, *suser = NULL, *spass = NULL; #define SCRIPTFILELEN (50) @@ -106,6 +107,9 @@ static HRESULT createFolderShortcut(wchar_t* sTargetfile, wchar_t* sLinkfile, wc static void alog(const char *fmt, ...) { + if (_persistentMode) + return; + FILE *f = _wfopen(logFile, L"a+"); if (f == NULL) return; time_t raw = time(NULL); @@ -124,6 +128,9 @@ static void alog(const char *fmt, ...) static void wlog(const wchar_t *fmt, ...) { + if (_persistentMode) + return; + wchar_t wbuffer[1000]; char abuffer[1000]; va_list args; @@ -431,6 +438,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine if (hUser32 == NULL) { alog("Cannot load user32.dll"); } + if (GetPrivateProfileIntA("openslx", "persistentMode", 0, SETTINGS_FILE) != 0) { + _persistentMode = TRUE; + } winVer.dwOSVersionInfoSize = sizeof(winVer); BOOL retVer = GetVersionEx(&winVer); CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); @@ -918,6 +928,9 @@ static int setResVMware(struct resolution *res, int nres) static int optimizeForRemote() { + if (_persistentMode) + return; + LONG ret; HKEY hKey; @@ -1499,6 +1512,9 @@ static uint8_t* hex2bin(char *szHexString) static HRESULT createFolderShortcut(wchar_t* targetDir, wchar_t* linkFile, wchar_t* comment) { + if (_persistentMode) + return S_OK; + HRESULT hRes; /* Returned COM result code */ IShellLink* pShellLink; /* IShellLink object pointer */ IPersistFile* pPersistFile; /* IPersistFile object pointer */ @@ -1551,6 +1567,9 @@ static HRESULT createFolderShortcut(wchar_t* targetDir, wchar_t* linkFile, wchar static BOOL patchRegPath(BOOL *patchOk, BOOL *anyMapped, HKEY hKey, wchar_t *letter, wchar_t *value, ...) { + if (_persistentMode) + return; + wchar_t *folder = NULL; wchar_t first[MAX_PATH] = {0}; wchar_t path[MAX_PATH]; @@ -1612,6 +1631,9 @@ typedef BOOL (WINAPI *P32TYPE)(HANDLE, PROCESSENTRY32W*); static void patchUserPaths(wchar_t *letter) { + if (_persistentMode) + return; + LONG ret; HKEY hKey; BOOL patchOk = TRUE; |