From 9a95c0c2d4a6382683725d5be0ab9171f9aed828 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Tue, 30 Mar 2010 20:11:25 +0200 Subject: diskless boot + minor modifications, virtualization.conf /w freemem --- .../plugins/virtualbox/files/run-virt.include | 61 ++++++++++------------ 1 file changed, 27 insertions(+), 34 deletions(-) (limited to 'os-plugins/plugins/virtualbox/files/run-virt.include') diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index 8543e376..f904b5f2 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -61,12 +61,12 @@ fi # link to image diskfile="${diskfolder}/${imgname}" -ln -sf ${vmpath} ${diskfile} +[ ${diskless} -eq 0 ] && ln -sf ${vmpath} ${diskfile} # check the file type -if echo ${imgname} | grep -iE "vdi|vmdk|vhd" >/dev/null 2>&1; then +if echo ${imgname} | grep -iE "vdi|vmdk|vhd" && [ ${diskless} -eq 0 ]; then imgfmt=$(echo ${imgname##*.} | tr [a-z] [A-Z]) -else +elif [ ${diskless} -eq 0 ]; then writelog "${imgname} is not a valid image format (vdi|vmdk|vhd), exiting!" exit 1 fi @@ -92,7 +92,7 @@ writelog "Directories:" writelog "\tConfig dir:\t\t$confdir" writelog "\tMachines dir:\t\t$machfolder" writelog "\tMachine config:\t\t$machconfig" -writelog "\tHardDisks dir:\t\t$diskfolder" +[ ${diskless} -eq 0 ] && writelog "\tHardDisks dir:\t\t$diskfolder" ################################################################################ ### Hardware checks @@ -105,9 +105,9 @@ macaddr=$(echo ${macaddr} | sed 's/://g') machineuuid="00000000-0000-0000-0000-${macaddr}" # cosmetical, since UUID in lower case machineuuid=$(echo ${machineuuid} | tr [A-Z] [a-z]) -# get UUID of VBox image -diskuuid=$(VBoxManage -q showvdiinfo ${diskfile} | grep UUID \ - | awk '{print $2}') +# get UUID of VBox image, if not diskless +[ ${diskless} -eq 0 ] && diskuuid=$(VBoxManage -q showvdiinfo ${diskfile} \ + | grep UUID | awk '{print $2}') # make disk immutable imgtype="Immutable" # snapshot UUID is static @@ -136,7 +136,7 @@ if echo "${imgmode}" | grep -q rw; then imgtype="Normal" # replace image uuid in machine config imageuuid=${diskuuid} -else +elif [ ${diskless} -eq 0 ]; then # use temp disk as snapshot cat ${PLUGINDIRVIRTUALBOX}/empty-diff.vdi.gz \ | gunzip > "${snapshotdir}/{${snapshotuuid}}.vdi" @@ -257,15 +257,14 @@ else boot="HardDisk" fi -writelog "\tSnapshots dir:\t\t$snapshotdir" +[ ${diskless} -eq 0 ] && writelog "\tSnapshots dir:\t\t$snapshotdir" writelog "Diskimage:" -writelog "\tDisk file:\t\t$diskfile" -writelog "\tDisk format:\t\t$imgfmt" -writelog "\tDisk type:\t\t$imgtype" -writelog "\tVMostype:\t\t$vmostype" -writelog "\tMachine UUID:\t\t$machineuuid" -writelog "\tDisk UUID:\t\t$diskuuid" -writelog "\tSnapshot UUID:\t\t$snapshotuuid" +[ ${diskless} -eq 0 ] && writelog "\tDisk file:\t\t$diskfile" +[ ${diskless} -eq 0 ] && writelog "\tDisk format:\t\t$imgfmt" +[ ${diskless} -eq 0 ] && writelog "\tDisk type:\t\t$imgtype" + writelog "\tVMostype:\t\t$vmostype" + writelog "\tMachine UUID:\t\t$machineuuid" +[ ${diskless} -eq 0 ] && writelog "\tDisk UUID:\t\t$diskuuid" writelog "Virtual Hardware:" writelog "\tGuest RAM:\t\t${mem} MB" # echo nur wenn memhost gesetzt @@ -273,7 +272,9 @@ 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}" -writelog "\tBooting from:\t\t${boot}" +writelog "\tBooting from:\t\t${boot}\c" +[ ${diskless} -eq 0 ] && writelog "" +[ ${diskless} -eq 1 ] && writelog " 'diskless'" # TODO: server start activate via xml, etc... #writelog "\tGuest VRDP port:\t${vrdpport}" #writelog "\tCD-ROM1:\t${cdrom0}" @@ -301,6 +302,14 @@ fi # create machine.xml . ${PLUGINCONFVIRTUALBOX}/machine.include +# if diskless remove all disks +if [ ${diskless} -eq 1 ]; then + sed -i "//d" ${machconfig} +fi + # add ssh port if linux and NAT if [ "${vmostype}" = "Linux26" ] && [ "${network_kind}" = "NAT" ]; then vmsshport="220${VM_ID}" @@ -322,33 +331,17 @@ fi # wait for a certain command to settle # get the PID of the right process -# TODO: not very good! But seems to work -# TODO: not needed? KILL!!! +# kill PID, seems to work VBMANPID=$(pstree -p | grep VBoxXPCOMIPCD | grep -ivE "VirtualBox|VBoxHeadless"\ | sed -e "s/.*VBoxXPCOMIPCD(\(.*\)).*/\1/") for i in $(echo ${VBMANPID}); do kill -9 ${VBMANPID} >/dev/null 2>&1 done -# TODO: OLD Version, NOW: KILL process -#VBMANPID=$(pstree -p | grep VBoxXPCOMIPCD | grep -ivE "VirtualBox|VBoxHeadless"\ -# | sed -e "s/.*VBoxXPCOMIPCD(\(.*\)).*/\1/" | tail -n 1) -#for i in {0..999}; do -# ps aux | grep -v grep | grep VBoxXPCOMIPCD | grep -q " ${VBMANPID} " || break -# if [ $i -eq 999 ]; then -# kill -9 ${VBMANPID} >/dev/null 2>&1 -# writelog "Process ID ${VBMANPID} did not finish, killing!" -# fi -#done # set the variables appropriately (several interfaces with different names) VIRTCMD=$(which VirtualBox 2>/dev/null) VIRTCMDOPTS="--startvm ${machineuuid} --start-running" -# SDL tests -#VIRTCMDSDL=$(which VBoxSDL 2>/dev/null) -#VIRTCMDOPTSSDL="--startvm ${machineuuid} --fullscreen --hwvirtex --memory 1024 \ -# --fixedmode 1680 1050 24 --hostkey 302 0" - # set headless mode VIRTCMDHL=$(which VBoxHeadless 2>/dev/null) VIRTCMDOPTSHL="-s ${machineuuid}" -- cgit v1.2.3-55-g7522