From 4c061fa1f75d93a56cfe39fe06354ad702304f22 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 7 Apr 2010 19:07:20 +0200 Subject: h2ph was executed on every loadperlheader call making demuxer really slow.. --- lib/OpenSLX/Syscall.pm | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/OpenSLX/Syscall.pm b/lib/OpenSLX/Syscall.pm index 172db4d0..da72ae3d 100644 --- a/lib/OpenSLX/Syscall.pm +++ b/lib/OpenSLX/Syscall.pm @@ -73,23 +73,25 @@ sub _loadPerlHeader # any of these). # If they are missing, we just have a go at creating all of them: mkpath($phLibDir) unless -e $phLibDir; - if (-l "/usr/include/asm" && !-e "$phLibDir/asm") { - my $asmFolder = readlink("/usr/include/asm"); - slxsystem("cd /usr/include && h2ph -rQ -d $phLibDir $asmFolder") == 0 - or die _tr('unable to create Perl-header from "asm" folder! (%s)', $!); - slxsystem("mv $phLibDir/$asmFolder $phLibDir/asm") == 0 - or die _tr('unable to cleanup "asm" folder for Perl headers! (%s)', $!); - } - elsif (-d "/usr/include/asm") { - slxsystem("cd /usr/include && h2ph -rQ -d $phLibDir asm") == 0 - or die _tr('unable to create Perl-header from "asm" folder! (%s)', $!); - } - else { - die _tr( - 'the folder "/usr/include/asm" is required - please install kernel headers!' - ); + if (!-e "$phLibDir/asm") { + if (-l "/usr/include/asm") { + my $asmFolder = readlink("/usr/include/asm"); + slxsystem("cd /usr/include && h2ph -rQ -d $phLibDir $asmFolder") == 0 + or die _tr('unable to create Perl-header from "asm" folder! (%s)', $!); + slxsystem("mv $phLibDir/$asmFolder $phLibDir/asm") == 0 + or die _tr('unable to cleanup "asm" folder for Perl headers! (%s)', $!); + } + elsif (-d "/usr/include/asm") { + slxsystem("cd /usr/include && h2ph -rQ -d $phLibDir asm") == 0 + or die _tr('unable to create Perl-header from "asm" folder! (%s)', $!); + } + else { + die _tr( + 'the folder "/usr/include/asm" is required - please install kernel headers!' + ); + } } - if (-e "usr/include/asm-generic" && !-e "$phLibDir/asm-generic") { + if (-e "/usr/include/asm-generic" && !-e "$phLibDir/asm-generic") { slxsystem("cd /usr/include && h2ph -rQ -d $phLibDir asm-generic") == 0 or die _tr('unable to create Perl-header from "asm-generic" folder! (%s)', $!); } -- cgit v1.2.3-55-g7522 From 8d36684e70cb0e83133f9e671039de2c48461478 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Thu, 8 Apr 2010 21:12:10 +0200 Subject: annoying warning from demuxer removed, has to be solved otherwise virtualization plugin refurbished virtualbox can boot now 64 bit guests on 32 bit hosts --- boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm | 16 +-- os-plugins/plugins/vmchooser/XX_vmchooser.sh | 26 ----- os-plugins/plugins/vmchooser/files/run-virt.sh | 5 +- .../init-hooks/80-after-plugins/virtualization.sh | 114 +++++++++++++++++++++ os-plugins/plugins/vmgrid/XX_vmgrid.sh | 24 +---- os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 17 +-- os-plugins/plugins/vmgrid/files/vmgrid | 50 +-------- .../init-hooks/80-after-plugins/virtualization.sh | 114 +++++++++++++++++++++ 8 files changed, 255 insertions(+), 111 deletions(-) create mode 100644 os-plugins/plugins/vmchooser/init-hooks/80-after-plugins/virtualization.sh create mode 100644 os-plugins/plugins/vmgrid/init-hooks/80-after-plugins/virtualization.sh diff --git a/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm b/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm index cac92b37..6de0a4fe 100644 --- a/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm +++ b/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm @@ -383,17 +383,17 @@ sub _writeSlxSystemConf # check if default directories available and copy them to /etc my $defaultDirConfig = "$self->{'root-path'}/etc/opt/openslx/openslx.conf"; my $configTargetPath = "$self->{'build-path'}/etc"; - my $defaultConfVer = slurpFile("$defaultDirConfig"); - my $actConfVer = "Version 0.2"; + #my $defaultConfVer = slurpFile("$defaultDirConfig"); + #my $actConfVer = "Version 0.2"; if (-r $defaultDirConfig) { $self->addCMD("cp -p $defaultDirConfig $configTargetPath/"); - if ($defaultConfVer =~ m{$actConfVer}) { - warn _tr( - "Your version of default dir file (openslx.conf) is to old!\n". - "Eventually the system won't work.\n" . - "Please run install, update or clone of this system again!\n"); - } +# if ($defaultConfVer =~ m{$actConfVer}) { +# warn _tr( +# "Your version of default dir file (openslx.conf) is to old!\n". +# "Eventually the system won't work.\n" . +# "Please run install, update or clone of this system again!\n"); +# } } else { die _tr( "No default directories defined!\n" . 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.*\\\ /proc/cpuinfo; then + echo "vtflag=1" >> ${PLUGINCONFDIR}/virtualization.conf + echo 'kvm_module="kvm_intel"' >> ${PLUGINCONFDIR}/virtualization.conf + elif grep -q ^flags.*\\\ /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 diff --git a/os-plugins/plugins/vmgrid/XX_vmgrid.sh b/os-plugins/plugins/vmgrid/XX_vmgrid.sh index d9e35dfb..1d0c76be 100644 --- a/os-plugins/plugins/vmgrid/XX_vmgrid.sh +++ b/os-plugins/plugins/vmgrid/XX_vmgrid.sh @@ -96,29 +96,9 @@ if [ -f $CONFFILE ]; then chmod 1777 ${RWSHARE} echo "vmgrid_rwmnt=${RWSHARE#/mnt}" >> ${PLUGINCONFDIR}/vmgrid.conf - # virtual virtualization plugin - testmkd ${VIRTUALIZATIONPLUGIN} - totalmemtest=$(expr $(echo ${vmgrid_memratio} \ - | awk -F ',' '{print $1" + "$2" + "$3" + "$4" + "$5" + "$6}')) - totalmem=$(expr $(grep -i "memtotal" /proc/meminfo \ - | awk '{print $2}') / 1024) - 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 "virt_freemem=${freemem}" \ - >> ${VIRTUALIZATIONPLUGIN}/virtualization.conf - else - # more than 100% memory assigned stupid! - # vmgrid will get this as well and exit! - # so we have theoretically 100% free - echo "virt_freemem=${totalmem}" \ - >> ${VIRTUALIZATIONPLUGIN}/virtualization.conf - fi - # finished ... [ $DEBUGLEVEL -gt 0 ] && echo "done with 'vmgrid' os-plugin ..." fi -[ $DEBUGLEVEL -gt 0 ] && echo " * configuration of 'vmgrid' os-plugin failed" +else + [ $DEBUGLEVEL -gt 0 ] && echo " * configuration of 'vmgrid' os-plugin failed" fi diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index 626dfcca..bf10dc36 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -27,8 +27,9 @@ RWSHARE=/var/opt/openslx/plugins/vmgrid/share # include general configuration from vmgrid [ -f ${PLUGINCONFVMGRID}/vmgrid.conf ] && \ . ${PLUGINCONFVMGRID}/vmgrid.conf -#[ -f ${PLUGINCONFVMGRID}/vmgrid.include ] && \ -# . ${PLUGINCONFVMGRID}/vmgrid.include +# load general virtualization information +[ -f ${PLUGINCONFROOT}/virtualization/virtualization.conf ] && \ + . ${PLUGINCONFROOT}/virtualization/virtualization.conf # get the vmchooser_active var [ -f ${PLUGINCONFROOT}/vmchooser/vmchooser.conf ] && \ . ${PLUGINCONFROOT}/vmchooser/vmchooser.conf @@ -64,7 +65,8 @@ while [ $# -gt 0 ]; do headless=0 ;; --forcemem) - forcemem=$2 + # get a result which can be divided through 4 + forcemem=$(expr $2 / 4 \* 4) shift ;; *) @@ -281,7 +283,8 @@ if [ "${vmgrid_virt}" != "${xmlvirt}" ]; then fi # definition of the client system -vmostype=$(grep -io '/dev/null) if [ ${hostmem} -lt 256 2>/dev/null ]; then @@ -165,44 +164,3 @@ for i in {1..4}; do done exit 0 - -################################################################################ -### old stuff with xml files -################################################################################ -# -#filter_autostart=$(grep -i "active param" ${vmgrid_xmlpath}/*.xml | \ -# grep -E "true|1" | awk -F ":" '{print $1}') -# -## wozu mehrere starten -> siehe cherkasova -# -#filter_virt= -#for i in ${filter_autostart}; do -# filter_temp= -# filter_temp=$(cat $i | grep -i "virtualmachine param.*${vmgrid_virt}" | \ -# wc -l) -# if [ ${filter_temp} -eq 1 ]; then -# filter_virt="${filter_virt} $i" -# fi -#done -# -## remove already started ${vmgrid_startvm} -#filter_virt=$(echo $filter_virt | \ -# sed -e "s,${vmgrid_xmlpath}/${vmgrid_startvm%.xml}.xml,,g") -# -#sort_virt=$(grep 'priority param' ${vmgrid_xmlpath}/*.xml | sort -n | \ -# awk -F ":" '{print $1}') -# -#for i in ${sort_virt}; do -# j=$(echo $filter_virt | grep $i | wc -l) -# if [ $j -eq 1 ]; then -# filter_virt=$(echo $filter_virt | sed -e "s,$i,,g") -# vmgrid ${i#${vmgrid_xmlpath}/} -# fi -#done -# -## start vms /wo priority -#for i in ${filter_virt}; do -# vmgrid ${i#${vmgrid_xmlpath}/} -#done -# -#exit 0 diff --git a/os-plugins/plugins/vmgrid/init-hooks/80-after-plugins/virtualization.sh b/os-plugins/plugins/vmgrid/init-hooks/80-after-plugins/virtualization.sh new file mode 100644 index 00000000..8c241b8b --- /dev/null +++ b/os-plugins/plugins/vmgrid/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.*\\\ /proc/cpuinfo; then + echo "vtflag=1" >> ${PLUGINCONFDIR}/virtualization.conf + echo 'kvm_module="kvm_intel"' >> ${PLUGINCONFDIR}/virtualization.conf + elif grep -q ^flags.*\\\ /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 -- cgit v1.2.3-55-g7522 From 064469b5a21c617010554d3df5f27f924169f4b5 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 9 Apr 2010 11:29:49 +0200 Subject: added rsyslog (setup of configuration still missing) --- os-plugins/plugins/syslog/OpenSLX/Distro/Base.pm | 15 +++++++++ .../plugins/syslog/OpenSLX/OSPlugin/syslog.pm | 37 ++++++++++++++++------ 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/os-plugins/plugins/syslog/OpenSLX/Distro/Base.pm b/os-plugins/plugins/syslog/OpenSLX/Distro/Base.pm index 25be964c..654d755e 100644 --- a/os-plugins/plugins/syslog/OpenSLX/Distro/Base.pm +++ b/os-plugins/plugins/syslog/OpenSLX/Distro/Base.pm @@ -53,6 +53,7 @@ sub runlevelInfo my %nameMap = ( 'syslogd' => 'sysklogd', 'syslog-ng' => 'syslog-ng', + 'rsyslog' => 'rsyslog', ); my $rlInfo = { scriptName => $nameMap{$kind}, @@ -71,6 +72,20 @@ sub getPackageName my %nameMap = ( 'syslogd' => 'sysklogd', 'syslog-ng' => 'syslog-ng', + 'rsyslog' => 'rsyslog', + ); + return $nameMap{$name}; +} + +sub getBinaryName +{ + my $self = shift; + my $name = shift; + + my %nameMap = ( + 'syslogd' => 'sysklogd', + 'syslog-ng' => 'syslog-ng', + 'rsyslog' => 'rsyslogd', ); return $nameMap{$name}; } diff --git a/os-plugins/plugins/syslog/OpenSLX/OSPlugin/syslog.pm b/os-plugins/plugins/syslog/OpenSLX/OSPlugin/syslog.pm index e3935fc7..2952f2e7 100644 --- a/os-plugins/plugins/syslog/OpenSLX/OSPlugin/syslog.pm +++ b/os-plugins/plugins/syslog/OpenSLX/OSPlugin/syslog.pm @@ -68,9 +68,9 @@ sub getAttrInfo description => unshiftHereDoc(<<' End-of-Here'), kind of syslog to use \(syslogd-ng or old-style syslog\) End-of-Here - content_regex => qr{^(syslog-ng|syslog)$}, - content_descr => 'allowed: syslogd-ng, syslog', - default => 'syslog-ng', + content_regex => qr{^(syslog-ng|syslogd|rsyslog)$}, + content_descr => 'allowed: syslog-ng, syslogd, rsyslog', + default => 'rsyslog', }, 'syslog::host' => { applies_to_systems => 1, @@ -126,19 +126,27 @@ sub installationPhase my $engine = $self->{'os-plugin-engine'}; - if ($self->{kind} eq 'syslog-ng' && !isInPath('syslog-ng')) { + if ($self->{kind} eq 'rsyslog' && !isInPath($self->{distro}->getBinaryName('rsyslog'))) { $engine->installPackages($self->{distro}->getPackageName('syslog-ng')); } + + if ($self->{kind} eq 'syslog-ng' && !isInPath('syslog-ng')) { + $engine->installPackages($self->{distro}->getPackageName($self->{distro}->getBinaryName('syslog-ng'))); + } + # not sure if we ever should setup this service - if ($self->{kind} eq 'syslogd' && !isInPath('syslog')) { + if ($self->{kind} eq 'syslogd' && !isInPath($self->{distro}->getBinaryName('syslogd'))) { $engine->installPackages($self->{distro}->getPackageName('syslogd')); } if (!$self->{kind}) { - if (qx{which syslog-ng}) { + if (qx{which $self->{distro}->getBinaryName('rsyslog')}) { + $self->{kind} = 'rsyslog'; + } + elsif (qx{which $self->{distro}->getBinaryName('syslog-ng')}) { $self->{kind} = 'syslog-ng'; } - elsif (qx{which syslogd}) { + elsif (qx{which $self->{distro}->getBinaryName('syslogd')}) { $self->{kind} = 'syslogd'; } else { @@ -150,7 +158,10 @@ sub installationPhase } # start to actually do something - according to current stage1 attributes - if ($self->{kind} eq 'syslog-ng') { + if ($self->{kind} eq 'rsyslog') { + $self->_setupRsyslog($self->{attrs}); + } + elsif ($self->{kind} eq 'syslog-ng') { $self->_setupSyslogNG($self->{attrs}); } elsif ($self->{kind} eq 'syslogd') { @@ -158,7 +169,7 @@ sub installationPhase } else { die _tr( - 'unknown kind "%s" given, only "syslog-ng" and "syslogd" are supported!', + 'unknown kind "%s" given, only "rsyslog", "syslog-ng" and "syslogd" are supported!', $self->{kind} ); } @@ -174,6 +185,14 @@ sub removalPhase return; } +sub _setupRsyslog +{ + my $self = shift; + my $attrs = shift; + + return; +} + sub _setupSyslogNG { my $self = shift; -- cgit v1.2.3-55-g7522 From e530a41bf4ef1b84917cd1295d5aaf30051e42c9 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Fri, 9 Apr 2010 22:07:25 +0200 Subject: qemukvm network configuration --- os-plugins/plugins/qemukvm/XX_qemukvm.sh | 19 ++++--------- os-plugins/plugins/qemukvm/files/ifdown | 19 +++++++------ os-plugins/plugins/qemukvm/files/ifup | 32 ++++++++++------------ os-plugins/plugins/qemukvm/files/run-virt.include | 25 +++++++++-------- .../init-hooks/80-after-plugins/virtualization.sh | 9 ++++-- os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 20 +++++++++----- .../init-hooks/80-after-plugins/virtualization.sh | 9 ++++-- 7 files changed, 69 insertions(+), 64 deletions(-) diff --git a/os-plugins/plugins/qemukvm/XX_qemukvm.sh b/os-plugins/plugins/qemukvm/XX_qemukvm.sh index ac97b52f..36ff4f59 100644 --- a/os-plugins/plugins/qemukvm/XX_qemukvm.sh +++ b/os-plugins/plugins/qemukvm/XX_qemukvm.sh @@ -94,25 +94,16 @@ ${qemukvm_imagesrc}." nonfatal ln -sf ${PLUGINDIR}/ifup ${PLUGINCONFDIR}/ifup ln -sf ${PLUGINDIR}/ifdown ${PLUGINCONFDIR}/ifdown - for qemubin in qemu-kvm kvm qemu ; do - qemu=$(binfinder ${qemubin}) - [ -n "${qemu}" ] && echo "ALL ALL=NOPASSWD: ${qemu}" >>/mnt/etc/sudoers - done - #killall=$(binfinder killall) - #ippath=$(binfinder ip) cat >> /mnt/etc/sudoers << EOF # allow to start and stop kvm services / load-/unload kvm modules -ALL ALL=NOPASSWD: /etc/init.d/qemukvm +#ALL ALL=NOPASSWD: /etc/init.d/qemukvm ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/sbin/tunctl -t tap* ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tap* - -# TODO: check if kvm / qemu sufficient +ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/bin/ip link set dev tap* up +ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/bin/ip addr add * dev tap* +ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/usr/sbin/udhcpd -S /tmp/qemukvm/*/udhcpd.conf +ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/bin/cp /tmp/qemukvm/*/forwarding /proc/sys/net/ipv4/conf/tap*/forwarding #ALL ALL=NOPASSWD: ${killall} udhcpd -#ALL ALL=NOPASSWD: ${PLUGINDIR}/ifup -#ALL ALL=NOPASSWD: ${PLUGINDIR}/ifdown -#ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/usr/sbin/udhcpd -S /tmp/qemukvm/if* -#ALL ALL=NOPASSWD: ${ippath} link set dev tap* -#ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/sbin/ip addr add * dev tap* EOF fi else diff --git a/os-plugins/plugins/qemukvm/files/ifdown b/os-plugins/plugins/qemukvm/files/ifdown index be6ec913..e741d9ca 100644 --- a/os-plugins/plugins/qemukvm/files/ifdown +++ b/os-plugins/plugins/qemukvm/files/ifdown @@ -13,17 +13,20 @@ # - Script used for network cleanup of qemukvm in stage4 # ----------------------------------------------------------------------------- -# Clean up script +# get VM_ID through tap name +VM_ID=$(echo $1 | grep -oE "0[0-4]$") +QKTMPDIR=/tmp/qemukvm/${USER}/${VM_ID} +touch /tmp/qemukvm/udhcpd.pids +chmod 666 tmp/qemukvm/udhcpd.pids case "$1" in - tap1) - # Bringing down the dhcp server - killall udhcpd 2>/dev/null - #iptables -t nat -D POSTROUTING -o br0 -j MASQUERADE 2>/dev/null + tapnat0*) + # kill udhcpd + cat ${QKTMPDIR}/udhcpd.pid >> /tmp/qemukvm/udhcpd-unused.pid ;; - tap2) - # Bringing down the dhcp server - killall udhcpd 2>/dev/null + taphost0*) + # kill udhcpd + cat ${QKTMPDIR}/udhcpd.pid >> /tmp/qemukvm/udhcpd-unused.pid ;; esac diff --git a/os-plugins/plugins/qemukvm/files/ifup b/os-plugins/plugins/qemukvm/files/ifup index 9d94ac64..b3218798 100644 --- a/os-plugins/plugins/qemukvm/files/ifup +++ b/os-plugins/plugins/qemukvm/files/ifup @@ -29,21 +29,20 @@ QKTMPDIR=/tmp/qemukvm/${USER}/${VM_ID} # should be set up (passed in $1): tap0 = bridge, tap1 = nat, tap2 = hostonly. case "$1" in tapbridge0*) - # Adding the tap0 interface to the existing bridge configured in stage3 - #sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t $1 >/dev/null 2>&1 sudo ip link set dev $1 up - #sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 $1 - echo "1" >/proc/sys/net/ipv4/conf/br0/forwarding - echo "1" >/proc/sys/net/ipv4/conf/$1/forwarding + # TODO: forwarding?, where needed + echo "1" >${QKTMPDIR}/forwarding + sudo cp ${QKTMPDIR}/forwarding /proc/sys/net/ipv4/conf/br0/forwarding + sudo cp ${QKTMPDIR}/forwarding /proc/sys/net/ipv4/conf/$1/forwarding ;; tapnat0*) - # Configuring DHCP on host tap1 interface and enable IP masquerading - #sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t $1 >/dev/null 2>&1 + # Configuring DHCP on host tapnat interface and enable IP masquerading sudo ip addr add ${nataddress} dev $1 sudo ip link set dev $1 up - # not necessary since already done by run-virt.include - #[ -d ${QKTMPDIR} ] || mkdir -p ${QKTMPDIR} - # cut the last .NNN/MM from nataddress ${natnetwork%.*} + # TODO: forwarding?, where needed + echo "1" >${QKTMPDIR}/forwarding + sudo cp ${QKTMPDIR}/forwarding /proc/sys/net/ipv4/conf/br0/forwarding + sudo cp ${QKTMPDIR}/forwarding /proc/sys/net/ipv4/conf/$1/forwarding # TODO: we use here atatic address, maybe change later sed -e "s,NWIF,$1,;s,CNETWORK,192.168.1${VM_ID}," \ -e "s,PIDFILE,${QKTMPDIR}/udhcpd.pid," \ @@ -51,29 +50,26 @@ case "$1" in ${OPENSLX_DEFAULT_CONFDIR}/udhcpd.conf \ >${QKTMPDIR}/udhcpd.conf touch ${QKTMPDIR}/udhcpd.leases - # ip link set $1 up - # ip addr add 192.168.101.254/24 dev $1 sudo /opt/openslx/uclib-rootfs/usr/sbin/udhcpd \ -S ${QKTMPDIR}/udhcpd.conf # iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE ;; taphost0*) - # Configuring DHCP on host tap2 interface - #sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t $1 >/dev/null 2>&1 + # Configuring DHCP on host taphost interface sudo ip addr add ${hoaddress} dev $1 sudo ip link set dev $1 up - #[ -d ${QKTMPDIR} ] || mkdir -p ${QKTMPDIR} + # TODO: forwarding?, where needed + echo "1" >${QKTMPDIR}/forwarding + sudo cp ${QKTMPDIR}/forwarding /proc/sys/net/ipv4/conf/br0/forwarding + sudo cp ${QKTMPDIR}/forwarding /proc/sys/net/ipv4/conf/$1/forwarding sed -e "s,NWIF,$1,;s,USER,${USER},;s,CNETWORK,192.168.1${VM_ID}," \ -e "s,PIDFILE,${QKTMPDIR}/udhcpd.pid," \ -e "s,LEASEFILE,${QKTMPDIR}/udhcpd.leases," \ ${OPENSLX_DEFAULT_CONFDIR}/udhcpd.conf >${QKTMPDIR}/udhcpd.conf touch ${QKTMPDIR}/udhcpd.leases - # ip link set $1 up - # ip addr add 192.168.102.254/24 dev $1 sudo /opt/openslx/uclib-rootfs/usr/sbin/udhcpd \ -S ${QKTMPDIR}/udhcpd.conf ;; esac -# Produce a clean exit status exit 0 diff --git a/os-plugins/plugins/qemukvm/files/run-virt.include b/os-plugins/plugins/qemukvm/files/run-virt.include index 08a8b4f1..02c70469 100644 --- a/os-plugins/plugins/qemukvm/files/run-virt.include +++ b/os-plugins/plugins/qemukvm/files/run-virt.include @@ -40,7 +40,7 @@ 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 +mkdir -m 1777 -p ${QKTMPDIR} 2>/dev/null # vmpath is the path to the vm, here an image (img|qcow*|vmdk) diskfile=${vmpath} @@ -118,22 +118,28 @@ network_card=${network_card:=pcnet} VIRTCMDOPTS="${VIRTCMDOPTS} -net nic,macaddr=${macaddr},model=${network_card}" # define net kind and apply script -qemu_ifscr="script=${PLUGINDIRQK}/ifup,downscript=${PLUGINDIRQK}/ifdown" +qemu_ifscr="script=${PLUGINCONFQK}/ifup,downscript=${PLUGINCONFQK}/ifdown" case "${network_kind}" in bridge*) VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tapbridge${VM_ID},${qemu_ifscr}" - sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t tapbridge${VM_ID} #2>/dev/null + sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t tapbridge${VM_ID} -u ${USER} \ + >/dev/null 2>&1 sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tapbridge${VM_ID} + POSTRUN="/opt/openslx/uclib-rootfs/sbin/tunctl -d tapbridge${VM_ID}" ;; - NAT|nat) + nat) VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tapnat${VM_ID},${qemu_ifscr}" - sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t tapnat${VM_ID} + sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t tapnat${VM_ID} -u ${USER} \ + >/dev/null 2>&1 sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tapnat${VM_ID} + POSTRUN="/opt/openslx/uclib-rootfs/sbin/tunctl -d tapnat${VM_ID}" ;; - hostonly|host-only) + host*) VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=taphost${VM_ID},${qemu_ifscr}" - sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t taphost${VM_ID} + sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t taphost${VM_ID} -u ${USER} \ + >/dev/null 2>&1 sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 taphost${VM_ID} + POSTRUN="/opt/openslx/uclib-rootfs/sbin/tunctl -d taphost${VM_ID}" ;; *) network_kind="user" @@ -278,11 +284,9 @@ if [ -z "${VIRTCMD}" ]; then rm -rf ${RMDIRS} exit 1 elif [ "${VIRTCMD##*/}" = "qemu" ]; then - writelog "No user space KVM found. Using slow QEMU emulation" writelog "User space emulation:\t\t${VIRTCMD}" else writelog "User space virtualization:\t${VIRTCMD}" - VIRTCMD="sudo $VIRTCMD" fi # using snapshots @@ -293,11 +297,10 @@ VIRTCMDOPTS="${VIRTCMDOPTS} -boot c" # set headless mode # define first, you do not want VIRTCMDOPTS from graphical start -VIRTCMDHL="$VIRTCMD" +VIRTCMDHL=${VIRTCMD} VIRTCMDOPTSHL="${VIRTCMDOPTS} -nographic ${diskfile}" # graphical start -VIRTCMD="$VIRTCMD" # vga std/cirrus/vmware? #VIRTCMDOPTS="${VIRTCMDOPTS} -vga std -full-screen ${diskfile}" VIRTCMDOPTS="${VIRTCMDOPTS} ${diskfile}" 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 index 8c241b8b..5fa046d9 100644 --- a/os-plugins/plugins/vmchooser/init-hooks/80-after-plugins/virtualization.sh +++ b/os-plugins/plugins/vmchooser/init-hooks/80-after-plugins/virtualization.sh @@ -30,7 +30,7 @@ active=0 [ -n "${CONFFILEVMGRID}" ] && active=1 [ $DEBUGLEVEL -gt 0 ] \ - && echo "Executing the virtual 'virtualization' plugin ..." + && echo -e "Executing the virtual 'virtualization' plugin ... \c" if [ ${active} -ne 0 ] ; then @@ -90,6 +90,9 @@ fi echo "vtflag=0" >> ${PLUGINCONFDIR}/virtualization.conf fi + # write mac + echo "machostaddr=${macaddr}" >> ${PLUGINCONFDIR}/virtualization.conf + # get further hw information waitfor /etc/hwinfo.cdrom j=0 @@ -107,8 +110,8 @@ fi # finished ... [ $DEBUGLEVEL -gt 0 ] \ - && echo " ok" + && echo "ok" else [ $DEBUGLEVEL -gt 0 ] \ - && echo " failed" + && echo "failed" fi diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index bf10dc36..5e64b4cd 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -39,11 +39,12 @@ RWSHARE=/var/opt/openslx/plugins/vmgrid/share ################################################################################ # function to write to stdout and logfile +LOGFILE=${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log writelog () { # write to stdout echo -e "$1" # log into file - echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log + echo -e "$1" >> ${LOGFILE} # log into share dir, so that log is available in vm as well echo -e "$1" >> ${vmgrid_rwmnt}/logs/run-vmgrid.${USER}.$$.log } @@ -66,7 +67,8 @@ while [ $# -gt 0 ]; do ;; --forcemem) # get a result which can be divided through 4 - forcemem=$(expr $2 / 4 \* 4) + forcemem=$2 + echo $2 | grep -q '[1-9][0-9]\{2,3\}$' && forcemem=$(expr $2 / 4 \* 4) shift ;; *) @@ -113,7 +115,7 @@ if [ "${vmgrid_virt}" = "xen" ]; then runningvms=$(expr ${runningvms} + 1) fi # check value -if [ $runningvms -le 0 ]; then +if [ ${runningvms} -le 0 ]; then writelog "Error in value: Running VMs: ${runningvms}. Exit!" exit 1 fi @@ -288,9 +290,9 @@ vmostype=$(grep -io '/dev/null 2>&1 +fi + # remove config dirs when finished if echo "${RMDIRS}" 2>/dev/null | grep -q ${vmgrid_virt}; then writelog "${vmgrid_virt} exited. Cleanning up... \c" diff --git a/os-plugins/plugins/vmgrid/init-hooks/80-after-plugins/virtualization.sh b/os-plugins/plugins/vmgrid/init-hooks/80-after-plugins/virtualization.sh index 8c241b8b..5fa046d9 100644 --- a/os-plugins/plugins/vmgrid/init-hooks/80-after-plugins/virtualization.sh +++ b/os-plugins/plugins/vmgrid/init-hooks/80-after-plugins/virtualization.sh @@ -30,7 +30,7 @@ active=0 [ -n "${CONFFILEVMGRID}" ] && active=1 [ $DEBUGLEVEL -gt 0 ] \ - && echo "Executing the virtual 'virtualization' plugin ..." + && echo -e "Executing the virtual 'virtualization' plugin ... \c" if [ ${active} -ne 0 ] ; then @@ -90,6 +90,9 @@ fi echo "vtflag=0" >> ${PLUGINCONFDIR}/virtualization.conf fi + # write mac + echo "machostaddr=${macaddr}" >> ${PLUGINCONFDIR}/virtualization.conf + # get further hw information waitfor /etc/hwinfo.cdrom j=0 @@ -107,8 +110,8 @@ fi # finished ... [ $DEBUGLEVEL -gt 0 ] \ - && echo " ok" + && echo "ok" else [ $DEBUGLEVEL -gt 0 ] \ - && echo " failed" + && echo "failed" fi -- cgit v1.2.3-55-g7522 From eec193967f7aca562f7d99eaf5d6177f08e9a99e Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Sun, 11 Apr 2010 23:08:47 +0200 Subject: virtualization plugin, now with calculation of mem, run-vmgrid and run-virt uses it --- os-plugins/plugins/vmchooser/files/run-virt.sh | 11 ++-- .../init-hooks/80-after-plugins/virtualization.sh | 54 ++++++++++++------ os-plugins/plugins/vmgrid/XX_vmgrid.sh | 4 +- os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 6 +- os-plugins/plugins/vmgrid/files/vmgrid | 55 ++++++------------ .../init-hooks/80-after-plugins/virtualization.sh | 54 ++++++++++++------ os-plugins/plugins/vmware/files/run-virt.include | 65 ++++++++++++---------- 7 files changed, 133 insertions(+), 116 deletions(-) diff --git a/os-plugins/plugins/vmchooser/files/run-virt.sh b/os-plugins/plugins/vmchooser/files/run-virt.sh index adfc737e..771ebef4 100644 --- a/os-plugins/plugins/vmchooser/files/run-virt.sh +++ b/os-plugins/plugins/vmchooser/files/run-virt.sh @@ -121,22 +121,21 @@ cpu_cores="${cpu_cores}" # check for CPU virtualization flags -# get total amount of memory installed in your machine -totalmem=$(expr $(grep -i "memtotal" /proc/meminfo | awk '{print $2}') / 1024) +# total amount of memory defined in stage 3 permem=60 +# get a result which can be divided through 4 mem=$(expr ${totalmem} / 100 \* ${permem} / 4 \* 4) +[ -n "${mainvirtmem}" ] && forcemem=$(expr ${mainvirtmem} / 4 \* 4) # configuring ethernet mac address: first 3 bytes are fixed (00:50:56) # 4th byte is the VM-ID (0D) # last two bytes are taken from the bridge of the host # define one MAC per guest macguestpart="00:50:56:${VM_ID}" -machostpart=$($(which ifconfig) br0 | grep br0 | sed -e "s/ //g" | \ - awk -F ":" '{print $(NF-1)":"$NF}') +machostpart=$(echo ${machostaddr} | awk -F ":" '{print $(NF-1)":"$NF}') macaddr=$(echo "${macguestpart}:${machostpart}" | tr [a-z] [A-Z]) #TODO: remove when vmware modified -mac=$(/sbin/ifconfig eth0 | grep eth0 | sed -e "s/ //g" \ - | awk -F ":" '{print $(NF-1)":"$NF}') +mac=${machostpart} # virtual fd/cd/dvd and drive devices, floppy b: for configuration # if $floppy_0 from run-virt.include set then fdtest="TRUE" 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 index 5fa046d9..400075cd 100644 --- a/os-plugins/plugins/vmchooser/init-hooks/80-after-plugins/virtualization.sh +++ b/os-plugins/plugins/vmchooser/init-hooks/80-after-plugins/virtualization.sh @@ -25,9 +25,9 @@ PLUGINCONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/virtualization # check if plugins available active=0 [ -f ${CONFFILEVMCHOOSER} ] && . ${CONFFILEVMCHOOSER} -[ -n "${CONFFILEVMCHOOSER}" ] && active=1 +[ ${vmchooser_active} -ne 0 ] && active=1 [ -f ${CONFFILEVMGRID} ] && . ${CONFFILEVMGRID} -[ -n "${CONFFILEVMGRID}" ] && active=1 +[ ${vmgrid_active} -ne 0 ] && active=1 [ $DEBUGLEVEL -gt 0 ] \ && echo -e "Executing the virtual 'virtualization' plugin ... \c" @@ -45,27 +45,45 @@ if [ ${active} -ne 0 ] ; then 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}')) + + # not more than 100% memory assigned 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 + + # host mem + hostratio=$(echo ${vmgrid_memratio} | awk -F ',' '{print $6}') + hostmem=$(expr ${totalmem} \* ${hostratio} / 100 2>/dev/null) + if [ ${hostmem} -lt 256 2>/dev/null ]; then + # min. 256 MB for host + hostmem=256 + fi + + # main vm mem (vmchooser) + if [ ${vmchooser_active} -ne 0 ]; then + mainvirtratio=$(echo ${vmgrid_memratio} | awk -F ',' '{print $5}') + mainvirtmem=$(expr ${totalmem} \* ${mainvirtratio} / 100 2>/dev/null) + if [ ${mainvirtmem} -lt 512 2>/dev/null ]; then + # min. 512 for vmchooser + mainvirtmem=512 + fi + else + mainvirtratio=0 + mainvirtmem=0 + fi + + cat << EOF >> ${PLUGINCONFDIR}/virtualization.conf +hostratio=${hostratio} +hostmem=${hostmem} +mainvirtratio=${mainvirtratio} +mainvirtmem=${mainvirtmem} +EOF + fi - else - echo "freemem=${totalmem}" \ - >> ${PLUGINCONFDIR}/virtualization.conf -fi + fi # cpu cores CPU_CORES=$(grep 'processor.*:' /proc/cpuinfo | wc -l) diff --git a/os-plugins/plugins/vmgrid/XX_vmgrid.sh b/os-plugins/plugins/vmgrid/XX_vmgrid.sh index 1d0c76be..f75c895d 100644 --- a/os-plugins/plugins/vmgrid/XX_vmgrid.sh +++ b/os-plugins/plugins/vmgrid/XX_vmgrid.sh @@ -30,8 +30,8 @@ if [ -f $CONFFILE ]; then # load needed variables . $CONFFILE - if [ $vmgrid_active -ne 0 ] ; then - [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'vmgrid' os-plugin ..." + if [ ${vmgrid_active} -ne 0 ] ; then + [ ${DEBUGLEVEL} -gt 0 ] && echo "executing the 'vmgrid' os-plugin ..." # load general configuration . /etc/initramfs-setup diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index 5e64b4cd..1501749e 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -53,19 +53,19 @@ writelog () { ### Get XML file and dir ################################################################################ -# check if forcemem or graphical mode set +# check if mem or graphical mode set headless=1 while [ $# -gt 0 ]; do case "$1" in -h|--help) - echo -e "Usage: run-vmgrid.sh [-g] [--forcemem ] \c" + echo -e "Usage: run-vmgrid.sh [-g] [--mem ] \c" echo -e "[/path/]filename[.xml]" exit ;; -g) headless=0 ;; - --forcemem) + --mem) # get a result which can be divided through 4 forcemem=$2 echo $2 | grep -q '[1-9][0-9]\{2,3\}$' && forcemem=$(expr $2 / 4 \* 4) diff --git a/os-plugins/plugins/vmgrid/files/vmgrid b/os-plugins/plugins/vmgrid/files/vmgrid index ef86cb5a..d8ccd938 100644 --- a/os-plugins/plugins/vmgrid/files/vmgrid +++ b/os-plugins/plugins/vmgrid/files/vmgrid @@ -24,7 +24,7 @@ if [ -n "$1" ]; then if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then - echo -e "Usage: vmgrid [[-g] [--forcemem ] \c" + echo -e "Usage: vmgrid [[-g] [--mem ] \c" echo -e "[/path/]filename[.xml]]" exit 0 else @@ -47,9 +47,6 @@ RWSHARE=/var/opt/openslx/plugins/vmgrid/share # load general virtualization information [ -f ${PLUGINCONFROOT}/virtualization/virtualization.conf ] && \ . ${PLUGINCONFROOT}/virtualization/virtualization.conf -# get the vmchooser_active var -[ -f ${PLUGINCONFROOT}/vmchooser/vmchooser.conf ] && \ - . ${PLUGINCONFROOT}/vmchooser/vmchooser.conf ################################################################################ ### Functions used throughout the script @@ -69,48 +66,35 @@ writelog () { ### Configure VMs for autostart and set RAM ################################################################################ -# start to log, create shrare log dir +# start to log, create share log dir mkdir -m 1777 -p ${vmgrid_rwmnt}/logs mkdir -m 1777 -p /tmp/vmgrid mkdir -p /tmp/vmgrid/${USER} echo "Starting to log at $(date)" \ >${vmgrid_rwmnt}/logs/run-vmgrid.${USER}.$$.log +if [ -z "${hostratio}" ]; then + writelog "There has been an error in the memory configuration in stage 3" + writelog "Please check your memory ratio settings, exiting!" + exit 1 +fi + # remove blanks -vmgrid_memratio=$(echo ${vmgrid_memratio} | sed -e "s, *,,g") vmgrid_startvms=$(echo ${vmgrid_startvms} | sed -e "s, *,,g") +vmgrid_memratio=$(echo ${vmgrid_memratio} | sed -e "s, *,,g") -# get hostmem, totalmem from stage 3 -hostratio=$(echo ${vmgrid_memratio} | awk -F ',' '{print $6}') -hostmem=$(expr ${totalmem} \* ${hostratio} / 100 2>/dev/null) -if [ ${hostmem} -lt 256 2>/dev/null ]; then - hostmem=256 - writelog "${hostmem} MB RAM reserved for host" -fi - -# get other vm mem -if [ -n "${vmchooser_active}" ]; then - othervmratio=$(echo ${vmgrid_memratio} | awk -F ',' '{print $5}') - othervmmem=$(expr ${totalmem} \* ${othervmratio} / 100 2>/dev/null) - if [ ${othervmmem} -lt 512 2>/dev/null ]; then - othervmmem=512 - writelog "${othervmmem} MB RAM reserved for other virtualization solutions" - fi -else - othervmratio=0 - othervmmem=0 -fi +# hostmem, mainvirt from virtualization plugin +# ratio minus other vms and host +restratio=$(expr 100 - ${hostratio} - ${mainvirtratio}) +# hostmem, totalmem, mainvirtmem from virtualization plugin # calculate freemem -freemem=$(expr ${totalmem} - ${hostmem} - ${othervmmem} 2>/dev/null) +freemem=$(expr ${totalmem} - ${hostmem} - ${mainvirtmem} 2>/dev/null) if [ ${freemem} -lt 512 2>/dev/null ]; then writelog "Not enough free RAM for this plugin, free: ${freemem} MB" exit 1 fi -# ratio minus other vms and host -restratio=$(expr 100 - ${hostratio} - ${othervmratio}) - # get clients mem ratio vmsumratios=0 for i in {1..4}; do @@ -123,15 +107,8 @@ for i in {1..4}; do vmsumratios=$(expr ${vmsumratios} + ${vmratio[$i]} 2>/dev/null) done -# ratio test: 100 - host - other vm + grid ratios -ratiotest=$(expr 100 - ${restratio} + ${vmsumratios} 2>/dev/null) -if [ ${ratiotest} -gt 100 ]; then - #writelog "you managed to get over 100% in ratio Einstein: ${ratiotest}%" - exit 1 -fi - for i in {1..4}; do - # calculate vms mem: mem = $freemem * $vmratio/100 * 100/$restratio + # calculate VMs mem: mem = $freemem * $vmratio/100 * 100/$restratio # multiple of 4 vmmem[$i]=$(expr ${freemem} \* ${vmratio[$i]} / ${restratio} / 4 \* 4 \ 2>/dev/null) @@ -155,7 +132,7 @@ for i in {1..4}; do writelog "${vm[$i]} already running, skipping!" else writelog "Starting ${vm[$i]} via run-vmgrid.sh with ${vmmem[$i]} MB RAM" - run-vmgrid.sh --forcemem ${vmmem[$i]} ${vm[$i]} 2>/dev/null & + run-vmgrid.sh --mem ${vmmem[$i]} ${vm[$i]} 2>/dev/null & echo $! > /tmp/vmgrid/${USER}/vmgrid.pids # wait 5 secs for the next vm to start sleep 10 diff --git a/os-plugins/plugins/vmgrid/init-hooks/80-after-plugins/virtualization.sh b/os-plugins/plugins/vmgrid/init-hooks/80-after-plugins/virtualization.sh index 5fa046d9..400075cd 100644 --- a/os-plugins/plugins/vmgrid/init-hooks/80-after-plugins/virtualization.sh +++ b/os-plugins/plugins/vmgrid/init-hooks/80-after-plugins/virtualization.sh @@ -25,9 +25,9 @@ PLUGINCONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/virtualization # check if plugins available active=0 [ -f ${CONFFILEVMCHOOSER} ] && . ${CONFFILEVMCHOOSER} -[ -n "${CONFFILEVMCHOOSER}" ] && active=1 +[ ${vmchooser_active} -ne 0 ] && active=1 [ -f ${CONFFILEVMGRID} ] && . ${CONFFILEVMGRID} -[ -n "${CONFFILEVMGRID}" ] && active=1 +[ ${vmgrid_active} -ne 0 ] && active=1 [ $DEBUGLEVEL -gt 0 ] \ && echo -e "Executing the virtual 'virtualization' plugin ... \c" @@ -45,27 +45,45 @@ if [ ${active} -ne 0 ] ; then 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}')) + + # not more than 100% memory assigned 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 + + # host mem + hostratio=$(echo ${vmgrid_memratio} | awk -F ',' '{print $6}') + hostmem=$(expr ${totalmem} \* ${hostratio} / 100 2>/dev/null) + if [ ${hostmem} -lt 256 2>/dev/null ]; then + # min. 256 MB for host + hostmem=256 + fi + + # main vm mem (vmchooser) + if [ ${vmchooser_active} -ne 0 ]; then + mainvirtratio=$(echo ${vmgrid_memratio} | awk -F ',' '{print $5}') + mainvirtmem=$(expr ${totalmem} \* ${mainvirtratio} / 100 2>/dev/null) + if [ ${mainvirtmem} -lt 512 2>/dev/null ]; then + # min. 512 for vmchooser + mainvirtmem=512 + fi + else + mainvirtratio=0 + mainvirtmem=0 + fi + + cat << EOF >> ${PLUGINCONFDIR}/virtualization.conf +hostratio=${hostratio} +hostmem=${hostmem} +mainvirtratio=${mainvirtratio} +mainvirtmem=${mainvirtmem} +EOF + fi - else - echo "freemem=${totalmem}" \ - >> ${PLUGINCONFDIR}/virtualization.conf -fi + fi # cpu cores CPU_CORES=$(grep 'processor.*:' /proc/cpuinfo | wc -l) diff --git a/os-plugins/plugins/vmware/files/run-virt.include b/os-plugins/plugins/vmware/files/run-virt.include index dfd07a89..8b91275a 100644 --- a/os-plugins/plugins/vmware/files/run-virt.include +++ b/os-plugins/plugins/vmware/files/run-virt.include @@ -301,36 +301,40 @@ case "$parallel" in esac # adjust memory available for vmware guests -case "$vmversion" in - 2.*) - permem=30 - ;; - 3.*) - permem=25 - ;; -esac -if [ "${totalmem}" -ge "2500" ]; 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 +if [ -n "${forcemem}" ]; then + mem="${forcemem}" +else + case "$vmversion" in + 2.*) + permem=30 + ;; + 3.*) + permem=25 + ;; + esac if [ "${totalmem}" -ge "2500" ]; then permem=40 - confdir=/dev/shm/vmware/$USER - conffile=${confdir}/run-vmware.conf - mkdir -p /dev/shm/vmware/$USER fi -fi -mem=$(expr ${totalmem} / 100 \* ${permem} / 4 \* 4) -if [ "${id44}" = "1" ]; then - memhost=$(expr ${totalmem} - ${mem}) -else - memhost=$(expr ${totalmem} - ${mem} - ${mem}) + # 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 + if [ "${totalmem}" -ge "2500" ]; then + permem=40 + confdir=/dev/shm/vmware/$USER + conffile=${confdir}/run-vmware.conf + mkdir -p /dev/shm/vmware/$USER + fi + fi + mem=$(expr ${totalmem} / 100 \* ${permem} / 4 \* 4) + if [ "${id44}" = "1" ]; then + hostmem=$(expr ${totalmem} - ${mem}) + else + hostmem=$(expr ${totalmem} - ${mem} - ${mem}) + fi fi # check if ide/scsi and hwver of image @@ -397,8 +401,8 @@ writelog "# File created by $0 (VMversion ${vmversion})\n# on $(date)\n" writelog "Starting with non-persistent mode ...\n" # check memory range -if [ "${mem}" -lt "256" ] || [ "${memhost}" -lt "256" ]; then - writelog "\tMemory out of range: ${mem} MB (guest) / ${memhost} MB (host)!" +if [ "${mem}" -lt "256" ] || [ "${hostmem}" -lt "256" ]; then + writelog "\tMemory out of range: ${mem} MB (guest) / ${hostmem} MB (host)!" writelog "\tMin. 256 MB for host and guest!" exit 1 fi @@ -420,7 +424,8 @@ if [ -n "${network_card}" ]; then writelog "\tNet Adaptor:\t${network_card}" fi writelog "\tMem:\t\t${mem} MB" -writelog "\tHostmem:\t${memhost} MB" +# echo nur wenn hostmem gesetzt +[ -n "${hostmem}" ] && writelog "\tHostmem:\t${hostmem} MB" writelog "\tMax. res.:\t${xres}x${yres}" writelog "\tCD-ROM1:\t${cdrom0}" writelog "\tCD-ROM2:\t${cdrom1}" -- cgit v1.2.3-55-g7522