diff options
Diffstat (limited to 'os-plugins/plugins/vmchooser')
3 files changed, 117 insertions, 28 deletions
diff --git a/os-plugins/plugins/vmchooser/XX_vmchooser.sh b/os-plugins/plugins/vmchooser/XX_vmchooser.sh index 35d17a2e..168bcda1 100644 --- a/os-plugins/plugins/vmchooser/XX_vmchooser.sh +++ b/os-plugins/plugins/vmchooser/XX_vmchooser.sh @@ -51,32 +51,6 @@ if [ -e $CONFFILE ]; then mount -n -t msdos -o loop,umask=000 ${PLUGINCONFDIR}/loopimg/fd.img \ ${PLUGINCONFDIR}/fd-loop - # create run-virt.include header (and fill in information on removable - # devices if present - echo -e "# run-virt.include created by $0 during stage3 plugin setup" \ - >${PLUGINCONFDIR}/run-virt.include - - waitfor /etc/hwinfo.cdrom - j=0 - for i in $(cat /etc/hwinfo.cdrom); do - echo "cdrom_$j=$i" >>${PLUGINCONFDIR}/run-virt.include - j=$(expr $j + 1) - done - - waitfor /etc/hwinfo.floppy - j=0 - for i in $(cat /etc/hwinfo.floppy); do - echo "floppy_$j=$i" >>${PLUGINCONFDIR}/run-virt.include - j=$(expr $j + 1) - done - - CPU_CORES=$(grep 'processor.*:' /proc/cpuinfo | wc -l) - if [ "${CPU_CORES}" -gt "1" 2>/dev/null ]; then - echo "cpu_cores=\"${CPU_CORES}\"" >>${PLUGINCONFDIR}/run-virt.include - else - echo 'cpu_cores="1"' >>${PLUGINCONFDIR}/run-virt.include - fi - # finished ... [ $DEBUGLEVEL -gt 0 ] && echo "done with 'vmchooser' os-plugin ..." fi diff --git a/os-plugins/plugins/vmchooser/files/run-virt.sh b/os-plugins/plugins/vmchooser/files/run-virt.sh index 9bc31396..adfc737e 100644 --- a/os-plugins/plugins/vmchooser/files/run-virt.sh +++ b/os-plugins/plugins/vmchooser/files/run-virt.sh @@ -22,8 +22,9 @@ . /etc/opt/openslx/openslx.conf PLUGINCONFROOT=${OPENSLX_DEFAULT_CONFDIR}/plugins PLUGINCONFDIR=${PLUGINCONFROOT}/vmchooser -# include general configuration from vmchooser -. ${PLUGINCONFDIR}/run-virt.include +# load general virtualization information +[ -f ${PLUGINCONFROOT}/virtualization/virtualization.conf ] && \ + . ${PLUGINCONFROOT}/virtualization/virtualization.conf # Sanity checks ################################################################################ diff --git a/os-plugins/plugins/vmchooser/init-hooks/80-after-plugins/virtualization.sh b/os-plugins/plugins/vmchooser/init-hooks/80-after-plugins/virtualization.sh new file mode 100644 index 00000000..8c241b8b --- /dev/null +++ b/os-plugins/plugins/vmchooser/init-hooks/80-after-plugins/virtualization.sh @@ -0,0 +1,114 @@ +# Copyright (c) 2008..2010 - RZ Uni Freiburg +# Copyright (c) 2008..2010 - OpenSLX GmbH +# +# This program/file is free software distributed under the GPL version 2. +# See http://openslx.org/COPYING +# +# If you have any feedback please consult http://openslx.org/feedback and +# send your feedback to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org +# +# script is included from init via the "." load function - thus it has all +# variables and functions available + +# virtual virtualization plugin +# make sure that this file is the same in vmgrid and vmchooser plugin! + +# include default directories +. /etc/openslx.conf + +CONFFILEVMCHOOSER="/initramfs/plugin-conf/vmchooser.conf" +CONFFILEVMGRID="/initramfs/plugin-conf/vmgrid.conf" +PLUGINCONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/virtualization + +# check if plugins available +active=0 +[ -f ${CONFFILEVMCHOOSER} ] && . ${CONFFILEVMCHOOSER} +[ -n "${CONFFILEVMCHOOSER}" ] && active=1 +[ -f ${CONFFILEVMGRID} ] && . ${CONFFILEVMGRID} +[ -n "${CONFFILEVMGRID}" ] && active=1 + +[ $DEBUGLEVEL -gt 0 ] \ + && echo "Executing the virtual 'virtualization' plugin ..." + +if [ ${active} -ne 0 ] ; then + + # load general configuration + . /etc/initramfs-setup + # include functions + . /etc/functions + + testmkd ${PLUGINCONFDIR} + + # check if vmgrid active and change free mem + totalmem=$(expr $(grep -i "memtotal" /proc/meminfo \ + | awk '{print $2}') / 1024) + echo "totalmem=${totalmem}" >> ${PLUGINCONFDIR}/virtualization.conf + if [ ${vmgrid_active} -ne 0 ]; then + totalmemtest=$(expr $(echo ${vmgrid_memratio} \ + | awk -F ',' '{print $1" + "$2" + "$3" + "$4" + "$5" + "$6}')) + if [ ${totalmemtest} -le 100 2>/dev/null ]; then + # get hostmem + freememper=$(expr 100 - $(echo ${vmgrid_memratio} \ + | awk -F ',' '{print $1" - "$2" - "$3" - "$4}')) + freemem=$(expr ${totalmem} \* ${freememper} / 100) + echo "freemem=${freemem}" \ + >> ${PLUGINCONFDIR}/virtualization.conf + else + # more than 100% memory assigned stupid! + # vmgrid will get this as well and exit! + # so we have theoretically 100% free + echo "freemem=${totalmem}" \ + >> ${PLUGINCONFDIR}/virtualization.conf + fi + else + echo "freemem=${totalmem}" \ + >> ${PLUGINCONFDIR}/virtualization.conf +fi + + # cpu cores + CPU_CORES=$(grep 'processor.*:' /proc/cpuinfo | wc -l) + if [ "${CPU_CORES}" -gt "1" 2>/dev/null ]; then + echo "cpu_cores=${CPU_CORES}" \ + >> ${PLUGINCONFDIR}/virtualization.conf + else + echo 'cpu_cores=1' >> ${PLUGINCONFDIR}/virtualization.conf + fi + + # arch + echo "host_arch=$(uname -m)" >> ${PLUGINCONFDIR}/virtualization.conf + + # VT enabled cpu? + if grep -q ^flags.*\\\<vmx\\\> /proc/cpuinfo; then + echo "vtflag=1" >> ${PLUGINCONFDIR}/virtualization.conf + echo 'kvm_module="kvm_intel"' >> ${PLUGINCONFDIR}/virtualization.conf + elif grep -q ^flags.*\\\<svm\\\> /proc/cpuinfo; then + echo "vtflag=1" >> ${PLUGINCONFDIR}/virtualization.conf + echo 'kvm_module="kvm_amd"' >> ${PLUGINCONFDIR}/virtualization.conf + else + echo "vtflag=0" >> ${PLUGINCONFDIR}/virtualization.conf + fi + + # get further hw information + waitfor /etc/hwinfo.cdrom + j=0 + for i in $(cat /etc/hwinfo.cdrom); do + echo "cdrom_$j=$i" >> ${PLUGINCONFDIR}/virtualization.conf + j=$(expr $j + 1) + done + + waitfor /etc/hwinfo.floppy + j=0 + for i in $(cat /etc/hwinfo.floppy); do + echo "floppy_$j=$i" >> ${PLUGINCONFDIR}/virtualization.conf + j=$(expr $j + 1) + done + + # finished ... + [ $DEBUGLEVEL -gt 0 ] \ + && echo " ok" +else + [ $DEBUGLEVEL -gt 0 ] \ + && echo " failed" +fi |