diff options
Diffstat (limited to 'remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt')
-rwxr-xr-x | remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt index d93bcd51..231ef6fe 100755 --- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt +++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt @@ -139,25 +139,25 @@ filecheck () ################################################################################ ## Added for persistent support. -diskmode='nonpersistent' && \ +diskmode='nonpersistent' if [[ "$(grep --extended-regexp \ '< *short_description *param=".+ --persistent--"' "$1")" ]]; then - diskmode='persistent' && \ - imageFilePath="$(grep -io '<image_name param=.*"' "$1" \ - | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }')" && \ + diskmode='persistent' + imageFilePath="$(grep -io '<image_path param=.*"' "$1" | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }')" + [ -z "$imageFilePath" ] && imageFilePath="$(grep -io '<image_name param=.*"' "$1" | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }')" originalXMLFilePath="$(grep -io '<original_xml_file_path param=.*"' "$1" \ - | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }')" && \ + | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }')" originalImageFileName="$(grep -io '<image_name param=.*"' \ "$originalXMLFilePath" | sed -e "s/&.*;/; /g" | awk -F '"' \ - '{ print $2 }')" && \ + '{ print $2 }')" originalVMDKFilePath="$(dirname \ - "$originalXMLFilePath")/${originalImageFileName}" && \ + "$originalXMLFilePath")/${originalImageFileName}" # Added to workaround path prefix coming from temporary generated xml file # by vmchooser. if [[ "$(grep --extended-regexp '^/tmp/tmp\.[^\/]+/' <<< \ "$imageFilePath")" ]]; then imageFilePath=$(sed -r 's/^\/?tmp\/[^\/]+\///g' \ - <<< "$imageFilePath") && \ + <<< "$imageFilePath") sed -ir \ "s/(<image_name param=\")[^\"]*(\")/\\1$(sed -e \ 's/\\/\\\\/g' -e 's/\//\\\//g' -e \ @@ -236,7 +236,9 @@ writelog "Enable 3D:\t\t${enable3d}" writelog "VM config:" # Name of the virt image -imgname=$(grep -io '<image_name param=.*"' "${xmlfile}" | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }') +imgname=$(grep -io '<image_path param=.*"' "${xmlfile}" | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }') +imgrelpath=$(grep -io '<image_name param=.*"' "${xmlfile}" | sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }') +[ -z "$imgname" ] && imgname="${imgrelpath}" ## Added for persistent support. if [[ "$userBranchFilePath" ]]; then @@ -244,7 +246,7 @@ if [[ "$userBranchFilePath" ]]; then fi ## -# Imagename /w full path +# Imagename w/ full path if echo "${imgname}" | grep -q '^/'; then imgpath="$(dirname "${imgname}")" imgname="$(basename "${imgname}")" @@ -345,8 +347,6 @@ writelog "\tVM short name:\t\t$vm_shortname" ### Declaration of default variables ############################################################################### -# VM-ID static (00) -VM_ID="00" # take last two digits of current pid... VM_ID=$(expr substr $$ $(expr ${#$} - 1) 2) @@ -454,7 +454,7 @@ QUEUE="STANDARD" # This has to match the queue you configured in your VM USER="$(whoami)" SPOOLDIR= ### Disabled: 100megs is not enough, some jobs are HUGE, try to use temp which should be on disk -## Try using users tmpfs home first, as it gets wiped on logout +## Try using user's tmpfs home first, as it gets wiped on logout #if [ -n "${HOME}" ] && [ -w "${HOME}" ]; then # SPOOLDIR="${HOME}/.spool" # mkdir -p "${SPOOLDIR}/${QUEUE}" @@ -467,6 +467,7 @@ if [ -z "${SPOOLDIR}" ] || [ ! -w "${SPOOLDIR}/${QUEUE}" ]; then slxlog "virt-spooldir" "Could not create spool directory ($SPOOLDIR) for $USER - printing will not work!" # TODO: Warn user fi + chmod 0700 "${SPOOLDIR}/${QUEUE}" fi # Start the lpdaemon listening on the given port @@ -496,7 +497,7 @@ if [ -n "$SLX_DNBD3_SERVERS" -o -n "$SLX_DNBD3_PRIO_SERVERS" ] && [ "x$SLX_VM_DN # Shuffle server list [ -n "$SLX_DNBD3_SERVERS" ] && TMP_SERVERS=$(for SRV in $SLX_DNBD3_SERVERS; do echo "$RANDOM $SRV"; done | sort -u | sed -r 's/^[0-9]+ //') for SRV in $SLX_DNBD3_PRIO_SERVERS $TMP_SERVERS; do - dnbd3=$(dnbd3-client -h "$SRV" -i "${vmpath#/mnt/vmstore/}" -r 0) + dnbd3=$(dnbd3-client -h "$SRV" -i "${imgrelpath}" -r 0) RET=$? if [ "$RET" = "0" ]; then vm_revision=$(cat "/sys/block/${dnbd3#/dev/}/net/rid") @@ -509,7 +510,7 @@ if [ -n "$SLX_DNBD3_SERVERS" -o -n "$SLX_DNBD3_PRIO_SERVERS" ] && [ "x$SLX_VM_DN usleep 200000 done if [ -z "$vm_diskfile" ]; then - slxlog "virt-dnbd3" "No dnbd3 server for ${vmpath#/mnt/vmstore/} found ($SLX_DNBD3_PRIO_SERVERS $TMP_SERVERS $dnbd3error), trying NFS..." + slxlog "virt-dnbd3" "No dnbd3 server for ${imgrelpath} found ($SLX_DNBD3_PRIO_SERVERS $TMP_SERVERS $dnbd3error), trying NFS/CIFS..." writelog "No working dnbd3 server found :-(" fi else @@ -519,6 +520,7 @@ else writelog "Won't use dnbd3 as no servers are given in config" fi +# $vm_diskfile will be empty if dnbd3 is not used or failed. Let's try to fall back to NFS/CIFS via file system if [ -z "$vm_diskfile" ]; then new_vmpath=$(ls "${vmpath}.r"* | grep -E -o '\.r[0-9]+$' | grep -o -E '[0-9]+' | sort -n | tail -1) [ -n "$new_vmpath" ] && vmpath="${vmpath}.r${new_vmpath}" |