diff options
author | Dirk von Suchodoletz | 2009-02-26 14:20:14 +0100 |
---|---|---|
committer | Dirk von Suchodoletz | 2009-02-26 14:20:14 +0100 |
commit | cb34bf23f8ba7aa596cc658e149442c2c6cca6cb (patch) | |
tree | 23b3be03d7deb628e2b4196c3ad088b588343808 /os-plugins/plugins/vmware/files/run-virt.include | |
parent | The basic functionality of the old run-vmware scripts is now available (diff) | |
download | core-cb34bf23f8ba7aa596cc658e149442c2c6cca6cb.tar.gz core-cb34bf23f8ba7aa596cc658e149442c2c6cca6cb.tar.xz core-cb34bf23f8ba7aa596cc658e149442c2c6cca6cb.zip |
Further improvements for run-virt.sh ...
git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2643 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins/plugins/vmware/files/run-virt.include')
-rw-r--r-- | os-plugins/plugins/vmware/files/run-virt.include | 245 |
1 files changed, 125 insertions, 120 deletions
diff --git a/os-plugins/plugins/vmware/files/run-virt.include b/os-plugins/plugins/vmware/files/run-virt.include index 001691ce..c9430098 100644 --- a/os-plugins/plugins/vmware/files/run-virt.include +++ b/os-plugins/plugins/vmware/files/run-virt.include @@ -12,118 +12,12 @@ # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- # run-virt.include -# - +# - component for vmware/player of the vmchooser plugin run-virt.sh # ----------------------------------------------------------------------------- -# declaration of default variables +# configuration writer functions ################################################################################ -# temporary disk space for logs, etc... -redodir=/tmp/vmware/${USER} -# dir for configs and vmem file -confdir=${redodir} -# configfile -conffile="${confdir}/run-vmware.conf" -# users vmware config folder -vmhome="${HOME}/.vmware" - -# percentage of memory to use for vmwares in standard case -permem=60 - -# serial port defined (e.g. "ttyS0" or "autodetect") -serial=$(grep -i "<serial port=\"" ${xml} | awk -F "\"" '{ print $2 }') -case "$serial" in - tty*) - serialdev="serial0.filename = \"/dev/${serial}\"" - serial="TRUE" - ;; - autodetect) - serialdev="serial0.autodetect = \"TRUE\"" - serial="TRUE" - ;; - *) - serialdev="" - serial="FALSE" - ;; -esac - -# 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 -if [ "${totalmem}" -ge "2500" ]; then - permem=40 - confdir=/dev/shm/vmware/$USER - conffile=${confdir}/run-vmware.conf - mkdir -p /dev/shm/vmware/$USER -# if there is no scratch space on disk you have to waste your mem -elif grep -qe "ramfs /tmp " /proc/mounts ; then - permem=30 -fi -mem=$(expr ${totalmem} / 100 \* ${permem} / 4 \* 4) - -# check memory range -memtest=${totalmem}-128 -if [ "${mem}" -lt "128" ] || [ "${mem}" -gt "${totalmem}" ]; then - writelog "\n\n" - writelog "\tYour memory is out of range: ${mem} MB." - writelog "\tMin. 128 MB for host and guest!" - writelog "tTry --mem option." - exit 1 -fi - -# virtual fd/cd/dvd and drive devices, floppy b: for configuration -#floppya is always false, if we have a floppy device or not isn't -#important. -floppya="FALSE" -floppyb="TRUE" -floppybname="/var/lib/virt/vmchooser/loopimg/fd.img" -cdr_1="FALSE" -cdr_2="FALSE" -# ide is expected default, test for the virtual disk image type should -# be done while creating the runscripts ... -ide="TRUE" -scsi="FALSE" -hddrv="ide" - -# get version info -. /etc/vmware/slxvmconfig - -# VMplayer buildversion -vmbuild=$buildversion -vmversion=$version - -# VMware start options -#-X = fullscreen -vmopt="-X" - -# config and hardware version ex. 8/6 for VMware6.5 -# will be replaced automatically during run of vmware/player -confver=8 -hver=7 - -# Folder of VirtualMachine Images (VMDKs of that type. Compatible images might -# be found in older version folders too ...) -vmdir="/var/lib/virt/vmware/vmware65" - -#TODO: check for a faster way, perhaps we should put this into XML -# the grepping under some circumstances lets wait the user for ages ... -if [ $(echo ${imagename} | grep -cv "\-flat.vmdk") ]; then - hddrv=$(grep -m 1 -ia "ddb.adapterType" ${diskfile} | awk -F "\"" '{print $2}') - if [ "${hddrv}" = "ide" ]; then - ide="TRUE" - scsi="FALSE" - elif [ "${hddrv}" = "lsilogic" ]; then - ide="FALSE" - scsi="TRUE" - elif [ "${hddrv}" = "buslogic" ]; then - ide="FALSE" - scsi="TRUE" - fi -fi - -# Should we debug? Hell yes, we should always debug! -debug=0 - -### write run-vmware.conf ####################################################### runvmwareconfheader () { echo ".encoding = \"UTF-8\" @@ -132,8 +26,6 @@ runvmwareconfheader () # id displayName = \"${displayname}\" guestOS = \"${vmostype}\" -config.version = \"${confver}\" -virtualHW.version = \"${hver}\" # CPU/MEM memsize = \"${mem}\" @@ -180,14 +72,6 @@ ethernet0.connectionType = \"${network_kind}\" ethernet0.address = \"00:50:56:0D:${mac}\" ethernet0.wakeOnPcktRcv = \"FALSE\" -# usb -usb.present = \"TRUE\" -ehci.present= \"TRUE\" - -# graphics -svga.autodetect = \"TRUE\" -mks.enable3d = \"TRUE\" - # sound sound.present = \"TRUE\" sound.fileName = \"-1\" @@ -223,12 +107,37 @@ gui.restricted = \"TRUE\" serial0.present = \"${serial}\" ${serialdev}" >${conffile} +case "$vmversion" in + 1.0|5.5|2.0|6.0) + echo " +# version specific stuff +config.version = \"8\" +virtualHW.version = \"4\" +usb.present = \"TRUE\" +usb.generic.autoconnect = \"TRUE\" +svga.maxWidth = \"${xres}\" +svga.maxHeight = \"${yres}\" +svga.autodetect = \"TRUE\" +pref.hotkey.shift = \"TRUE\" +pref.hotkey.control = \"TRUE\" +pref.hotkey.alt = \"TRUE\"" >>${conffile} + ;; + 2.5|6.5) + echo " +# version specific stuff +config.version = \"8\" +virtualHW.version = \"7\" +usb.present = \"TRUE\" +ehci.present= \"TRUE\" +svga.autodetect = \"TRUE\" +mks.enable3d = \"TRUE\"" >>${conffile} + ;; +esac + # set the appropriate permissions for the vmware config file chmod u+rwx ${conffile} >/dev/null 2>&1 } - -### creates user configurationfile in ${vmhome} ################################ preferencesheader () { echo ".encoding = \"UTF-8\" @@ -271,6 +180,102 @@ pref.eula.1.buildNumber = \"${vmbuild}\"" \ >${vmhome}/preferences } +# declaration of default variables +################################################################################ + +# temporary disk space for logs, etc... +redodir=/tmp/vmware/${USER} +# dir for configs and vmem file +confdir=${redodir} +# configfile +conffile="${confdir}/run-vmware.conf" +# users vmware config folder +vmhome="${HOME}/.vmware" + +# percentage of memory to use for vmwares in standard case +permem=60 + +# serial port defined (e.g. "ttyS0" or "autodetect") +serial=$(grep -i "<serial port=\"" ${xml} | awk -F "\"" '{ print $2 }') +case "$serial" in + tty*) + serialdev="serial0.filename = \"/dev/${serial}\"" + serial="TRUE" + ;; + autodetect) + serialdev="serial0.autodetect = \"TRUE\"" + serial="TRUE" + ;; + *) + serialdev="" + serial="FALSE" + ;; +esac + +# 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 +if [ "${totalmem}" -ge "2500" ]; then + permem=40 + confdir=/dev/shm/vmware/$USER + conffile=${confdir}/run-vmware.conf + mkdir -p /dev/shm/vmware/$USER +# if there is no scratch space on disk you have to waste your mem +elif grep -qe "ramfs /tmp " /proc/mounts ; then + permem=30 +fi +mem=$(expr ${totalmem} / 100 \* ${permem} / 4 \* 4) + +# check memory range +memtest=${totalmem}-128 +if [ "${mem}" -lt "128" ] || [ "${mem}" -gt "${totalmem}" ]; then + writelog "\n\n" + writelog "\tYour memory is out of range: ${mem} MB." + writelog "\tMin. 128 MB for host and guest!" + writelog "tTry --mem option." + exit 1 +fi + +# virtual fd/cd/dvd and drive devices, floppy b: for configuration +#floppya is always false, if we have a floppy device or not isn't +#important. +floppya="FALSE" +floppyb="TRUE" +floppybname="/var/lib/virt/vmchooser/loopimg/fd.img" +cdr_1="FALSE" +cdr_2="FALSE" +# ide is expected default, test for the virtual disk image type should +# be done while creating the runscripts ... +ide="TRUE" +scsi="FALSE" +hddrv="ide" + +# get several version infos for vmware/player +. /etc/vmware/slxvmconfig +vmbuild=$buildversion +vmversion=$version + +# VMware start options +#-X = fullscreen +vmopt="-X" + +#TODO: check for a faster way, perhaps we should put this into XML +# the grepping under some circumstances lets wait the user for ages ... +if [ $(echo ${imagename} | grep -cv "\-flat.vmdk") ]; then + hddrv=$(grep -m 1 -ia "ddb.adapterType" ${diskfile} | awk -F "\"" '{print $2}') + if [ "${hddrv}" = "ide" ]; then + ide="TRUE" + scsi="FALSE" + elif [ "${hddrv}" = "lsilogic" ]; then + ide="FALSE" + scsi="TRUE" + elif [ "${hddrv}" = "buslogic" ]; then + ide="FALSE" + scsi="TRUE" + fi +fi + +# Should we debug? Hell yes, we should always debug! +debug=0 ### log function ############################################################### # function to write to stdout and logfile |