From 8ac3d72cd1ba2d9b76f6c201b6cb9f3389915cb6 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Thu, 8 Apr 2010 21:07:44 +0200 Subject: virtualization plugin refurbished ;). booting 64bit guest on 32 bit hosts now possible /w virtualbox --- .../plugins/virtualbox/files/run-virt.include | 44 +++++++++++++++++----- 1 file changed, 34 insertions(+), 10 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 5fc0641a..af5595ee 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -66,7 +66,7 @@ diskfile="${diskfolder}/${imgname}" [ ${diskless} -eq 0 ] && ln -sf ${vmpath} ${diskfile} # check the file type -if echo ${imgname} | grep -iE "vdi|vmdk|vhd" && [ ${diskless} -eq 0 ]; then +if echo ${imgname} | grep -qiE "vdi|vmdk|vhd" && [ ${diskless} -eq 0 ]; then imgfmt=$(echo ${imgname##*.} | tr [a-z] [A-Z]) elif [ ${diskless} -eq 0 ]; then writelog "${imgname} is not a valid image format (vdi|vmdk|vhd), exiting!" @@ -76,17 +76,31 @@ fi # TODO: maybe rewrite, to reduce checks, merge it with network option, # so we can have a "compatibility to vmware config" section case "${vmostype}" in - winxp*) + winxp*|windowsxp*) vmostype="WindowsXP" ;; - winvista*) + winvista*|windowsvista*) vmostype="WindowsVista" ;; - Windows7*) + windows7*) vmostype="Windows7" ;; - linux*) - vmostype="Linux26" + linux*|*ubuntu*|*suse*|debian*|*sci*) + if echo "${vmostype}" | grep -q "64"; then + vmostype="Linux26_64" + # check for vtflag + if [ ${vtflag} -ne 1 ]; then + writelog "You are trying to boot a 64 bit OS without a VT enabled CPU" + writelog "This is not supported, exiting!" + exit 1 + fi + # check if host is only 32 bit, then use only 1 cpu (only 1 supported) + if echo "${host_arch}" | grep -qE "i.86"; then + cpu_cores=1 + fi + else + vmostype="Linux26" + fi ;; esac @@ -123,7 +137,7 @@ if echo "${imgmode}" | grep -q rw; then # lock existing? if [ -e "${vmpath}.lock" ]; then writelog "This rw image is already in use: ${vmpath}, exiting!" - writelog "Remove lock if you are shure that this is not the case" + writelog "Remove lock if you are sure that this is not the case" exit 1 # image rw? elif ! [ -w ${vmpath} ]; then @@ -144,6 +158,9 @@ elif [ ${diskless} -eq 0 ]; then | gunzip > "${snapshotdir}/{${snapshotuuid}}.vdi" fi +# make sure cpu_cores is not empty +cpu_cores=${cpu_cores:-"1"} + # TODO: MEM muss noch angepasst werden. Maschine crasht wenn nehr als 50% MEM # memory part equal to vmware plugin # percentage of memory to use for virtualbox in standard case @@ -222,7 +239,13 @@ case ${boot} in vm_name=$(echo ${vm_name} | sed -e "s, ,-,g") # link TFTP dir for NAT TFTP boots mkdir -p ${confdir}/TFTP - cp ${virtualbox_tftpdir}/pxelinux.0 ${confdir}/TFTP/${vm_name}.pxe + if [ -e ${virtualbox_tftpdir}/pxelinux.0 ]; then + cp ${virtualbox_tftpdir}/pxelinux.0 ${confdir}/TFTP/${vm_name}.pxe + else + writelog "${virtualbox_tftpdir}/pxelinux.0 not found!" + writelog "Network boot won't work, exiting!" + exit 1 + fi for i in $(ls ${virtualbox_tftpdir}); do ln -sf ${virtualbox_tftpdir}/${i} ${confdir}/TFTP/${i} done @@ -271,6 +294,7 @@ writelog "Diskimage:" writelog "\tMachine UUID:\t\t$machineuuid" [ ${diskless} -eq 0 ] && writelog "\tDisk UUID:\t\t$diskuuid" writelog "Virtual Hardware:" +[ ${vtflag} -eq 1 ] && writelog "\tVT enabled CPU" writelog "\tGuest RAM:\t\t${mem} MB" # echo nur wenn memhost gesetzt [ -n "${memhost}" ] && writelog "\tHost RAM:\t\t${memhost} MB" @@ -315,8 +339,8 @@ if [ ${diskless} -eq 1 ]; then sed -i "//d" ${machconfig} fi -# add ssh port if linux and NAT -if [ "${vmostype}" = "Linux26" ] && [ "${network_kind}" = "NAT" ]; then +# add ssh port if Linux26* and NAT +if echo "${vmostype}" | grep -q "Linux26" && [ "${network_kind}" = "NAT" ]; then vmsshport="220${VM_ID}" extradataitem='