diff options
-rw-r--r-- | boot-env/OpenSLX/BootEnvironment/PXE.pm | 4 | ||||
-rw-r--r-- | boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm | 14 | ||||
-rw-r--r-- | installer/OpenSLX/OSSetup/Engine.pm | 10 | ||||
-rw-r--r-- | os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm | 59 | ||||
-rw-r--r-- | os-plugins/plugins/virtualbox/XX_virtualbox.sh | 30 | ||||
-rw-r--r-- | os-plugins/plugins/virtualbox/files/run-virt.include | 352 | ||||
-rw-r--r-- | os-plugins/plugins/vmchooser/files/run-virt.sh | 56 | ||||
-rw-r--r-- | os-plugins/plugins/vmware/XX_vmware.sh | 9 | ||||
-rw-r--r-- | os-plugins/plugins/vmware/files/run-virt.include | 6 | ||||
-rw-r--r-- | os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm | 46 | ||||
-rw-r--r-- | os-plugins/plugins/xen/init-hooks/10-have-nw-modules/xen.sh | 23 | ||||
-rwxr-xr-x | os-plugins/plugins/xen/init-hooks/20-nw-bridge-config/xen-bridge.sh | 4 |
12 files changed, 386 insertions, 227 deletions
diff --git a/boot-env/OpenSLX/BootEnvironment/PXE.pm b/boot-env/OpenSLX/BootEnvironment/PXE.pm index e49e52b6..d46786d0 100644 --- a/boot-env/OpenSLX/BootEnvironment/PXE.pm +++ b/boot-env/OpenSLX/BootEnvironment/PXE.pm @@ -81,6 +81,7 @@ sub writeBootloaderMenuFor } $info->{menuLabel} = $label; } +# if kernel=*xen* then run sub _xenLabel from xen.pm my $slxLabels = ''; foreach my $info (sort { $a->{label} cmp $b->{label} } @$systemInfos) { my $vendorOSName = $info->{'vendor-os'}->{name}; @@ -112,13 +113,14 @@ sub writeBootloaderMenuFor $append .= " file=$bootURI" if length($bootURI); $append .= " file=$tftpPrefix" if length($tftpPrefix); $append .= " $clientAppend"; - $slxLabels .= "LABEL openslx-$pxeLabel\n"; $slxLabels .= $pxeDefault; $slxLabels .= "\tMENU LABEL ^$info->{menuLabel}\n"; $slxLabels .= "\tKERNEL $pxePrefix$vendorOSName/$kernelName\n"; $slxLabels .= "\tAPPEND $append\n"; $slxLabels .= "\tIPAPPEND 3\n"; +# if kernel=*xen* then run sub _xenBootEntry from xen.pm +# if (!defined $xenKernel) {...} my $helpText = $info->{description} || ''; if (length($helpText)) { # make sure that text matches the given margin diff --git a/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm b/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm index ca4764ca..cac92b37 100644 --- a/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm +++ b/boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm @@ -383,13 +383,21 @@ 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"; + 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"); + } } else { die _tr( - "No default directories defined!\n" . - "Please run install, update or clone of this system again!\n"); + "No default directories defined!\n" . + "Please run install, update or clone of this system again!\n"); } return; diff --git a/installer/OpenSLX/OSSetup/Engine.pm b/installer/OpenSLX/OSSetup/Engine.pm index 4160b4b5..72e8c7e8 100644 --- a/installer/OpenSLX/OSSetup/Engine.pm +++ b/installer/OpenSLX/OSSetup/Engine.pm @@ -1106,8 +1106,9 @@ sub _generateDefaultDirs my $OPENSLX_DEFAULT_DIR = "/opt/openslx"; my $OPENSLX_DEFAULT_CONFDIR = "/etc/opt/openslx"; my $OPENSLX_DEFAULT_LOGDIR = "/var/log/openslx"; - my $OPENSLX_DEFAULT_BINDIR = "/var/opt/openslx/bin"; - my $OPENSLX_DEFAULT_LIBDIR = "/var/opt/openslx/lib"; + my $OPENSLX_DEFAULT_VARDIR = "/var/opt/openslx"; + my $OPENSLX_DEFAULT_BINDIR = "$OPENSLX_DEFAULT_VARDIR/bin"; + my $OPENSLX_DEFAULT_LIBDIR = "$OPENSLX_DEFAULT_VARDIR/lib"; my $OPENSLX_DEFAULT_VIRTDIR = "/var/lib/virt"; mkpath("$targetRoot/$OPENSLX_DEFAULT_DIR", "$targetRoot/$OPENSLX_DEFAULT_CONFDIR", @@ -1117,9 +1118,12 @@ sub _generateDefaultDirs "$targetRoot/$OPENSLX_DEFAULT_VIRTDIR"); slxsystem("chmod 1777 $targetRoot/$OPENSLX_DEFAULT_LOGDIR"); - my $openslxConfig = "OPENSLX_DEFAULT_DIR=$OPENSLX_DEFAULT_DIR\n"; + my $openslxConfig = "# Default OpenSLX directories defined by satge 1\n"; + $openslxConfig .= "# Version 0.2\n\n"; + $openslxConfig .= "OPENSLX_DEFAULT_DIR=$OPENSLX_DEFAULT_DIR\n"; $openslxConfig .= "OPENSLX_DEFAULT_CONFDIR=$OPENSLX_DEFAULT_CONFDIR\n"; $openslxConfig .= "OPENSLX_DEFAULT_LOGDIR=$OPENSLX_DEFAULT_LOGDIR\n"; + $openslxConfig .= "OPENSLX_DEFAULT_VARDIR=$OPENSLX_DEFAULT_VARDIR\n"; $openslxConfig .= "OPENSLX_DEFAULT_BINDIR=$OPENSLX_DEFAULT_BINDIR\n"; $openslxConfig .= "OPENSLX_DEFAULT_LIBDIR=$OPENSLX_DEFAULT_LIBDIR\n"; $openslxConfig .= "OPENSLX_DEFAULT_VIRTDIR=$OPENSLX_DEFAULT_VIRTDIR\n"; diff --git a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm index fd1424f1..8e04fdd6 100644 --- a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm +++ b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm @@ -115,18 +115,24 @@ sub installationPhase # Different names of the tool (should be unified somehow!?) if (!isInPath('VirtualBox')) { # todo: fix this - $self->{distro}->installVbox(); + $self->{distro}->installVbox(); } if (!isInPath('VirtualBox')) { - print "VirtualBox is not installed. VirtualBox Plugin won't be installed!\n"; + print "VirtualBox is not installed. VirtualBox Plugin won't be installed!\n"; # exit - } + } $self->_writeRunlevelScript(); - # Copy run-virt.include to the appropriate place for inclusion in stage4 - copyFile("$self->{openslxBasePath}/lib/plugins/virtualbox/files/run-virt.include", - "$self->{pluginRepositoryPath}/"); + # Copy run-virt.include and template files to the appropriate place for + # inclusion in stage4 + my $pluginName = $self->{'name'}; + my $pluginBasePath = "$self->{openslxBasePath}/lib/plugins/$pluginName/files"; + foreach my $file ( qw( run-virt.include virtualbox.include machine.include + empty-diff*.vdi.gz ) ) { + copyFile("$pluginBasePath/$file", "$self->{pluginRepositoryPath}/"); + chmod 0755, "$self->{pluginRepositoryPath}/$file"; + } return; } @@ -157,6 +163,7 @@ sub _writeRunlevelScript my $self = shift; my $initfile = newInitFile(); + my $script = ""; $initfile->setName("vbox-slx"); $initfile->setDesc("Setup environment for virtualbox. Part of OpenSLX virtualbox plugin."); @@ -166,30 +173,34 @@ sub _writeRunlevelScript 'running', 'lsmod | grep -q "$1[^_-]"' ); + # + $script = unshiftHereDoc(<<' End-of-Here'); + if running vboxdrv; then + if running vboxnetflt; then + echo "VirtualBox kernel modules (vboxdrv and vboxnetflt) are loaded." + else + echo "VirtualBox kernel module is loaded." + fi + #TODO: check it: ignore user check. handling our own way: + for i in /tmp/.vbox-*-ipc; do + echo "Running: " + $(VBoxManage -q list runningvms | sed -e 's/^".*"//' 2>/dev/null) + done + else + echo "VirtualBox kernel module(s) are not loaded." + fi + End-of-Here $initfile->addFunction( - 'vmstatus', - 'if running vboxdrv; then - if running vboxnetflt; then - echo "VirtualBox kernel modules (vboxdrv and vboxnetflt) are loaded." - else - echo "VirtualBox kernel module is loaded." - fi - #TODO: check it: ignore user check. handling our own way: - for i in /tmp/.vbox-*-ipc; do - echo "Running: " - $(VBoxManage --nologo list runningvms | sed -e \'s/^".*"//\' 2>/dev/null) - done - else - echo "VirtualBox kernel module is not loaded." - fi' + "vmstatus", + "$script" ); $initfile->addFunction( 'start', - ' modprobe vboxdrv && modprobe vboxnetflt', + ' modprobe -qa vboxdrv vboxnetflt vboxnetadp', ); $initfile->addFunction( 'stop', - ' rmmod vboxnetflt && rmmod vboxdrv', + ' rmmod vboxnetadp vboxnetflt vboxdrv', ); $initfile->addToCase( 'start', @@ -212,8 +223,6 @@ sub _writeRunlevelScript my $distro = (split('-',$self->{'os-plugin-engine'}->distroName()))[0]; my $runlevelscript = getInitFileForDistro($initfile, $distro); - # todo: because we dont have distribution or version dependend - # init scripts we could put it directly into /etc/init.d... spitFile("$self->{'pluginRepositoryPath'}/vbox-slx", $runlevelscript); } diff --git a/os-plugins/plugins/virtualbox/XX_virtualbox.sh b/os-plugins/plugins/virtualbox/XX_virtualbox.sh index 38dd80ec..1ca15fd9 100644 --- a/os-plugins/plugins/virtualbox/XX_virtualbox.sh +++ b/os-plugins/plugins/virtualbox/XX_virtualbox.sh @@ -1,4 +1,4 @@ -# Copyright (c) 2009 - OpenSLX GmbH +# Copyright (c) 2009, 2010 - OpenSLX GmbH # # This program/file is free software distributed under the GPL version 2. # See http://openslx.org/COPYING @@ -11,11 +11,20 @@ # script is included from init via the "." load function - thus it has all # variables and functions available +# include default directories +. /etc/openslx.conf + +CONFFILE="/initramfs/plugin-conf/virtualbox.conf" +PLUGINCONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/virtualbox +PLUGINDIR=/mnt/${OPENSLX_DEFAULT_DIR}/plugin-repo/virtualbox +VIRTDIR=/mnt/${OPENSLX_DEFAULT_VIRTDIR}/virtualbox +LOGDIR=/mnt/${OPENSLX_DEFAULT_LOGDIR} + # check if the configuration file is available -if [ -e /initramfs/plugin-conf/virtualbox.conf ]; then +if [ -e ${CONFFILE} ]; then # load needed variables - . /initramfs/plugin-conf/virtualbox.conf + . ${CONFFILE} # Test if this plugin is activated... more or less useless with the # new plugin system @@ -33,22 +42,21 @@ if [ -e /initramfs/plugin-conf/virtualbox.conf ]; then fi if [ -n "${vbimgserv}" ] ; then # directory where qemu images are expected in - mnttarget=/mnt/var/lib/virt/virtualbox + mnttarget=${VIRTDIR} # mount the virtualbox image source readonly (ro) fsmount ${vbimgprot} ${vbimgserv} ${vbimgpath} ${mnttarget} ro else [ $DEBUGLEVEL -gt 1 ] && error " * Incomplete information in variable \ ${virtualbox_imagesrc}." nonfatal fi - # copy version depending files - the vmchooser expects for every virtua- - # lization plugin a file named after it (here run-virtualbox.include) - testmkd /mnt/etc/opt/openslx - cp /mnt/opt/openslx/plugin-repo/virtualbox/run-virt.include \ - /mnt/etc/opt/openslx/run-virtualbox.include + # copy virtualization include files to config dir + testmkd ${PLUGINCONFDIR} + cp ${PLUGINDIR}/*.include ${PLUGINCONFDIR} + # copy ${CONFFILE} to ${PLUGINCONFDIR} just in case + cp ${CONFFILE} ${PLUGINCONFDIR} # copy and activate init file - cp /mnt/opt/openslx/plugin-repo/virtualbox/vbox-slx \ - /mnt/etc/init.d + cp ${PLUGINDIR}/vbox-slx /mnt/etc/init.d/ chmod 755 /mnt/etc/init.d/vbox-slx rllinker "vbox-slx" 20 2 diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index e16e2edf..44a749cb 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -1,6 +1,7 @@ -# run-virtualbox.include -# -# Copyright (c) 2009 - OpenSLX GmbH +# run-virt.include +# ----------------------------------------------------------------------------- +# Copyright (c) 2009..2010 - RZ Uni Freiburg +# Copyright (c) 2009..2010 - OpenSLX GmbH # # This program/file is free software distributed under the GPL version 2. # See http://openslx.org/COPYING @@ -9,53 +10,158 @@ # send your feedback to feedback@openslx.org # # General information about OpenSLX can be found at http://openslx.org -# -# Include script for running the Virtual Box on an OpenSLX client via the -# run-virt.sh. The stuff is copied to /etc/opt/openslx/run-virtualbox.include -# during stage3. +# ----------------------------------------------------------------------------- +# run-virt.include +# - Include script for running the Virtual Box on an OpenSLX client via the +# run-virt.sh or run-vmgrid.sh +################################################################################ + +################################################################################ +### Include general configuration +################################################################################ +if [ -f ${OPENSLX_DEFAULT_CONFDIR}/plugins/${self}/${self}.conf ]; then + . ${OPENSLX_DEFAULT_CONFDIR}/plugins/${self}/${self}.conf +else + writelog "Problems reading config file of ${self} plugin" + exit 1 +fi + +################################################################################ +### Declaration of default variables +################################################################################ + +PLUGINCONFVIRTUALBOX="${PLUGINCONFROOT}/${self}" +# create TMPDIR for all users +mkdir -m 1777 /tmp/${self} 2>/dev/null +# dir for configs +confdir="/tmp/${self}/${USER}/${VM_ID}" +# use alternate configuration directory instead of $HOME/.VirtualBox +export VBOX_USER_HOME=${confdir} +rm -rf ${VBOX_USER_HOME}/* /tmp/.vbox-${USER}-ipc +machfolder="${VBOX_USER_HOME}/Machines" +# imgname is the name of the virtual image file +# use vm_shortname since vm_name can be very long +vm_shortname=$(echo ${imgname%.*} | sed -e "s, ,-,g") +machconfig="${machfolder}/${vm_shortname}/${vm_shortname}.xml" +diskfolder="${VBOX_USER_HOME}/HardDisks" +snapshotdir=${machfolder}/${vm_shortname}/Snapshots +# imgname is the name of the virtual image file +diskfile="${diskfolder}/${imgname}" +mkdir -p ${diskfolder} ${snapshotdir} +ln -sf ${vmpath} ${diskfile} + +# check the file type +if echo ${imgname} | grep -iE "vdi" >/dev/null 2>&1; then #vmdk|vhd + imgtype=$(echo ${imgname#*.} | tr [a-z] [A-Z]) +else + writelog "${imgname} is not a valid image type (vdi)" #vmdk|vhd +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*) + vmostype="WindowsXP" + ;; + winvista*) + vmostype="WindowsVista" + ;; + Windows7*) + vmostype="Windows7" + ;; + linux*) + vmostype="Linux26" + ;; +esac + +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" + +################################################################################ +### Hardware checks +################################################################################ + +# remove ':' from MAC addr for vbox +macaddr=$(echo ${macaddr} | sed 's/://g') -# include general configuration from vmchooser -. /etc/opt/openslx/run-virt.include +# machine UUID, MAC addr part of it +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}') +# snapshot UUID is static +snapshotuuid="88bc8b6d-f248-468a-95fe-318084904f8b" # memory part equal to vmware plugin # percentage of memory to use for virtualbox in standard case -permem=30 -if [ "${totalmem}" -ge "1600" ]; 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 [ "${totalmem}" -ge "2500" ]; then +if [ -n "${forcemem}" ]; then + mem="${forcemem}" +else + permem=30 + if [ "${totalmem}" -ge "1600" ]; then permem=40 - mkdir /dev/shm/vbox/${USER} - snapshotdir=/dev/shm/vbox/$USER fi -fi -mem=$(expr ${totalmem} / 100 \* ${permem}) -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 + # TODO: makes this sense for vbox? + #if [ "${totalmem}" -ge "2500" ]; then + #permem=40 + #rmdir ${snapshotdir} + #snapshotdirold=${snapshotdir} + #snapshotdir=/dev/shm/${self}/${USER}/${VM_ID} + #mkdir -p ${snapshotdir} + #ln -sf ${snapshotdir} ${snapshotdirold} + #fi + fi + mem=$(expr ${totalmem} / 100 \* ${permem}) + if [ "${id44}" = "1" ]; then + memhost=$(expr ${totalmem} - ${mem}) + else + memhost=$(expr ${totalmem} - ${mem} - ${mem}) + fi + #permem=40 + #mem=$(expr ${totalmem} * ${permem}) + if [ "${mem}" -lt "256" ] || [ "${memhost}" -lt "256" ]; then + writelog "Memory out of range: ${mem} MB (guest) / ${memhost} MB (host)!" + writelog "Min. 256 MB for host and guest!" + exit 1 + fi fi -#permem=40 -#mem=$(expr ${totalmem} * ${permem}) - -if [ "${mem}" -lt "256" ] || [ "${memhost}" -lt "256" ]; then - writelog "\tMemory out of range: ${mem} MB (guest) / ${memhost} MB (host)!" - writelog "\tMin. 256 MB for host and guest!" - exit 1 +# translate network cards +if [ "${network_card}" = "e1000" ]; then + vb_network_card="82540EM" +else + network_card="pcnet" + vb_network_card="Am79C973" fi +# translate network kinds (nat, bridged, host-only) +case "${network_kind}" in + bridged) + network_kind='BridgedInterface name="br0"' + ;; + host-only) + network_kind='HostOnlyInterface name="vboxnet0"' + ;; + *) + network_kind="NAT" + ;; +esac +vrdpport="590${VM_ID}" -# most of the following does not make much sense yet ... -# +# TODO: most of the following does not make much sense yet ... # virtual fd/cd/dvd and drive devices, floppy b: for configuration # if $floppy_0 from run-virt.include set then fdtest="TRUE" fdtest= @@ -79,114 +185,92 @@ cdrom1=${cdtest:-"FALSE"} ide="TRUE" hddrv="ide" +writelog "\tSnapshots dir:\t\t$snapshotdir" +writelog "Diskimage:" +writelog "\tDisk type:\t\t$imgtype" +writelog "\tDisk file:\t\t$diskfile" +writelog "\tVMostype:\t\t$vmostype" +writelog "\tMachine UUID:\t\t$machineuuid" +writelog "\tDisk UUID:\t\t$diskuuid" +writelog "\tSnapshot UUID:\t\t$snapshotuuid" +writelog "Virtual Hardware:" +writelog "\tGuest RAM:\t\t${mem} MB" +# echo nur wenn memhost gesetzt +[ -n "${memhost}" ] && writelog "\tHost RAM:\t\t${memhost} MB" +writelog "\tMAC address:\t\t$macaddr" +writelog "\tNetwork card:\t\t${vb_network_card}" +writelog "\tNetwork kind:\t\t${network_kind}" +#writelog "\tCD-ROM1:\t${cdrom0}" +#writelog "\tCD-ROM2:\t${cdrom1}" +#writelog "\tFloppy_A:\t${floppy0}" ################################################################################ -### Pepare env and and configure Image -################################################################################ - -# Current ID, to make sure it won't run into conflicts if started more -# as once at the same time, else delete would make the trick... -ID=$$ -# Don't use $HOME/.VirtualBox! -export VBOX_USER_HOME="/tmp/vbox-${USER}-${ID}" - -# Import Image to VirtualBox, which won't get changed -VBoxManage -nologo registerimage disk ${diskfile} -type immutable - -# Get ID of VBox Image... -diskuid="$(VBoxManage -nologo showvdiinfo ${diskfile} |grep UUID|awk '{ print $2; }')" -# Create Image and register it, so we are able to modify and start it -VBoxManage -nologo createvm -name "${ID}" -register - -################################################################################ -### -### Modify VM -### +### Pepare and configure virtual machine and disk image ################################################################################ -## Add harddisk -VBoxManage -nologo modifyvm "${ID}" -hda ${diskuid} - -## Configure VM memory -VBoxManage -nologo modifyvm "${ID}" -memory ${mem} - -## Add cddrives -## TODO: merge to new version, where run-virt.include has our drives -#VBoxManage -nologo modifyvm "${ID}" -dvd host:${cdrs} - -# Enable hardware virtualization -# TODO: check if CPU supports hw virtualization -#VBoxManage -nologo modifyvm "${ID}" -hwvirtex on - -# HDD as boot device -VBoxManage -nologo modifyvm "${ID}" -boot1 disk +# TODO: date wichtig? +#date="$(date +%Y-%m-%dT%H:%M:%SZ)" +. ${PLUGINCONFVIRTUALBOX}/virtualbox.include >"${VBOX_USER_HOME}/VirtualBox.xml" -# enable audio (oss|null|none|alsa|pulse). OSS is backwardcompatible to v2.0 -VBoxManage -nologo modifyvm "${ID}" -audio oss +# shortened date YYYY-MM-DD +#date=${date%T*} +. ${PLUGINCONFVIRTUALBOX}/machine.include >"${machconfig}" -# supress License and Message -# TODO: Not clear if we are allowed to do this -VBoxManage -nologo setextradata global "GUI/LicenseAgreed" "7" -VBoxManage -nologo setextradata global "GUI/SuppressMessages" ",remindAboutAutoCapture" -VBoxManage -nologo setextradata global "GUI/RegistrationData" "triesLeft=0" - -# if we have enough memory, we can put the snapshots (changes on immutable -# disk) there -if [ -n ${snapshotdir} ]; then - VBoxManage -nologo modifyvm "${ID}" -snapshotfolder "${snapshotdir}" -fi - -# Operating system. Possible: VBoxManage -nologo list ostypes -# WindowsXP, WindowsVista, Windows7, Linux26 etc. -# keep compatibility to VMware -# Todo: maybe rewrite, to reduce checks, merge it with network option, -# so we can have a "compatibility to vmware config" section. Or include -# it into vmchooser? -if [ "${vmostype}" = "winxppro" -o "${vmostype}" = "WindowsXP" ]; then - VBoxManage -nologo modifyvm "${ID}" -ostype "WindowsXP" -elif [ "${vmostype}" = "winvista" -o "${vmostype}" = "WindowsVista" ]; then - VBoxManage -nologo modifyvm "${ID}" -ostype "WindowsVista" -elif [ "${vmostype}" = "Windows7" ]; then - VBoxManage -nologo modifyvm "${ID}" -ostype "Windows7" -elif [ "${vmostype}" = "linux" -o "${vmostype}" = "Linux26" ]; then - VBoxManage -nologo modifyvm "${ID}" -ostype "Linux26" -elif [ -n "${vmostype}" ]; then - VBoxManage -nologo modifyvm "${ID}" -ostype "${vmostype}" +# add ssh port if linux and NAT +if [ "${vmostype}" = "Linux26" ] && [ "${network_kind}" = "NAT" ]; then + vmsshport="220${VM_ID}" + extradataitem='<ExtraDataItem name="VBoxInternal/Devices' \ + extradataitem="${extradataitem}/${network_card}/0/LUN#0/Config/ssh/" + extradataguestport='GuestPort" value="22"/>' + extradatahostport="HostPort\" value=\"${vmsshport}\"/>" + extradataprotocol='Protocol" value="TCP"/>' + sed -i "s,</ExtraData>, ${extradataitem}${extradataguestport}\n\ + ${extradataitem}${extradatahostport}\n\ + ${extradataitem}${extradataprotocol}\n\ + </ExtraData>," "${machconfig}" + writelog "\tGuest SSH port:\t\t${vmsshport}" fi +cat ${OPENSLX_DEFAULT_DIR}/plugin-repo/virtualbox/empty-diff.vdi.gz | \ + gunzip > "${snapshotdir}/{${snapshotuuid}}.vdi" -# Network Configuration -# only bridge differes to vmware. Compatibility option -if [ "${network_kind}" = "bridge" ]; then - network_kind="bridged" -fi -VBoxManage -nologo modifyvm "${ID}" -nic1 "${network_kind}" -if [ "${network_kind}" = "bridged" ]; then - VBoxManage -nologo modifyvm "${ID}" -bridgeadapter1 "eth1" -fi -if [ "${network_kind}" = "hostonly" ]; then - VBoxManage -nologo modifyvm "${ID}" -hostonlyadapter1 "vboxnet0" -fi - -# modify macaddress -mac=$(echo ${mac}|sed 's/://') # ${mac/:/} -VBoxManage -nologo modifyvm "${ID}" -macaddress1 "0050560D${mac}" +################################################################################ +# finally set env for run-virt.sh +################################################################################ +# 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!!! +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 -# usb configuration -# not available in free -ose version -#VBoxManage -nologo modifyvm "${ID}" -usb on -#VBoxManage -nologo modifyvm "${ID}" -usbehci on +# define dirs and files which can be removed after exit, be carefull! +RMDIRS="${snapshotdir} ${confdir}" +# set the variables appropriately (several interfaces with different names) +VIRTCMD=$(which VirtualBox 2>/dev/null) +VIRTCMDOPTS="--startvm ${machineuuid} --start-running" -# finally set env for run-virt.sh -################################################################################ +# SDL tests +#VIRTCMDSDL=$(which VBoxSDL 2>/dev/null) +#VIRTCMDOPTSSDL="--startvm ${machineuuid} --fullscreen --hwvirtex --memory 1024 \ +# --fixedmode 1680 1050 24 --hostkey 302 0" -# set the variables appropriately (several interfaces with different names) -#VIRTCMD=$(which virtualbox 2>/dev/null) -VIRTCMD=$(which VBoxManage -nologo 2>/dev/null) -VIRTCMDOPTS="startvm ${ID} -type gui" +# set headless mode +VIRTCMDHL=$(which VBoxHeadless 2>/dev/null) +VIRTCMDOPTSHL="-s ${machineuuid}" -# todo: for debugging purpose during development -echo "\n export VBOX_USER_HOME=\"/tmp/vbox-${USER}-${ID}\"" -echo " VBoxManage -nologo $VIRTCMDOPTS\n\n" diff --git a/os-plugins/plugins/vmchooser/files/run-virt.sh b/os-plugins/plugins/vmchooser/files/run-virt.sh index 5733ee41..690a7fea 100644 --- a/os-plugins/plugins/vmchooser/files/run-virt.sh +++ b/os-plugins/plugins/vmchooser/files/run-virt.sh @@ -40,13 +40,14 @@ xml=$1 ################################################################################ # File name of the image -imagename=$(grep -io "<image_name param=.*\"" ${xml} | \ +imgname=$(grep -io "<image_name param=.*\"" ${xml} | \ awk -F "\"" '{ print $2 }') case ${xml} in /tmp/*) # we do not need folder name as it is already included by vmchooser - diskfile=$imagename + diskfile=$imgname + imgname=$(basename ${imgname}) ;; *) # Path to the image @@ -54,18 +55,23 @@ case ${xml} in [ -z $imgpath ] && \ { imgpath=$(readlink -f $xml); imgpath=${imgpath%/*.xml}; } # Diskfile is file including absolute path to it - diskfile=$imgpath/$imagename + diskfile=$imgpath/$imgname ;; esac +# TODO: change to new var vmpath, remove diskfile afterwards +vmpath=$diskfile [ -e $diskfile ] || { echo -e "\n\tImage file $diskfile not found!"; exit 1; } # Short description of the image (as present in the vmchooser menu line) -short_description=$(grep -o "short_description param=.*\"" ${xml} | \ +vm_name=$(grep -o "short_description param=.*\"" ${xml} | \ sed -e "s/&.*;/; /g" | awk -F "\"" '{print $2}') # If ${short_description} not defined use ${image_name} -short_description=${short_description:-"${image_name}"} -displayname=${short_description} +# if ${vm_name} not defined use ${imgname} +vm_name=${vm_name:-"${imgname%.*}"} +displayname=${vm_name} +# remove blanks +vm_name=$(echo ${vm_name} | sed -e "s, ,-,g") # Type of virtual machine to run virt_mach=$(grep -o "virtualmachine param=.*\"" ${xml} | \ @@ -74,7 +80,7 @@ virt_mach=$(grep -o "virtualmachine param=.*\"" ${xml} | \ # Make a guess from the filename extension if ${virt_mach} is empty (not set # within the xml file) if [ -z ${virt_mach} ] ; then - case "$(echo ${imagename##*.}|tr [A-Z] [a-z])" in + case "$(echo ${imgname##*.}|tr [A-Z] [a-z])" in vmdk) virt_mach="vmware" ;; @@ -104,6 +110,9 @@ parallel=$(grep -io '<parport param=.*"' ${xml} | awk -F '"' '{ print $2 }') # Declaration of default variables ############################################################################### +# VM-ID static (0D) +VM_ID="00" + # cpu cores cpu_cores="${cpu_cores}" @@ -114,9 +123,15 @@ totalmem=$(expr $(grep -i "memtotal" /proc/meminfo | awk '{print $2}') / 1024) permem=60 mem=$(expr ${totalmem} / 100 \* ${permem} / 4 \* 4) -# Configuring ethernet mac address: first four bytes are fixed (00:50:56:0D) -# the last two bytes are taken from the first local network adaptor of the host -# system +# 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}') +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}') @@ -223,10 +238,11 @@ writelog () # Logo for console cat <<EOL - .----.--.--.-----.--.--.--.----.-----. - | _| | | | | | | _|_ _| - |__| |_____|__|__|\___/|__|__| |_| -OpenSLX script for preparing virtual machine environment ... + __ __ + .----.--.--.-----.___.--.--.|__|.----.| |_ + | _| | | |___| | || || _|| _| + |__| |_____|__|__| \___/ |__||__| |____| + OpenSLX virtual machine environment preparation script ... EOL @@ -243,15 +259,17 @@ writelog "finished\n" # Copy guest configuration (with added information) config.xml to be accessed # via virtual floppy # fixme -> to be changed (vmchooser adapts the file content!?) -echo "Please fix the config.xml generation" +#TODO: wozu echo? +#echo "Please fix the config.xml generation" cp ${xml} ${PLUGINCONFDIR}/fd-loop/config.xml # Check if virtual machine container file exists -filecheck +#filecheck # Get all virtual machine specific stuff from the respective include file -if [ -e ${PLUGINCONFROOT}/${virt_mach}/run-${virt_mach}.include ] ; then - . ${PLUGINCONFROOT}/${virt_mach}/run-${virt_mach}.include +if [ -e ${PLUGINCONFROOT}/${virt_mach}/run-virt.include ] ; then + self=${virt_mach} + . ${PLUGINCONFROOT}/${virt_mach}/run-virt.include # start a windowmanager for easier handling # (expect problems /w windows opening in background /w vmware without wm) for dm in xfwm4 metacity openbox blackbox kwin fvwm2 ; do @@ -266,7 +284,7 @@ if [ -e ${PLUGINCONFROOT}/${virt_mach}/run-${virt_mach}.include ] ; then fi done ${VIRTCMD} ${VIRTCMDOPTS} - writelog "Bye.\n" + writelog "Bye." exit 0 else writelog "Failed because of missing ${virt_mach} plugin." diff --git a/os-plugins/plugins/vmware/XX_vmware.sh b/os-plugins/plugins/vmware/XX_vmware.sh index cb8683f6..116561f6 100644 --- a/os-plugins/plugins/vmware/XX_vmware.sh +++ b/os-plugins/plugins/vmware/XX_vmware.sh @@ -12,6 +12,10 @@ # script is included from init via the "." load function - thus it has all # variables and functions available +# TODO: +# configs nach /etc/opt/openslx/plugins/vmware +# cp nach run-virt.include + # TODO: nvram,functions # write /etc/vmware/config (if a non-standard location of vmware basedir is # to be configured), /etc/init.d/vmware @@ -159,9 +163,8 @@ ${vmware_imagesrc}." nonfatal prefvmx.useRecommendedLockedMemSize = "TRUE"' | sed -e "s/^ *//" \ >/mnt/etc/vmware/config - # copy version depending files - the vmchooser expects for every virtua- - # lization plugin a file named after it (here run-vmware.include) - cp ${PLUGINDIR}/run-virt.include ${PLUGINCONFDIR}/run-vmware.include + # copy virtualization include files to config dir + cp ${PLUGINDIR}/run-virt.include ${PLUGINCONFDIR} # copy version depending files cp ${PLUGINDIR}/${vmware_kind}/vmplayer ${BINDIR}/vmplayer if [ -e ${PLUGINDIR}/${vmware_kind}/vmware ]; then diff --git a/os-plugins/plugins/vmware/files/run-virt.include b/os-plugins/plugins/vmware/files/run-virt.include index 6328baab..e6866673 100644 --- a/os-plugins/plugins/vmware/files/run-virt.include +++ b/os-plugins/plugins/vmware/files/run-virt.include @@ -1,6 +1,6 @@ # run-virt.include # ----------------------------------------------------------------------------- -# Copyright (c) 2009 - RZ Uni Freiburg +# Copyright (c) 2009..2010 - RZ Uni Freiburg # Copyright (c) 2009..2010 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. @@ -13,7 +13,7 @@ # ----------------------------------------------------------------------------- # run-virt.include # - component for vmware/player of the vmchooser plugin run-virt.sh -# ----------------------------------------------------------------------------- +################################################################################ # configuration writer functions ################################################################################ @@ -451,5 +451,5 @@ writelog "" ################################################################################ # using the modified version of the wrapper script -VIRTCMD=/var/opt/openslx/bin/vmplayer +VIRTCMD="${OPENSLX_DEFAULT_BINDIR}/vmplayer" VIRTCMDOPTS="${vmopt} ${conffile}" diff --git a/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm b/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm index 5e500b49..babc22a7 100644 --- a/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm +++ b/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm @@ -79,4 +79,50 @@ sub suggestAdditionalKernelModules return @suggestedModules; } +sub _xenLabel +{ + # set label for each Xen system + foreach my $info (@$systemInfos) { + if ($info->{xen::active} eq 1) { + my $label = $info->{label} || ''; + if (!length($label) || $label eq $info->{name}) { + if ($info->{name} =~ m{^(.+)::(.+)$}) { + my $system = $1; + my $exportType = $2; + $label = $system . "-xen" . ' ' x (36-length($system)) . $exportType; + } else { + $label = $info->{name}; + } + } + } + $info->{pxeLabel} = $label; + } + return $info; #??? +} + +sub _xenBootEntry +{ + # Xen entries look different + # Example: + # KERNEL mboot.c32 vendor-os/xen.gz dom0_mem=128000 --- + # vendor-os/vmlinuz-xen debug=3 --- vendor-os/initramfs-1 + if ($info->{xen::active} eq 1) { + my $xenKernel = slxsystem(ls /boot/xen* | sort | tail -n 1); + $append .= " file=$bootURI" if length($bootURI); + $append .= " file=$tftpPrefix" if length($tftpPrefix); + $append .= " $clientAppend"; + $append .= " --- $pxePrefix$vendorOSName/$info->{'initramfs-name'}"; + $slxLabels .= "LABEL openslx-$info->{'external-id'}-xen\n"; + # $slxLabels .= $pxeDefault; + $slxLabels .= "\tMENU LABEL ^$info->{pxeLabel}\n"; + $slxLabels .= "\tKERNEL mboot.c32\n"; + $slxLabels .= "\tAPPEND $pxePrefix$vendorOSName/$xenKernel"; + # $slxLabels .= " dom0_mem=128000"; + $slxLabels .= " --- $pxePrefix$vendorOSName/$kernelName"; + $slxLabels .= " --- $append\n"; + $slxLabels .= "\tIPAPPEND 3\n"; + } + return $slxLabels; +} + 1; diff --git a/os-plugins/plugins/xen/init-hooks/10-have-nw-modules/xen.sh b/os-plugins/plugins/xen/init-hooks/10-have-nw-modules/xen.sh deleted file mode 100644 index 321b6a06..00000000 --- a/os-plugins/plugins/xen/init-hooks/10-have-nw-modules/xen.sh +++ /dev/null @@ -1,23 +0,0 @@ -# configure Xen bridge xenbr0 -modprobe ${MODPRV} netloop -local ipls -local vifnum="0" -local bridge="xenbr${vifnum}" -local netdev="eth${vifnum}" -local pdev="p${netdev}" -local vdev="veth${vifnum}" -local vif0="vif0.${vifnum}" -# fixme: that is the mac address of main ethernet device -local mac=`ip link show ${netdev} | grep 'link\/ether' | sed -e 's/.*ether \(..:..:..:..:..:..\).*/\1/'` - -brctl addbr ${bridge} -brctl stp ${bridge} off -brctl setfd ${bridge} 0 -brctl addif ${bridge} ${vif0} -for ipls in "${netdev} name ${pdev}" "${vdev} name ${netdev}" \ - "${pdev} down arp off" "${pdev} addr fe:ff:ff:ff:ff:ff" \ - "${netdev} addr ${mac} arp on" "${bridge} up" "${vif0} up" \ - "${pdev} up" "${netdev} up"; do - ip link set ${ipls} -done -brctl addif ${bridge} ${pdev} diff --git a/os-plugins/plugins/xen/init-hooks/20-nw-bridge-config/xen-bridge.sh b/os-plugins/plugins/xen/init-hooks/20-nw-bridge-config/xen-bridge.sh index 7267969c..8ee244b9 100755 --- a/os-plugins/plugins/xen/init-hooks/20-nw-bridge-config/xen-bridge.sh +++ b/os-plugins/plugins/xen/init-hooks/20-nw-bridge-config/xen-bridge.sh @@ -31,8 +31,8 @@ brctl setfd ${bridge} 0.000000000001 brctl addif ${bridge} ${vif0} for ipls in "${netdev} name ${pdev}" "${vdev} name ${netdev}" \ "${pdev} down arp off" "${pdev} addr fe:ff:ff:ff:ff:ff" \ - "${netdev} addr ${mac} arp on" "${netdev} addr ${mac} arp on" \ - "${bridge} up" "${vif0} up" "${pdev} up" ; do + "${netdev} addr ${mac} arp on" "${bridge} up" "${vif0} up" \ + "${pdev} up" "${netdev} up"; do ip link set ${ipls} done brctl addif ${bridge} ${pdev} |