diff options
author | Michael Janczyk | 2010-03-22 19:06:22 +0100 |
---|---|---|
committer | Michael Janczyk | 2010-03-22 19:06:22 +0100 |
commit | 3f82922eef9a7b3e894d629d6cac59cadb66e2de (patch) | |
tree | 6a01c4c65bb88da9e268d1c3bddac520fa8811b2 | |
parent | qemukvm angepasst... geht noch nicht :( (diff) | |
download | core-3f82922eef9a7b3e894d629d6cac59cadb66e2de.tar.gz core-3f82922eef9a7b3e894d629d6cac59cadb66e2de.tar.xz core-3f82922eef9a7b3e894d629d6cac59cadb66e2de.zip |
small bugfix regarding xmlfile and paths.
writelog now additional into rwshare.
virtualbox rmdirs new.
qemukvm plugin added new konfigurations and headless support, to be tested
-rw-r--r-- | os-plugins/plugins/qemukvm/XX_qemukvm.sh | 22 | ||||
-rw-r--r-- | os-plugins/plugins/qemukvm/files/kvm.cmdline | 46 | ||||
-rw-r--r-- | os-plugins/plugins/qemukvm/files/run-virt.include | 206 | ||||
-rw-r--r-- | os-plugins/plugins/virtualbox/XX_virtualbox.sh | 2 | ||||
-rw-r--r-- | os-plugins/plugins/virtualbox/files/run-virt.include | 23 | ||||
-rw-r--r-- | os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 42 | ||||
-rw-r--r-- | os-plugins/plugins/vmgrid/files/vmgrid | 30 |
7 files changed, 254 insertions, 117 deletions
diff --git a/os-plugins/plugins/qemukvm/XX_qemukvm.sh b/os-plugins/plugins/qemukvm/XX_qemukvm.sh index 47d2689f..b595aab0 100644 --- a/os-plugins/plugins/qemukvm/XX_qemukvm.sh +++ b/os-plugins/plugins/qemukvm/XX_qemukvm.sh @@ -14,7 +14,7 @@ # include default directories . /etc/openslx.conf -CONFFILE="/initramfs/plugin-conf/qemukvm.conf" +CONFFILE=/initramfs/plugin-conf/qemukvm.conf PLUGINCONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/qemukvm PLUGINDIR=${OPENSLX_DEFAULT_DIR}/plugin-repo/qemukvm VIRTDIR=/mnt/${OPENSLX_DEFAULT_VIRTDIR}/qemukvm @@ -33,14 +33,19 @@ if [ -e ${CONFFILE} ]; then # load general configuration . /initramfs/machine-setup - # load needed variables - . /initramfs/plugin-conf/qemukvm.conf + + # copy virtualization include files and qemukvm.conf to config dir + testmkd ${PLUGINCONFDIR} + cp /mnt/${PLUGINDIR}/run-virt.include ${PLUGINCONFDIR} + cp ${CONFFILE} ${PLUGINCONFDIR} # check for the virtualization CPU features - if grep -q "svm" /proc/cpuinfo && modprobe ${MODPRV} kvm_amd ; then - [ $DEBUGLEVEL -gt 0 ] && echo " * Loaded kvm_amd module" - elif grep -q "vmx" /proc/cpuinfo && modprobe ${MODPRV} kvm_intel ; then + if grep -q "vmx" /proc/cpuinfo && modprobe ${MODPRV} kvm_intel ; then [ $DEBUGLEVEL -gt 0 ] && echo " * Loaded kvm_intel module" + echo "kvm=intel" >> ${PLUGINCONFDIR}/qemukvm.conf + elif grep -q "svm" /proc/cpuinfo && modprobe ${MODPRV} kvm_amd ; then + [ $DEBUGLEVEL -gt 0 ] && echo " * Loaded kvm_amd module" + echo "kvm=amd" >> ${PLUGINCONFDIR}/qemukvm.conf elif modprobe ${MODPRV} kqemu ; then [ $DEBUGLEVEL -gt 0 ] && \ error " * Successfully loaded the kqemu module, but loading of kvm_amd \ @@ -51,7 +56,6 @@ CPU." nonfatal error " * All module loading failed including the kqemu module, which \ was either\n not found or couldn't be loaded for other reasons. Thus using \ qemu(-kvm)\n makes not much sense." nonfatal - exit 1 fi # load the tunnel device module @@ -73,10 +77,6 @@ qemu(-kvm)\n makes not much sense." nonfatal ${qemukvm_imagesrc}." nonfatal fi - # copy virtualization include files to config dir - testmkd ${PLUGINCONFDIR} - - cp /mnt/${PLUGINDIR}/run-virt.include ${PLUGINCONFDIR} # create a network configuration template (variables should be setable in # the future, see vmware plugin) natnetwork="192.168.101" diff --git a/os-plugins/plugins/qemukvm/files/kvm.cmdline b/os-plugins/plugins/qemukvm/files/kvm.cmdline index b3352cb5..c566879d 100644 --- a/os-plugins/plugins/qemukvm/files/kvm.cmdline +++ b/os-plugins/plugins/qemukvm/files/kvm.cmdline @@ -149,48 +149,4 @@ ctrl-alt-f toggle full screen ctrl-alt-n switch to virtual console 'n' ctrl-alt toggle mouse and keyboard grab -When using -nographic, press 'ctrl-a h' to get some help. -root@lsfks19:~# kvm >kvm.cmd -open /dev/kvm: No such file or directory -Could not initialize KVM, will disable KVM support -root@lsfks19:~# vim kvm.cmd - -QEMU PC emulator version 0.9.1 (kvm-84), Copyright (c) 2003-2008 Fabrice Bellard -usage: qemu [options] [disk_image] - -'disk_image' is a raw hard image image for IDE hard disk 0 - -Standard options: --h or -help display this help and exit --M machine select emulated machine (-M ? for list) --cpu cpu select CPU (-cpu ? for list) --smp n set the number of CPUs to 'n' [default=1] --fda/-fdb file use 'file' as floppy disk 0/1 image --hda/-hdb file use 'file' as IDE hard disk 0/1 image --hdc/-hdd file use 'file' as IDE hard disk 2/3 image --cdrom file use 'file' as IDE cdrom image (cdrom is ide1 master) --drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i] - [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off] - [,cache=writethrough|writeback|none][,format=f][,serial=s] - [,boot=on|off] - use 'file' as a drive image --mtdblock file use 'file' as on-board Flash memory image --sd file use 'file' as SecureDigital card image --pflash file use 'file' as a parallel flash image --boot [a|c|d|n] boot on floppy (a), hard disk (c), CD-ROM (d), or network (n) --snapshot write to temporary files instead of disk image files --m megs set virtual RAM size to megs MB [default=128] --k language use keyboard layout (for example "fr" for French) --audio-help print list of audio drivers and their options --soundhw c1,... enable audio support - and only specified sound cards (comma separated list) - use -soundhw ? to get the list of supported cards - use -soundhw all to enable all of them --usb enable the USB driver (will be the default soon) --usbdevice name add the host or guest USB device 'name' --name string set the name of the guest --uuid %08x-%04x-%04x-%04x-%012x - specify machine UUID - -Display options: --nographic disable graphical output and redirect serial I/Os to console
\ No newline at end of file +When using -nographic, press 'ctrl-a h' to get some help.
\ No newline at end of file diff --git a/os-plugins/plugins/qemukvm/files/run-virt.include b/os-plugins/plugins/qemukvm/files/run-virt.include index 8d6d442b..0cec83da 100644 --- a/os-plugins/plugins/qemukvm/files/run-virt.include +++ b/os-plugins/plugins/qemukvm/files/run-virt.include @@ -28,31 +28,108 @@ else fi ################################################################################ -### Pepare and configure virtual machine and disk image +### Declaration of default variables ################################################################################ -permem=50 -mem=$(expr ${totalmem} / 100 \* ${permem}) +PLUGINCONFVIRTUALBOX="${PLUGINCONFROOT}/${self}" +# create TMPDIR for all users +mkdir -m 1777 /tmp/${self} 2>/dev/null +# TMPDIR +QKTMPDIR="/tmp/${self}/${USER}/${VM_ID}" +# define dirs and files which can be removed after exit, be carefull! +RMDIRS="${QKTMPDIR}" +rm -rf ${RMDIRS} 2>/dev/null +mkdir -p ${QKTMPDIR} 2>/dev/null +# vmpath is the path to the vm, here an image (img|qcow*|vmdk) +diskfile=${vmpath} + +# check the file type +if echo ${imgname} | grep -iE "img|qcow|vmdk" >/dev/null 2>&1; then + imgtype=$(echo ${imgname#*.} | tr [a-z] [A-Z]) +else + writelog "${imgname} is not a valid image type (img|qcow*|vmdk), exiting!" + exit 1 +fi + +# display name +VIRTCMDOPTS="${VIRTCMDOPTS} -name ${displayname}" + +writelog "Directories:" +writelog "\tTMPDIR:\t\t$QKTMPDIR" +writelog "Diskimage:" +writelog "\tDisk type:\t\t$imgtype" +writelog "\tDisk file:\t\t$diskfile" + +################################################################################ +### Hardware checks +################################################################################ + +# memory part equal to vmware plugin +# percentage of memory to use for virtualbox in standard case +if [ -n "${forcemem}" ]; then + mem="${forcemem}" +else +# permem=30 +# if [ "${totalmem}" -ge "1600" ]; then +# permem=40 +# fi +# # check if /tmp is on harddisk +# if grep -qe "/dev/.* /tmp " /proc/mounts ; then +# permem=60 +# id44="1" +# # Hack, if more than 2,5G RAM use 40% of Ram and write vmem into Ram as well +# # (40% vmware | 40% confdir(vmem...) | 20% host +# # VMplayer 2+ issue +# # TODO: makes this sense for vbox? +# #if [ "${totalmem}" -ge "2500" ]; then +# #permem=40 +# #rmdir ${snapshotdir} +# #snapshotdirold=${snapshotdir} +# #snapshotdir=/dev/shm/${self}/${USER}/${VM_ID} +# #mkdir -p ${snapshotdir} +# #ln -sf ${snapshotdir} ${snapshotdirold} +# #fi +# fi +# mem=$(expr ${totalmem} / 100 \* ${permem}) +# if [ "${id44}" = "1" ]; then +# memhost=$(expr ${totalmem} - ${mem}) +# else +# memhost=$(expr ${totalmem} - ${mem} - ${mem}) +# fi + # static first + permem=50 + mem=$(expr ${totalmem} / 100 \* ${permem}) + if [ "${mem}" -lt "256" ] || [ "${memhost}" -lt "256" ]; then + writelog "Memory out of range: ${mem} MB (guest) / ${memhost} MB (host)!" + writelog "Min. 256 MB for host and guest!" + exit 1 + fi +fi + VIRTCMDOPTS="${VIRTCMDOPTS} -m ${mem}" # network adaptor alternatives: rtl8139, pcnet, e1000 -VIRTCMDOPTS="${VIRTCMDOPTS} -net nic,model=pcnet" +network_card=${network_card:=pcnet} +VIRTCMDOPTS="${VIRTCMDOPTS} -net nic,model=${network_card}" case "${network_kind}" in bridge*) VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap0" ;; - nat|NAT) - VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap1" - ;; - hostonly) + hostonly|host-only) VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap2" ;; + *) + network_kind="NAT" + VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap1" + ;; esac +# external GUI port +vncport="590${VM_ID}" + +# TODO: most of the following does not make much sense yet ... # virtual fd/cd/dvd and drive devices, floppy b: for configuration -#VIRTCMDOPTS="${VIRTCMDOPTS} -fda /dev/fd0" -VIRTCMDOPTS="${VIRTCMDOPTS} -fdb /var/lib/virt/vmchooser/loopimg/fd.img" # if $floppy_0 from run-virt.include set then fdtest="TRUE" fdtest= fdtest=${floppy_0:+"TRUE"} @@ -75,19 +152,114 @@ cdrom1=${cdtest:-"FALSE"} ide="TRUE" hddrv="ide" +# TODO: nur bei vmchooser +#VIRTCMDOPTS="${VIRTCMDOPTS} -fda /dev/fd0" +#VIRTCMDOPTS="${VIRTCMDOPTS} -fdb ${floppy1name}" + # audio VIRTCMDOPTS="${VIRTCMDOPTS} -soundhw all" # serial #VIRTCMDOPTS="${VIRTCMDOPTS} -serial /dev/ttyS0" +writelog "Virtual Hardware:" +writelog "\tGuest RAM:\t\t${mem} MB" +# echo nur wenn memhost gesetzt +[ -n "${memhost}" ] && writelog "\tHost RAM:\t\t${memhost} MB" +writelog "\tMAC address:\t\t$macaddr" +writelog "\tNetwork card:\t\t${network_card}" +writelog "\tNetwork kind:\t\t${network_kind}" +#writelog "\tCD-ROM1:\t${cdrom0}" +#writelog "\tCD-ROM2:\t${cdrom1}" +#writelog "\tFloppy_A:\t${floppy0}" +#writelog "\tFloppy_B:\t${floppy1}" +#writelog "\tShared Folders 'home':\t/home/${USER}" + +################################################################################ +### finally set env for run-virt.sh +################################################################################ + +#-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i] +# [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off] +# [,cache=writethrough|writeback|none][,format=f][,serial=s] +# [,boot=on|off] +#-snapshot write to temporary files instead of disk image files +#-usb enable the USB driver (will be the default soon) +#-usbdevice name add the host or guest USB device 'name' +#-nographic disable graphical output and redirect serial I/Os to console +#-vga [std|cirrus|vmware|none] select video card type +#-vnc display start a VNC server on display +#-tftp dir allow tftp access to files in dir [-net user] +#-bootp file advertise file in BOOTP replies +#-no-fd-bootchk disable boot signature checking for floppy disks +#-no-acpi disable ACPI +#-kernel bzImage use 'bzImage' as kernel image +#-append cmdline use 'cmdline' as kernel command line +#-initrd file use 'file' as initial ram disk +#-serial dev redirect the serial port to char device 'dev' +#-parallel dev redirect the parallel port to char device 'dev' +#-monitor dev redirect the monitor to char device 'dev' +#-pidfile file write PID to 'file' +#-d item1,... output log to /tmp/qemu.log (use -d ? for a list of log items) +#-L path set the directory for the BIOS, VGA BIOS and keymaps +#-bios file set the filename for the BIOS +#-no-kvm disable KVM hardware virtualization +#-enable-nesting enable support for running a VM inside the VM (AMD only) +#-no-reboot exit instead of rebooting +#-no-shutdown stop before shutdown +#-loadvm [tag|id] +# start right away with a saved state (loadvm in monitor) +#-daemonize daemonize QEMU after initializing +#-kvm-shadow-memory megs set the amount of shadow pages to be allocated +#-mem-path set the path to hugetlbfs/tmpfs mounted directory, also +# enables allocation of guest memory with huge pages +#-mem-prealloc toggles preallocation of -mem-path backed physical memory +# at startup. Default is enabled. +#-option-rom rom load a file, rom, into the option ROM space +#-localtime set the real time clock to local time [default=utc] +#-startdate select initial date of the clock +#-icount [N|auto] +# enable virtual instruction counter with 2^N clock ticks per instruction +#-echr chr set terminal escape character instead of ctrl-a +#-virtioconsole c +# set virtio console +#-show-cursor show cursor + +# check for kvm modules +# TODO: check for /dev/kvm +if [ -n "${kvm}" ]; then + if lsmod |Ęgrep ${kvm}; then + for tool in kvm qemu-kvm; do + VIRTCMD=$(which ${tool} 2>/dev/null) + [ -n "$VIRTCMD" ] && break + done + else + writelog "KVM available but no modules loaded, maybe compiled into kernel?" + VIRTCMD=$(which qemu 2>/dev/null) + fi +fi + # set the variables appropriately -for tool in kvm qemu-kvm qemu; do - VIRTCMD=$(which ${tool} 2>/dev/null) - [ "x$VIRTCMD" != "x" ] && break -done +#for tool in kvm qemu-kvm qemu; do +# VIRTCMD=$(which ${tool} 2>/dev/null) +# [ -n "$VIRTCMD" ] && break +#done + +if [ -z "${VIRTCMD}" ]; then + writelog "No QEMU/KVM found." + rm -rf ${RMDIRS} + exit 1 +elif [ "${VIRTCMD}" = "qemu" ]; then + writelog "No KVM fouund. Starting slow QEMU emulation" + VIRTCMD="qemu" +else + VIRTCMD="sudo $VIRTCMD" +fi -[ -z $VIRTCMD ] && { writelog "No qemu/kvm tool found."; exit 1; } +# set headless mode +VIRTCMDHL="$VIRTCMD" +VIRTCMDOPTSHL="${VIRTCMDOPTS} -boot c -alt-grab -nographic" -VIRTCMD="sudo $VIRTCMD" -VIRTCMDOPTS="${VIRTCMDOPTS} -boot c -alt-grab ${diskfile}" +# graphical start +VIRTCMD="$VIRTCMD" +VIRTCMDOPTS="${VIRTCMDOPTS} -boot c -alt-grab -full-screen ${diskfile}" diff --git a/os-plugins/plugins/virtualbox/XX_virtualbox.sh b/os-plugins/plugins/virtualbox/XX_virtualbox.sh index 4fa0b7bb..998dabd7 100644 --- a/os-plugins/plugins/virtualbox/XX_virtualbox.sh +++ b/os-plugins/plugins/virtualbox/XX_virtualbox.sh @@ -14,7 +14,7 @@ # include default directories . /etc/openslx.conf -CONFFILE="/initramfs/plugin-conf/virtualbox.conf" +CONFFILE=/initramfs/plugin-conf/virtualbox.conf PLUGINCONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/virtualbox PLUGINDIR=/mnt/${OPENSLX_DEFAULT_DIR}/plugin-repo/virtualbox VIRTDIR=/mnt/${OPENSLX_DEFAULT_VIRTDIR}/virtualbox diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index 62ef769d..eb1cb0e9 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -37,7 +37,9 @@ mkdir -m 1777 /tmp/${self} 2>/dev/null confdir="/tmp/${self}/${USER}/${VM_ID}" # use alternate configuration directory instead of $HOME/.VirtualBox export VBOX_USER_HOME=${confdir} -rm -rf ${VBOX_USER_HOME}/* /tmp/.vbox-${USER}-ipc +# define dirs and files which can be removed after exit, be carefull! +RMDIRS="${snapshotdir} ${confdir} /tmp/.vbox-${USER}-ipc" 2>/dev/null +rm -rf ${RMDIRS} 2>/dev/null machfolder="${VBOX_USER_HOME}/Machines" # imgname is the name of the virtual image file # use vm_shortname since vm_name can be very long @@ -45,16 +47,16 @@ vm_shortname=$(echo ${imgname%.*} | sed -e "s, ,-,g") machconfig="${machfolder}/${vm_shortname}/${vm_shortname}.xml" diskfolder="${VBOX_USER_HOME}/HardDisks" snapshotdir=${machfolder}/${vm_shortname}/Snapshots -# imgname is the name of the virtual image file diskfile="${diskfolder}/${imgname}" -mkdir -p ${diskfolder} ${snapshotdir} +mkdir -p ${diskfolder} ${snapshotdir} 2>/dev/null ln -sf ${vmpath} ${diskfile} # check the file type if echo ${imgname} | grep -iE "vdi" >/dev/null 2>&1; then #vmdk|vhd imgtype=$(echo ${imgname#*.} | tr [a-z] [A-Z]) else - writelog "${imgname} is not a valid image type (vdi)" #vmdk|vhd + writelog "${imgname} is not a valid image type (vdi), exiting!" #vmdk|vhd + exit 1 fi # TODO: maybe rewrite, to reduce checks, merge it with network option, @@ -151,7 +153,7 @@ case "${network_kind}" in bridged) network_kind='BridgedInterface name="br0"' ;; - host-only) + hostonly|host-only) network_kind='HostOnlyInterface name="vboxnet0"' ;; *) @@ -159,8 +161,10 @@ case "${network_kind}" in ;; esac +# external GUI vrdpport="590${VM_ID}" +# TODO: nur bei vmchooser # TODO: most of the following does not make much sense yet ... # virtual fd/cd/dvd and drive devices, floppy b: for configuration # if $floppy_0 from run-virt.include set then fdtest="TRUE" @@ -200,9 +204,12 @@ writelog "\tGuest RAM:\t\t${mem} MB" writelog "\tMAC address:\t\t$macaddr" writelog "\tNetwork card:\t\t${vb_network_card}" writelog "\tNetwork kind:\t\t${network_kind}" +# TODO: server start activate via xml, etc... +#writelog "\tGuest VRDP port:\t${vrdpport}" #writelog "\tCD-ROM1:\t${cdrom0}" #writelog "\tCD-ROM2:\t${cdrom1}" #writelog "\tFloppy_A:\t${floppy0}" +#writelog "\tFloppy_B:\t${floppy1}" writelog "\tShared Folders 'home':\t/home/${USER}" ################################################################################ @@ -245,7 +252,7 @@ cat ${OPENSLX_DEFAULT_DIR}/plugin-repo/virtualbox/empty-diff.vdi.gz | \ gunzip > "${snapshotdir}/{${snapshotuuid}}.vdi" ################################################################################ -# finally set env for run-virt.sh +### finally set env for run-virt.sh ################################################################################ # wait for a certain command to settle @@ -268,9 +275,6 @@ done # fi #done -# define dirs and files which can be removed after exit, be carefull! -RMDIRS="${snapshotdir} ${confdir}" - # set the variables appropriately (several interfaces with different names) VIRTCMD=$(which VirtualBox 2>/dev/null) VIRTCMDOPTS="--startvm ${machineuuid} --start-running" @@ -283,4 +287,3 @@ VIRTCMDOPTS="--startvm ${machineuuid} --start-running" # set headless mode VIRTCMDHL=$(which VBoxHeadless 2>/dev/null) VIRTCMDOPTSHL="-s ${machineuuid}" - diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index 4a09f237..18e62ea0 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -18,23 +18,12 @@ . /etc/opt/openslx/openslx.conf ################################################################################ -### Functions used throughout the script -################################################################################ - -# function to write to stdout and logfile -writelog () { - # write to stdout - echo -e "$1" - # log into file - echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log -} - -################################################################################ ### Define default dirs / get configs ################################################################################ PLUGINCONFROOT=${OPENSLX_DEFAULT_CONFDIR}/plugins PLUGINCONFVMGRID=${PLUGINCONFROOT}/vmgrid +RWSHARE=/var/opt/openslx/plugins/vmgrid/share # include general configuration from vmgrid [ -f ${PLUGINCONFVMGRID}/vmgrid.conf ] && \ . ${PLUGINCONFVMGRID}/vmgrid.conf @@ -45,21 +34,36 @@ PLUGINCONFVMGRID=${PLUGINCONFROOT}/vmgrid . ${PLUGINCONFROOT}/vmchooser/vmchooser.conf ################################################################################ +### Functions used throughout the script +################################################################################ + +# function to write to stdout and logfile +mkdir -p ${RWSHARE}/var/log/openslx 2>/dev/null +writelog () { + # write to stdout + echo -e "$1" + # log into file + echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log + # log into share dir, so that log is available in vm as well + echo -e "$1" >> ${RWSHARE}/var/log/openslx/run-vmgrid.${USER}.$$.log +} + +################################################################################ ### Get XML file and dir ################################################################################ # check if forcemem set -# TODO: klappt noch nicht immer :( if [ "$1" = "--forcemem" ]; then forcemem=$2 - xmlfile=${3##*/} + xmlfile=$3 else - xmlfile=${1##*/} + xmlfile=$1 fi # absolute or relative path? -if ls ${1} 2>/dev/null | grep '/' >/dev/null 2>&1; then - xmlpath=$(dirname ${1}) +if ls ${xmlfile} 2>/dev/null | grep '/' >/dev/null 2>&1; then + xmlpath=$(dirname ${xmlfile}) + xmlfile=$(basename ${xmlfile}) else xmlpath=${vmgrid_xmlpath} fi @@ -265,8 +269,6 @@ ide="TRUE" scsi="FALSE" hddrv="ide" -# TODO: vncclient IP:59001 oder Plugin? - # add rw share rwshare="/var/opt/openslx/plugins/vmgrid/share" @@ -296,7 +298,7 @@ fi # start headless if [ -n "${VIRTCMDHL}" ]; then - writelog "Starting ${vmgrid_virt} head-less..." + writelog "Starting ${vmgrid_virt} headless..." ${VIRTCMDHL} ${VIRTCMDOPTSHL} else writelog "${vmgrid_virt}: No headless mode defined, exiting!" diff --git a/os-plugins/plugins/vmgrid/files/vmgrid b/os-plugins/plugins/vmgrid/files/vmgrid index 66291aea..7257226e 100644 --- a/os-plugins/plugins/vmgrid/files/vmgrid +++ b/os-plugins/plugins/vmgrid/files/vmgrid @@ -27,29 +27,18 @@ if [ -n "$1" ]; then echo "Usage: vmgrid [[/path/]filename[.xml]]" exit 0 else - run-vmgrid.sh $1 & + run-vmgrid.sh $@ & exit 0 fi fi ################################################################################ -### Functions used throughout the script -################################################################################ - -# function to write to stdout and logfile -writelog () { - # write to stdout - echo -e "$1" - # log into file - echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log -} - -################################################################################ ### Define default dirs / get configs ################################################################################ PLUGINCONFROOT=${OPENSLX_DEFAULT_CONFDIR}/plugins PLUGINCONFDIR=${PLUGINCONFROOT}/vmgrid +RWSHARE=/var/opt/openslx/plugins/vmgrid/share # include general configuration from vmgrid [ -f ${PLUGINCONFDIR}/vmgrid.conf ] && \ . ${PLUGINCONFDIR}/vmgrid.conf @@ -58,6 +47,21 @@ PLUGINCONFDIR=${PLUGINCONFROOT}/vmgrid . ${PLUGINCONFROOT}/vmchooser/vmchooser.conf ################################################################################ +### Functions used throughout the script +################################################################################ + +# function to write to stdout and logfile +mkdir -p ${RWSHARE}/var/log/openslx 2>/dev/null +writelog () { + # write to stdout + echo -e "$1" + # log into file + echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log + # log into share dir, so that log is available in vm as well + echo -e "$1" >> ${RWSHARE}/var/log/openslx/run-vmgrid.${USER}.$$.log +} + +################################################################################ ### Configure VMs for autostart and set RAM ################################################################################ |