From 7f75f14a06255fad86151a5273bee619a313a594 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 27 Nov 2013 17:37:16 +0100 Subject: [vmchooser] Add slxlog to run-virt --- .../data/opt/openslx/scripts/vmchooser-run_virt | 94 ++++++++++++---------- 1 file changed, 51 insertions(+), 43 deletions(-) (limited to 'remote/modules/vmchooser/data/opt/openslx/scripts') 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 5c85dfcd..0030eda1 100755 --- a/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt +++ b/remote/modules/vmchooser/data/opt/openslx/scripts/vmchooser-run_virt @@ -180,18 +180,22 @@ DO_PROFILE="$(grep -c -E -i '<\s*profile\s*param="?(true|yes)"?' "$xmlfile")" # test if the xml file is valid if ! [ -r "${xmlfile}" ]; then writelog "${xmlfile} not a readable XML file!" + slxlog "virt-nonreadable-xml" "XML file not readable: $xmlfile" exit 1 fi # test if XML file -if ! grep '/dev/null 2>&1; then +if ! grep -q '/dev/null | grep -q '^/' >/dev/null 2>&1; then +if echo "${imgname}" | grep -q '^/'; then imgpath="$(dirname "${imgname}")" imgname="$(basename "${imgname}")" vmpath="${imgpath}/${imgname}" # If old vmchooser binary stuff # We do not need folder name as it is already included by vmchooser -elif echo "${xmlfile}" 2>/dev/null | grep -q '^/tmp/' >/dev/null 2>&1; then +elif echo "${xmlfile}" | grep -q '^/tmp/'; then vmpath="$imgname" imgname="$(basename "${imgname}")" ## Added for persistent support. @@ -265,9 +269,7 @@ xmlvirt=$(grep -o 'virtualmachine param=.*"' "${xmlfile}" \ | sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}') # choose the proper virtualization/emulator plugin -[ "x${xmlvirt}" != "x" -a "x${xmlvirt}" != "xqemukvm" -a \ -"x${xmlvirt}" != "xvirtualbox" -a "x${xmlvirt}" != "xvmware" ] && \ -xmlvirt="emufe" +[ "x${xmlvirt}" != "x" -a "x${xmlvirt}" != "xqemukvm" -a "x${xmlvirt}" != "xvirtualbox" -a "x${xmlvirt}" != "xvmware" ] && xmlvirt="emufe" # make a guess from the filename extension if ${xmlvirt} is empty # (not set within the XML file) @@ -308,23 +310,18 @@ if [ -z "${xmlvirt}" ] && [ -n "${additional_config}" ]; then fi # Definition of the client system -vmostype=$(grep -io '/dev/null | \ -awk -F '=' {'print $2'} | tr "[A-Z]" "[a-z]") +enable3d=$(grep -i "/dev/null | awk -F '=' '{print $2}' | tr "[A-Z]" "[a-z]") # Add rw share sharepath="${HOME}/PERSISTENT" @@ -427,19 +424,12 @@ else VOL="80%" fi # Adjust sound volume -#writelog "Unmuting sound...\c " amixer -q sset Master "$VOL" unmute 2>/dev/null amixer -q sset PCM "$VOL" unmute 2>/dev/null amixer -q sset CD "$VOL" unmute 2>/dev/null amixer -q sset Headphone "$VOL" unmute 2>/dev/null amixer -q sset Front "$VOL" unmute 2>/dev/null # in SUSE 11.0 it's headphone amixer -q sset Speaker "$VOL" unmute 2>/dev/null # annoying built-in speaker -#writelog "finished\n" - -# Load kvm modules -if [ "$vtflag" = "1" -a -n "$kvm_module" ]; then - modprobe "$kvm_module" -fi # # # # # # Start printer daemon # # # # # # # @@ -449,13 +439,12 @@ QUEUE="STANDARD" # Start the lpdaemon listening on the given port tcpsvd -E 0.0.0.0 5515 \ - lpd "$SPOOLDIR" \ - sh -c "printergui $USER $SPOOLDIR/$QUEUE/\$DATAFILE" & + lpd "$SPOOLDIR" \ + sh -c "printergui $USER $SPOOLDIR/$QUEUE/\$DATAFILE" & # PID to kill the process PID_LPD="$!" - # Copy guest configuration (with added information) config.xml to be accessed # via virtual floppy cp "$xmlfile" "$VMCHOOSER_DIR/fd-loop/config.xml" @@ -483,7 +472,10 @@ if [ -n "$SLX_DNBD3_SERVERS" -o -n "$SLX_DNBD3_PRIO_SERVERS" ] && [ "x$SLX_VM_DN break fi done - [ -z "$vm_diskfile" ] && writelog "No working dnbd3 server found :-(" + if [ -z "$vm_diskfile" ]; then + slxlog "virt-dnbd3" "No dnbd3 server for ${vmpath#/mnt/vmstore/} found ($SLX_DNBD3_PRIO_SERVERS $TMP_SERVERS), trying NFS..." + writelog "No working dnbd3 server found :-(" + fi else writelog "Won't use dnbd3 as it's not loaded, or the daemon is not running..." fi @@ -499,20 +491,27 @@ fi # Check if virtual machine container file exists if ! [ -e "${vmpath}" ]; then + slxlog "virt-missing-image" "VM image $vmpath not found!" writelog "Virtual machine image ${vmpath} not found!" - exit 1 + cleanexit 1 fi writelog "Used diskfile: $vm_diskfile" # Get all virtual machine specific stuff from the respective include file if [ ! -e "$VMCHOOSER_DIR/$xmlvirt/run-virt.include" ] ; then + # TODO: Tell user + slxlog "virt-plugin-missing" "Could not find run-virt.include for $xmlvirt" writelog "Failed because of missing ${xmlvirt} plugin." cleanexit 1 fi self="${xmlvirt}" -. "$VMCHOOSER_DIR/$xmlvirt/run-virt.include" || writelog "Erroneous run-virt.include for $xmlvirt" +if ! . "$VMCHOOSER_DIR/$xmlvirt/run-virt.include"; then + slxlog "virt-plugin-error" "run-virt.include for $xmlvirt could not be sourced (contains syntax errors?)" "$xmlvirt" + writelog "Erroneous run-virt.include for $xmlvirt" +fi + # start a windowmanager for easier handling # (expect problems w/ windows opening in background w/ vmware without wm) for dm in openbox kwin xfwm4 metacity blackbox twm fvwm2 ; do @@ -526,13 +525,22 @@ for dm in openbox kwin xfwm4 metacity blackbox twm fvwm2 ; do break fi done + # Start poolvideoswitch if we find the autostarter file #if [ -e /etc/xdg/autostart/pvsgui.desktop ]; then # /usr/local/bin/pvsgui -p 2 -b >/dev/null 2>&1 & #fi + if [[ "$DO_PROFILE" -ge "1" ]]; then - wget "http://132.230.8.113/profile/do.php?action=start" + wget "http://132.230.8.113/profile/do.php?action=start" & +fi + +# Check if tcpsvd is running. Do this down here so we do not check immediately after trying to spawn it, +# as this could result in success even if it's not really working +if ! kill -0 "$PID_LPD"; then + slxlog "virt-lpd" "Could not start tcpsvd/lpd for virtual machine session" fi + # This will start the VM eval ${VIRTCMD} ${VIRTCMDOPTS} # -- cgit v1.2.3-55-g7522