From 85c3afe09fbdd38acc461aa7965409a1d3ffa858 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Fri, 19 Mar 2010 17:33:16 +0100 Subject: virtualbox, vmgrix und xen anpassungen --- .../virtualbox/OpenSLX/OSPlugin/virtualbox.pm | 59 ++-- os-plugins/plugins/virtualbox/XX_virtualbox.sh | 30 +- .../plugins/virtualbox/files/run-virt.include | 352 +++++++++++++-------- os-plugins/plugins/vmchooser/files/run-virt.sh | 56 ++-- os-plugins/plugins/vmware/XX_vmware.sh | 9 +- os-plugins/plugins/vmware/files/run-virt.include | 6 +- os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm | 46 +++ .../xen/init-hooks/10-have-nw-modules/xen.sh | 23 -- .../init-hooks/20-nw-bridge-config/xen-bridge.sh | 4 +- 9 files changed, 365 insertions(+), 220 deletions(-) delete mode 100644 os-plugins/plugins/xen/init-hooks/10-have-nw-modules/xen.sh (limited to 'os-plugins/plugins') 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='" + extradataprotocol='Protocol" value="TCP"/>' + sed -i "s,, ${extradataitem}${extradataguestport}\n\ + ${extradataitem}${extradatahostport}\n\ + ${extradataitem}${extradataprotocol}\n\ + ," "${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 " 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} -- cgit v1.2.3-55-g7522 From 0da1acc25f8d5f36c660f2d2fa83d1c0240c3909 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Fri, 19 Mar 2010 17:33:58 +0100 Subject: virtualbox, vmgrix und xen anpassungen, jetzt auch geadded --- os-plugins/plugins/virtualbox/files/VirtualBox.xml | 41 +++ .../plugins/virtualbox/files/empty-diff-00.vdi.gz | Bin 0 -> 282 bytes .../plugins/virtualbox/files/empty-diff-01.vdi.gz | Bin 0 -> 279 bytes .../plugins/virtualbox/files/empty-diff-02.vdi.gz | Bin 0 -> 284 bytes .../plugins/virtualbox/files/empty-diff-03.vdi.gz | Bin 0 -> 282 bytes .../plugins/virtualbox/files/empty-diff-04.vdi.gz | Bin 0 -> 282 bytes .../plugins/virtualbox/files/empty-diff.vdi.gz | Bin 0 -> 282 bytes .../plugins/virtualbox/files/machine.include | 132 +++++++++ .../plugins/virtualbox/files/run-virt.include.bak | 159 ++++++++++ .../plugins/virtualbox/files/run-virt2.include | 323 +++++++++++++++++++++ .../plugins/virtualbox/files/virtualbox.include | 47 +++ .../plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm | 244 ++++++++++++++++ os-plugins/plugins/vmgrid/XX_vmgrid.sh | 85 ++++++ os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 310 ++++++++++++++++++++ os-plugins/plugins/vmgrid/files/vmgrid | 195 +++++++++++++ os-plugins/plugins/vmgrid/files/xmlfilter.sh | 50 ++++ .../xen/init-hooks/20-nw-bridge-config/bridge.sh | 30 ++ 17 files changed, 1616 insertions(+) create mode 100644 os-plugins/plugins/virtualbox/files/VirtualBox.xml create mode 100644 os-plugins/plugins/virtualbox/files/empty-diff-00.vdi.gz create mode 100644 os-plugins/plugins/virtualbox/files/empty-diff-01.vdi.gz create mode 100644 os-plugins/plugins/virtualbox/files/empty-diff-02.vdi.gz create mode 100644 os-plugins/plugins/virtualbox/files/empty-diff-03.vdi.gz create mode 100644 os-plugins/plugins/virtualbox/files/empty-diff-04.vdi.gz create mode 100644 os-plugins/plugins/virtualbox/files/empty-diff.vdi.gz create mode 100644 os-plugins/plugins/virtualbox/files/machine.include create mode 100644 os-plugins/plugins/virtualbox/files/run-virt.include.bak create mode 100644 os-plugins/plugins/virtualbox/files/run-virt2.include create mode 100644 os-plugins/plugins/virtualbox/files/virtualbox.include create mode 100644 os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm create mode 100644 os-plugins/plugins/vmgrid/XX_vmgrid.sh create mode 100644 os-plugins/plugins/vmgrid/files/run-vmgrid.sh create mode 100644 os-plugins/plugins/vmgrid/files/vmgrid create mode 100755 os-plugins/plugins/vmgrid/files/xmlfilter.sh create mode 100755 os-plugins/plugins/xen/init-hooks/20-nw-bridge-config/bridge.sh (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/virtualbox/files/VirtualBox.xml b/os-plugins/plugins/virtualbox/files/VirtualBox.xml new file mode 100644 index 00000000..d9a36795 --- /dev/null +++ b/os-plugins/plugins/virtualbox/files/VirtualBox.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/os-plugins/plugins/virtualbox/files/empty-diff-00.vdi.gz b/os-plugins/plugins/virtualbox/files/empty-diff-00.vdi.gz new file mode 100644 index 00000000..24697b58 Binary files /dev/null and b/os-plugins/plugins/virtualbox/files/empty-diff-00.vdi.gz differ diff --git a/os-plugins/plugins/virtualbox/files/empty-diff-01.vdi.gz b/os-plugins/plugins/virtualbox/files/empty-diff-01.vdi.gz new file mode 100644 index 00000000..138e51e8 Binary files /dev/null and b/os-plugins/plugins/virtualbox/files/empty-diff-01.vdi.gz differ diff --git a/os-plugins/plugins/virtualbox/files/empty-diff-02.vdi.gz b/os-plugins/plugins/virtualbox/files/empty-diff-02.vdi.gz new file mode 100644 index 00000000..1355f373 Binary files /dev/null and b/os-plugins/plugins/virtualbox/files/empty-diff-02.vdi.gz differ diff --git a/os-plugins/plugins/virtualbox/files/empty-diff-03.vdi.gz b/os-plugins/plugins/virtualbox/files/empty-diff-03.vdi.gz new file mode 100644 index 00000000..6e66af70 Binary files /dev/null and b/os-plugins/plugins/virtualbox/files/empty-diff-03.vdi.gz differ diff --git a/os-plugins/plugins/virtualbox/files/empty-diff-04.vdi.gz b/os-plugins/plugins/virtualbox/files/empty-diff-04.vdi.gz new file mode 100644 index 00000000..ddb8bb5f Binary files /dev/null and b/os-plugins/plugins/virtualbox/files/empty-diff-04.vdi.gz differ diff --git a/os-plugins/plugins/virtualbox/files/empty-diff.vdi.gz b/os-plugins/plugins/virtualbox/files/empty-diff.vdi.gz new file mode 100644 index 00000000..24697b58 Binary files /dev/null and b/os-plugins/plugins/virtualbox/files/empty-diff.vdi.gz differ diff --git a/os-plugins/plugins/virtualbox/files/machine.include b/os-plugins/plugins/virtualbox/files/machine.include new file mode 100644 index 00000000..7488126a --- /dev/null +++ b/os-plugins/plugins/virtualbox/files/machine.include @@ -0,0 +1,132 @@ +# Include file (machine template) for run-virt.include of the virtualbox plugin +cat < + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <${network_kind}/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +EOF diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include.bak b/os-plugins/plugins/virtualbox/files/run-virt.include.bak new file mode 100644 index 00000000..2fd81f6b --- /dev/null +++ b/os-plugins/plugins/virtualbox/files/run-virt.include.bak @@ -0,0 +1,159 @@ +# run-virtualbox.include +# +# Copyright (c) 2009, 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 +# +# Include script for running the Virtual Box on an OpenSLX client via the +# run-virt.sh. The stuff is copied to /etc/opt/openslx/virtualbox/run- +# virtualbox.include during stage3. + +################################################################################ +### General settings +################################################################################ + +# include general configuration from vmchooser +. /etc/opt/openslx/plugins/virtualbox/virtualbox.conf + +# 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=$$ +machname="$(basename ${diskfile})" +machname=${machname%.*} +# use alternate configuration directory instead of $HOME/.VirtualBox +export VBOX_USER_HOME="/tmp/vbox-${USER}" +rm -rf ${VBOX_USER_HOME}/* /tmp/.vbox-${USER}-ipc +machfolder="${VBOX_USER_HOME}/Machines" +machconfig="${machfolder}/${machname}/${machname}.xml" +diskfolder="${VBOX_USER_HOME}/HardDisks" +mkdir -p ${machfolder}/${machname}/Snapshots ${diskfolder} +ln -sf ${diskfile} ${diskfolder}/${machname}.vdi +# Get ID of VBox Image... +diskuid="$(VBoxManage -nologo showvdiinfo ${diskfile} |grep UUID|awk '{ print $2; }')" +# produce proper mac address format +mac="0050560d$(echo ${mac}|sed 's/://;y/ABCDEF/abcdef/')" +date="$(date +%Y-%m-%dT%H:%M:%SZ)" + +# Operating system. Possible: VBoxManage -nologo list ostypes: WindowsXP, +# WindowsVista, Windows7, Linux26 etc. +# keeps compatibility to vmware plugin run-virt.include +# Todo: maybe rewrite, to reduce checks, merge it with network option, +# so we can have a "compatibility to vmware config" section +if [ "${vmostype}" = "winxppro" ]; then vmostype="WindowsXP" +elif [ "${vmostype}" = "winvista" ]; then vmostype="WindowsVista" +elif [ "${vmostype}" = "Windows7" ]; then vmostype="Windows7" +elif [ "${vmostype}" = "linux" ]; then vmostype="Linux26" +elif [ -n "${vmostype}" ]; then vmostype="${vmostype}" +fi +# translate network kinds (nat, bridged, host-only) +if [ "${network_kind}" = "nat" ]; then network_kind="NAT" +elif [ "${network_kind}" = "bridged" ]; then network_kind="" +elif [ "${network_kind}" = "host-only" ]; then network_kind="" +fi + +# 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 + 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}) +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 +fi + +# 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= +fdtest=${floppy_0:+"TRUE"} +# if $fdtest not set floppy0="FALSE", else "TRUE" +floppy0=${fdtest:-"FALSE"} +floppy1="TRUE" +floppy1name="/var/lib/virt/vmchooser/loopimg/fd.img" +# if $cdrom_0 from run-virt.include set then cdtest="TRUE" +cdtest= +cdtest=${cdrom_0:+"TRUE"} +# if $cdtest not set cdrom0="FALSE", else "TRUE" +cdrom0=${cdtest:-"FALSE"} +# if $cdrom_1 from run-virt.include set then cdtest="TRUE" +cdtest= +cdtest=${cdrom_1:+"TRUE"} +# if $cdtest not set cdrom1="FALSE", else "TRUE" +cdrom1=${cdtest:-"FALSE"} +# ide is expected default, test for the virtual disk image type should +# be done while creating the runscripts ... +ide="TRUE" +hddrv="ide" + + +################################################################################ +### Pepare and configure virtual machine and disk image +################################################################################ + +# produce the machine configuration XML +sed -e "s,MACHINE,${machname},g;s,OSTYPE,${vmostype},;s,MEMSIZE,${mem}," \ + -e "s,DISKUID,${diskuid},;s,MACADDR,${mac},;s,DATE,${date}," \ + -e "s,NETTYPE,${network_kind},;s,OPTDEVICE,/dev/sr0," \ + /etc/opt/openslx/plugins/virtualbox/MachineTemplate.xml \ + >${machconfig} + +# shortened date YYYY-MM-DD +date=${date%T*} +# produce the general and containers configuration file +sed -e "s,DISKUID,${diskuid},;s,FD1NAME,${floppy1name},;s,DATE,${date}," \ + -e "s,DISKFILE,${diskfolder}/${machname}.vdi,;s,MACHINE,${machname},g;s,MACADDR,${mac}," \ + -e "s,MACHFOLDER,${machfolder},;s,DISKFOLDER,${diskfolder}," \ + /etc/opt/openslx/plugins/virtualbox/VirtualBox.xml \ + >${VBOX_USER_HOME}/VirtualBox.xml + +cat /opt/openslx/plugin-repo/virtualbox/empty-diff.vdi.gz | \ + gunzip >${machfolder}/${machname}/Snapshots/{88bc8b6d-f248-468a-95fe-318084904f8b}.vdi + + +#\t + +# finally set env for run-virt.sh +################################################################################ + +# wait for a certain command to settle +while [ TRUE ] ; do + ps aux|grep -v grep|grep -q VBoxSVC || break +done +# set the variables appropriately (several interfaces with different names) +VIRTCMD=$(which VirtualBox 2>/dev/null) +VIRTCMDOPTS="--startvm 00000000-1111-2222-3456-${mac} --start-running" diff --git a/os-plugins/plugins/virtualbox/files/run-virt2.include b/os-plugins/plugins/virtualbox/files/run-virt2.include new file mode 100644 index 00000000..4f885abd --- /dev/null +++ b/os-plugins/plugins/virtualbox/files/run-virt2.include @@ -0,0 +1,323 @@ +# 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 +# +# 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 +# ----------------------------------------------------------------------------- +# 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}" +# use alternate configuration directory instead of $HOME/.VirtualBox +export VBOX_USER_HOME=${confdir} + +# imgname is the name of the virtual image file +imgnamebase=${imgname%.*} +imgnameending=${imgname#*.} +# use vm_shortname since vm_name can be very long + VM_ID +vm_shortname="$(echo ${imgnamebase} | sed -e "s, ,-,g")-${VM_ID}" + +# mach folders config +machfolder="${confdir}/Machines" +machconfig="${machfolder}/${vm_shortname}/${vm_shortname}.xml" +diskfolder="${confdir}/HardDisks" +snapshotdir=${machfolder}/${vm_shortname}/Snapshots +diskfile="${diskfolder}/${imgname}" + +# remove old stuff, RMDIRS can be used in calling script as well +RMDIRS="${machfolder}/${vm_shortname} ${diskfile}" +rm -rf ${RMDIRS} +# create new stuff +mkdir -p ${diskfolder} ${snapshotdir} +# check if image already existing +if [ "$(readlink -f ${diskfile})" = "${vmpath}" ]; then + diskuuid=$(grep "${diskfile}" "${confdir}/VirtualBox.xml" | \ + sed -e "s,.*HardDisk uuid=\"{\(.*\)}\" location=.*,\1,") + diskexisting=1 +else + ln -sf ${vmpath} ${diskfile} +fi + +# check the file type +if echo ${imgname} | grep -iE "vdi" >/dev/null 2>&1; then #vmdk|vhd + imgtype=$(echo ${imgnameending} | 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') + +# memory part equal to vmware plugin +# percentage of memory to use for virtualbox in standard case +if [ -n "${forcemem}" ]; then + mem="${forcemem}" +else + 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 + # TODO: makes this sense for vbox? + #if [ "${totalmem}" -ge "2500" ]; then + #permem=40 + #rmdir ${snapshotdir} + #snapshotdirold=${snapshotdir} + #snapshotdir=/dev/shm/${self}/${USER} + #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 + +# 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 +[ -z "${diskuuid}" ] && diskuuid=$(VBoxManage -q showvdiinfo ${diskfile} | \ + grep UUID | awk '{print $2}') +# snapshot UUIDs (static) +snapshotuuid[00]="88bc8b6d-f248-468a-95fe-318084904f8b" +snapshotuuid[01]="42f5033e-9913-41ff-8cba-1c986ba5db8d" +snapshotuuid[02]="1b66fdcb-8ede-4bb8-aaec-417bc2074633" +snapshotuuid[03]="563d2c5e-c9a2-4fbb-be51-8d279a558e6c" +snapshotuuid[04]="efff0c85-c1c8-420d-a25f-6e66f117e1f2" +snapshotuuid=${snapshotuuid[$VM_ID]} + +cat ${OPENSLX_DEFAULT_DIR}/plugin-repo/virtualbox/empty-diff-${VM_ID}.vdi.gz | \ + gunzip > "${snapshotdir}/{${snapshotuuid}}.vdi" + +#snapshotuuid=$(VBoxManage -q showvdiinfo \ +# "${snapshotdir}/${snapshotuuid}.vdi" | grep UUID | awk '{print $2}') + +# 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}" + +# 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= +fdtest=${floppy_0:+"TRUE"} +# if $fdtest not set floppy0="FALSE", else "TRUE" +floppy0=${fdtest:-"FALSE"} +floppy1="TRUE" +floppy1name="/var/lib/virt/vmchooser/loopimg/fd.img" +# if $cdrom_0 from run-virt.include set then cdtest="TRUE" +cdtest= +cdtest=${cdrom_0:+"TRUE"} +# if $cdtest not set cdrom0="FALSE", else "TRUE" +cdrom0=${cdtest:-"FALSE"} +# if $cdrom_1 from run-virt.include set then cdtest="TRUE" +cdtest= +cdtest=${cdrom_1:+"TRUE"} +# if $cdtest not set cdrom1="FALSE", else "TRUE" +cdrom1=${cdtest:-"FALSE"} +# ide is expected default, test for the virtual disk image type should +# be done while creating the runscripts ... +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 and configure virtual machine and disk image +################################################################################ + +# TODO: date wichtig? +#date="$(date +%Y-%m-%dT%H:%M:%SZ)" +# check if VirtualBox.xml already existing +# TODO: geht nicht!!! +if grep -q "" + extdiff="" + if [ -z "${diskexisting}" ]; then + sed -i "s,, ${extrahd}\n ${extdiff}\n\ + \n ," \ + "${confdir}/VirtualBox.xml" + elif [ ${diskexisting} -eq 1 2>/dev/null ]; then + sed -i "s,\(" + if ! grep -q "${extramach}" "${confdir}/VirtualBox.xml"; then + sed -i "s,, ${extramach}\n ," \ + "${confdir}/VirtualBox.xml" + fi +else + . ${PLUGINCONFVIRTUALBOX}/virtualbox.include > \ + "${confdir}/VirtualBox.xml" +fi + +# shortened date YYYY-MM-DD +#date=${date%T*} +. ${PLUGINCONFVIRTUALBOX}/machine.include >"${machconfig}" + +# add ssh port if linux and NAT +if [ "${vmostype}" = "Linux26" ] && [ "${network_kind}" = "NAT" ]; then + vmsshport="220${VM_ID}" + extradataitem='" + extradataprotocol='Protocol" value="TCP"/>' + sed -ni "s,, ${extradataitem}${extradataguestport}\n\ + ${extradataitem}${extradatahostport}\n\ + ${extradataitem}${extradataprotocol}\n\ + ," "${machconfig}" + writelog "\tGuest SSH port:\t\t${vmsshport}" +fi + +################################################################################ +# 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 + +# set the variables appropriately (several interfaces with different names) +VIRTCMD=$(which VirtualBox 2>/dev/null) +VIRTCMDOPTS="--startvm ${machineuuid} --start-running" + +# SDL tests +#VIRTCMDSDL=$(which VBoxSDL 2>/dev/null) +#VIRTCMDOPTSSDL="--startvm ${machineuuid} --fullscreen --hwvirtex --memory 1024 \ +# --fixedmode 1680 1050 24 --hostkey 302 0" + +# set headless mode +VIRTCMDHL=$(which VBoxHeadless 2>/dev/null) +VIRTCMDOPTSHL="-s ${machineuuid}" + diff --git a/os-plugins/plugins/virtualbox/files/virtualbox.include b/os-plugins/plugins/virtualbox/files/virtualbox.include new file mode 100644 index 00000000..e0c41290 --- /dev/null +++ b/os-plugins/plugins/virtualbox/files/virtualbox.include @@ -0,0 +1,47 @@ +# Include file (general template) for run-virt.include of the virtualbox plugin +cat < + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +EOF diff --git a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm new file mode 100644 index 00000000..a4f08bc1 --- /dev/null +++ b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm @@ -0,0 +1,244 @@ +# Copyright (c) 2008, 2009 - OpenSLX GmbH +# +# This program 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 suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# vmgrid.pm +# - ... +# ----------------------------------------------------------------------------- +package OpenSLX::OSPlugin::vmgrid; + +use strict; +use warnings; + +use base qw(OpenSLX::OSPlugin::Base); + +use OpenSLX::Basics; +use OpenSLX::Utils; + +sub new +{ + my $class = shift; + + my $self = { + name => 'vmgrid', + }; + + return bless $self, $class; +} + +# TODO: desc +sub getInfo +{ + my $self = shift; + + return { + description => unshiftHereDoc(<<' End-of-Here'), + ... + End-of-Here + precedence => 80, + #required => [ qr{^(vmware|virtualbox|qemukvm|xen)$} ], + #openvz|vserver + # TODO: virtaul plugin (requires, provides?) + #required => [ qw( virtualization ) ], + #provided => [ qw( virtualization ) ], + }; +} + +sub getAttrInfo +{ + my $self = shift; + + return { + 'vmgrid::active' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + should the 'vmgrid'-plugin be executed during boot? + End-of-Here + content_regex => qr{^(0|1)$}, + content_descr => '1 means active - 0 means inactive', + default => '1', + }, + 'vmgrid::virt' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + which virtualization technique schould be used? + End-of-Here + content_regex => qr{^(vmware|virtualbox|qemukvm|xen)$}, + #openvz|vserver + content_descr => 'possible values: vmware, virtualbox, qemukvm, xen', + #openvz, vserver + default => undef, + }, + 'vmgrid::roshare' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + do you want to mount external resources? + e.g. NFS share /w virt images ... + will be mounted to /var/lib/virt/vmgrid + End-of-Here + content_regex => qr{^nfs://}, + content_descr => 'NFS share as URI (nfs://...)', + default => undef, + }, + 'vmgrid::rwshare' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + do you want a persistent storage device? + use local hard drive (ID45) or NFS share. + will be mounted to /var/opt/openslx/plugins/vmgrid/share + End-of-Here + content_regex => qr{^(id45|nfs://)}, + content_descr => 'NFS share as URI (nfs://...) or "id45"', + default => undef, + }, + 'vmgrid::imgpath' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + location of virtual images + for starts /wo full path + End-of-Here + content_descr => 'absolute path to vm image files', + default => '/var/lib/virt/vmgrid/images', + }, + 'vmgrid::xmlpath' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + location of XML configuration for virtual images + for starts /wo full path + End-of-Here + content_descr => 'absolute path to vm xml files', + default => '/var/lib/virt/vmgrid/xml', + }, + 'vmgrid::startvms' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + which virtaul machines should be started per default + comma separated list. first will be started first, + second second, and so on, max. 4 VMs + End-of-Here + content_descr => 'name of xml file e.g. scilin-5.4-wn(.xml)', + default => undef, + }, + 'vmgrid::hvm' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + use hardware virtualization, if applicable + override the settings of the corresponding virt plugin + (only if supported by plugin) + End-of-Here + content_regex => qr{^(0|1)$}, + content_descr => 'possible values: "0", "1" or "-" (for unset)', + default => undef, + }, + 'vmgrid::maxvcpus' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + use this number of vcpus as maximum for one vm + will be used only if applicable + (only if supported by plugin) + End-of-Here + content_regex => qr{^(1|2|4|8|16)$}, + content_descr => 'possible values: 1, 2, 4, 8, 16', + default => undef, + }, + 'vmgrid::minvcpus' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + use this number of vcpus as minimum for one vm + will be used only if applicable + (only if supported by plugin) + End-of-Here + content_regex => qr{^(1|2|4|8|16)$}, + content_descr => 'possible values: 1, 2, 4, 8, 16', + default => undef, + }, + 'vmgrid::memratio' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + define memory ratio in nn% + order: grid client 1, 2, 3, 4, other VMs, host + if desktop virtualization defined the free memory will be + distributed between the remaining grid clients, + according to their ratio + if less than 4 VMs defined in startvms the memory is being + reserved for a later manual start + set to 0 if you don't intend to start them manually + (only if supported by plugin) + End-of-Here + content_regex => qr{^(\d\d??,\d\d??,\d\d??,\d\d??,\d\d??,\d\d??)$}, + content_descr => 'vals: \d\d??,\d\d??,\d\d??,\d\d??,\d\d??,\d\d??', + default => '40,0,0,0,40,20', + }, + 'vmgrid::maxram' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + maximum of RAM used for ALL vms + will be used only if applicable + (only if supported by plugin) + End-of-Here + content_regex => qr{^(1|2|3|4|5|6|7|8|9)}, + content_descr => 'values can be absolute or relative e.g. 512 or 50%', + default => undef, + }, + 'vmgrid::minram' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + minimum of RAM used for ALL vms + will be used only if applicable + (only if supported by plugin) + End-of-Here + content_regex => qr{^(1|2|3|4|5|6|7|8|9)}, + content_descr => 'values can be absolute or relative e.g. 512 or 50%', + default => undef, + }, + }; +} + +sub installationPhase +{ + my $self = shift; + my $info = shift; + + my $pluginRepoPath = $info->{'plugin-repo-path'}; + my $openslxBasePath = $info->{'openslx-base-path'}; + + # copy all needed files now: + my $pluginName = $self->{'name'}; + my $pluginBasePath = "$openslxBasePath/lib/plugins/$pluginName/files"; + foreach my $file ( qw( vmgrid run-vmgrid.sh ) ) { + copyFile("$pluginBasePath/$file", "$pluginRepoPath/"); + chmod 0755, "$pluginRepoPath/$file"; + } + + return; +} + +sub removalPhase +{ + my $self = shift; + my $info = shift; + + return; +} + +1; + diff --git a/os-plugins/plugins/vmgrid/XX_vmgrid.sh b/os-plugins/plugins/vmgrid/XX_vmgrid.sh new file mode 100644 index 00000000..7aa7dba5 --- /dev/null +++ b/os-plugins/plugins/vmgrid/XX_vmgrid.sh @@ -0,0 +1,85 @@ +# 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 + +# include default directories +. /etc/openslx.conf + +CONFFILE="/initramfs/plugin-conf/vmgrid.conf" +PLUGINCONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/vmgrid +VIRTUALIZATIONPLUGIN=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/virtualization +RWSHARE=/mnt/${OPENSLX_DEFAULT_VARDIR}/plugins/vmgrid/share +BINDIR=/mnt/${OPENSLX_DEFAULT_BINDIR} +PLUGINDIR=${OPENSLX_DEFAULT_DIR}/plugin-repo/vmgrid +VIRTDIR=/mnt/${OPENSLX_DEFAULT_VIRTDIR}/vmgrid +LOGDIR=/mnt/${OPENSLX_DEFAULT_LOGDIR} + +if [ -f $CONFFILE ]; then + + # load needed variables + . $CONFFILE + + if [ $vmgrid_active -ne 0 ] ; then + [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'vmgrid' os-plugin ..." + + # load general configuration + . /initramfs/machine-setup + + testmkd ${PLUGINCONFDIR} + # create folder for virtual virtualization plugin + testmkd ${VIRTUALIZATIONPLUGIN} + testmkd ${VIRTDIR} + cp $CONFFILE ${PLUGINCONFDIR}/vmgrid.conf + # create link to binpath + ln -fs ${PLUGINDIR}/vmgrid ${BINDIR}/vmgrid + ln -fs ${PLUGINDIR}/run-vmgrid.sh ${BINDIR}/run-vmgrid.sh + + # mount nfs virt ro share + if strinstr "nfs://" "${vmgrid_roshare}"; then + virtsrcprot=$(uri_token ${vmgrid_roshare} prot) + virtsrcserv=$(uri_token ${vmgrid_roshare} server) + virtsrcpath="$(uri_token ${vmgrid_roshare} path)" + if [ -n "${virtsrcprot}" -a -n "${virtsrcserv}" -a -n "${virtsrcpath}" ]; + then + virtsrctarget=${VIRTDIR} + # mount the vmgrid source ro + fsmount ${virtsrcprot} ${virtsrcserv} ${virtsrcpath} ${virtsrctarget} \ + ro + fi + fi + + # bind mount id 45 to ${RWSHARE} + if strinstr "id45" "${vmgrid_rwshare}" ; then + if grep "/mnt/var/scratch " /proc/mounts; then + mount --bind -n /mnt/var/scratch ${RWSHARE} >${LOGDIR}/vmgrid.log 2>&1 + fi + # mount nfs rw share + elif strinstr "nfs://" "${vmgrid_rwshare}" ; then + rwshareprot=$(uri_token ${vmgrid_rwshare} prot) + rwshareserv=$(uri_token ${vmgrid_rwshare} server) + rwsharepath="$(uri_token ${vmgrid_rwshare} path)" + if [ -n "${rwshareprot}" -a -n "${rwshareserv}"-a -n "${rwsharepath}" ]; + then + rwtarget=${RWSHARE} + # mount the vmgrid source rw + fsmount ${rwshareprot} ${rwshareserv} ${rwsharepath} ${rwtarget} rw + fi + fi + + # TODO: virtual virtualization plugin + + # finished ... + [ $DEBUGLEVEL -gt 0 ] && echo "done with 'vmgrid' os-plugin ..." + fi +[ $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 new file mode 100644 index 00000000..c8ebb1a1 --- /dev/null +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -0,0 +1,310 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# Copyright (c) 2007..2010 - RZ Uni FR +# Copyright (c) 2007..2010 - OpenSLX GmbH +# +# This program 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 suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# vmgrid +# - This is the generic wrapper for the several virtualization solutions... +################################################################################ + +. /etc/opt/openslx/openslx.conf + +################################################################################ +### Functions used throughout the script +################################################################################ + +# function to write to stdout and logfile +writelog () { + # write to stdout + echo -e "$1" + # log into file + echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log +} + +################################################################################ +### Define default dirs / get configs +################################################################################ + +PLUGINCONFROOT=${OPENSLX_DEFAULT_CONFDIR}/plugins +PLUGINCONFVMGRID=${PLUGINCONFROOT}/vmgrid +# include general configuration from vmgrid +[ -f ${PLUGINCONFVMGRID}/vmgrid.conf ] && \ + . ${PLUGINCONFVMGRID}/vmgrid.conf +#[ -f ${PLUGINCONFVMGRID}/vmgrid.include ] && \ +# . ${PLUGINCONFVMGRID}/vmgrid.include +# get the vmchooser_active var +[ -f ${PLUGINCONFROOT}/vmchooser/vmchooser.conf ] && \ + . ${PLUGINCONFROOT}/vmchooser/vmchooser.conf + +################################################################################ +### Get XML file and dir +################################################################################ + +# check if forcemem set +if [ "$1" = "--forcemem" ]; then + forcemem=$2 + xmlfile=${3##*/} +else + xmlfile=${1##*/} +fi + +# absolute or relative path? +if ls ${1} 2>/dev/null | grep '/' >/dev/null 2>&1; then + xmlpath=$(dirname ${1}) +else + xmlpath=${vmgrid_xmlpath} +fi +# full path +xmlfile="${xmlpath}/${xmlfile%.xml}.xml" + +################################################################################ +### Sanity checks +################################################################################ + +# test if the xml file is valid +if ! [ -r "${xmlfile}" ]; then + echo -e "Usage: run-vmgrid.sh [--forcemem ] \c" + echo -e "[/path/]filename[.xml]" + exit 1 +fi + +# test how many instances running +runningvms=$(ps aux | grep "run-vmgrid.sh " | grep -v grep | wc -l) +runningvms=$(expr ${runningvms} - 1) +# check value +if [ $runningvms -le 0 ]; then + writelog "Error in value: Running VMs: ${runningvms}. Exit!" + exit 1 +fi +# check if vmchooser plugin installed +if [ ${vmchooser_active} = "1" 2>/dev/null] && [ ${runningvms} -gt 1 ]; then + # only allow one instance of vmgrid + writelog "Already 1 VMs running and vmchooser plugin is active." + writelog "Can't start ${xmlfile}, exiting!" + exit 1 +# else allow max. 4 instances +elif [ ${runningvms} -gt 4 ]; then + writelog "Already 4 VMs running, exiting!" + exit 1 +fi +VM_ID="0${runningvms}" + +# test if XML file +if ! grep '/dev/null 2>&1; then + writelog \ + "Submitted configuration file ${xmlfile} seems to have wrong XML format" + exit 1 +fi + +################################################################################ +### Logo for console +################################################################################ + +cat </dev/null 2>&1; then + writelog \ + "\tSubmitted configuration file ${xmlfile} seems to have wrong XML format" + exit 1 +fi + +writelog "\tXML file:\t\t$xmlfile" + +imgpath=${vmgrid_imgpath} + +# name of the virt image of dir +imgname=$(grep -io 'image_name param=.*"' ${xmlfile} | sed -e "s/&.*;/; /g" | \ + awk -F '"' '{ print $2 }') +# full path +vmpath=${imgpath}/${imgname} + +# check if virtual machine container file exists +if ! [ -e $vmpath ]; then + writelog "\tVirtual machine image or directory ${vmpath} not found!" + exit 1 +fi + +writelog "\tVM file/dir:\t\t$vmpath" + +# name of the virt machine, sed because of Windows formatting +vm_name=$(grep -o 'short_description param=.*"' ${xmlfile} | \ + sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}') + +# is there an additional configuration provided? +additional_config=$(grep -o 'additional_config param=.*"' ${xmlfile} | \ + sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}') + +# if ${vm_name} not defined use ${imgname} +vm_name=${vm_name:-"${imgname%.*}"} +displayname=${vm_name} +# remove blanks + +# image is for the following virtual machine +xmlvirt=$(grep -o 'virtualmachine param=.*"' ${xmlfile} | \ + sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}') + +# make a guess from the filename extension if ${xmlvirt} is empty +# (not set within the XML file) +if [ -z "${xmlvirt}" ] && [ -n "${additional_config}" ]; then + writelog "\tNo virtual machine parameter defined in ${xmlfile}" + writelog "\tTrying to guess VM...\c" + case "$(cat ${additional_config} | tr [A-Z] [a-z])" in + *config.version*|*virtualhw.version*|*independent-nonpersistent*|*vmdk*) + xmlvirt="vmware" + ;; + *innotek*|*virtualbox*) + xmlvirt="virtualbox" + ;; + *qemu*|*kvm*) + xmlvirt="qemukvm" + ;; + *) + xmlvirt="none" + ;; + esac +elif [ -z "${xmlvirt}" ]; then + case "$(echo ${imgname##*.} | tr [A-Z] [a-z])" in + vmdk) + xmlvirt="vmware" + ;; + vbox) + xmlvirt="virtualbox" + ;; + img|qcow*) + xmlvirt="qemukvm" + ;; + *) + xmlvirt="none" + ;; + esac + writelog "result:\t${xmlvirt}" +fi + +# TODO: confs von openvz lesen? +if [ "${vmgrid_virt}" != "${xmlvirt}" ]; then + writelog "\tThe virtual machine specified in ${xmlfile}" + writelog "\tdoes not match the virtualization used here (${vmgrid_virt})" + exit 1 +fi + +# definition of the client system +vmostype=$(grep -io '/dev/null | grep ${vmgrid_virt} >/dev/null 2>&1; then + rm -rf ${RMDIRS} >/dev/null 2>&1 +fi +writelog "done" +writelog "Bye." + +exit 0 diff --git a/os-plugins/plugins/vmgrid/files/vmgrid b/os-plugins/plugins/vmgrid/files/vmgrid new file mode 100644 index 00000000..66291aea --- /dev/null +++ b/os-plugins/plugins/vmgrid/files/vmgrid @@ -0,0 +1,195 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# Copyright (c) 2007..2010 - RZ Uni FR +# Copyright (c) 2007..2010 - OpenSLX GmbH +# +# This program 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 suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# vmgrid +# - Script for autostarts defined in vmgrid::startvms +################################################################################ + +# include default directories +. /etc/opt/openslx/openslx.conf + +################################################################################ +### Manual Start +################################################################################ + +if [ -n "$1" ]; then + if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then + echo "Usage: vmgrid [[/path/]filename[.xml]]" + exit 0 + else + run-vmgrid.sh $1 & + exit 0 + fi +fi + +################################################################################ +### Functions used throughout the script +################################################################################ + +# function to write to stdout and logfile +writelog () { + # write to stdout + echo -e "$1" + # log into file + echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log +} + +################################################################################ +### Define default dirs / get configs +################################################################################ + +PLUGINCONFROOT=${OPENSLX_DEFAULT_CONFDIR}/plugins +PLUGINCONFDIR=${PLUGINCONFROOT}/vmgrid +# include general configuration from vmgrid +[ -f ${PLUGINCONFDIR}/vmgrid.conf ] && \ + . ${PLUGINCONFDIR}/vmgrid.conf +# get the vmchooser_active var +[ -f ${PLUGINCONFROOT}/vmchooser/vmchooser.conf ] && \ + . ${PLUGINCONFROOT}/vmchooser/vmchooser.conf + +################################################################################ +### Configure VMs for autostart and set RAM +################################################################################ + +# remove blanks +vmgrid_memratio=$(echo ${vmgrid_memratio} | sed -e "s, *,,g") +vmgrid_startvms=$(echo ${vmgrid_startvms} | sed -e "s, *,,g") + +# get total amount of memory installed in your machine +# TODO: stage 3? virtaulization plugin +totalmem=$(expr $(grep -i "memtotal" /proc/meminfo | awk '{print $2}') / 1024) + +# get hostmem +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 [ ${vmchooser_active} -eq 1 ]; 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 + +# calculate freemem +freemem=$(expr ${totalmem} - ${hostmem} - ${othervmmem} 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 + vm[$i]=$(echo ${vmgrid_startvms} | awk -F ',' '{print $1}') + # remove ${vm[$i]} from list because of '{print $1}' + vmgrid_startvms=$(echo ${vmgrid_startvms} | sed -e "s/${vm[$i]},*//") + vmratio[$i]=$(echo ${vmgrid_memratio} | awk -F ',' '{print $1}') + # remove ${vmratio[$i]} from list because of '{print $1}' + vmgrid_memratio=$(echo ${vmgrid_memratio} | sed -e "s/${vmratio[$i]},*//") + 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 + # multiple of 4 + vmmem[$i]=$(expr ${freemem} \* ${vmratio[$i]} / ${restratio} / 4 \* 4 \ + 2>/dev/null) + if [ -n "${vm[$i]}" ] && [ ${vmmem[$i]} -lt 512 2>/dev/null ]; then + writelog "Not enough free RAM for ${vm[$i]} (min. 512 MB), \c" + writelog "free: ${vmmem[$i]} MB" + unset vm[$i] + fi +done + +################################################################################ +### Start the VMs +################################################################################ + +# start vms +for i in {1..4}; do + if [ -n "${vm[$i]}" ]; then + alreadyrunning=$(ps aux | grep run-vmgrid.sh | grep -v grep | \ + grep "${vm[$i]}" | wc -l) + if [ ${alreadyrunning} -gt 0 2>/dev/null ]; then + 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]} & + # wait 5 secs for the next vm to start + sleep 5 + fi + fi +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/files/xmlfilter.sh b/os-plugins/plugins/vmgrid/files/xmlfilter.sh new file mode 100755 index 00000000..5196992c --- /dev/null +++ b/os-plugins/plugins/vmgrid/files/xmlfilter.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# ----------------------------------------------------------------------------- +# Copyright (c) 2007..2009 - RZ Uni FR +# Copyright (c) 2007..2009 - OpenSLX GmbH +# +# This program 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 suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# xmlfilter.sh +# - This script is invoked by the vmchooser tool. It simply filters xml- +# files (taking the path to these files in $1). You might modify it in any +# way to match your needs, e.g. ask some database instead. You can re- +# implement it in any other programming language too. You simply have to +# return a list of proper xml files to be interpreted by the vmchooser +# binary). Please check for vmchooser.sh too ... +# ----------------------------------------------------------------------------- + +# This script . +# +# currently: +# - filter for slxgrp (which comes from /etc/machine-setup) +# + +# include default directories +. /etc/opt/openslx/openslx.conf + +if [ -f ${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.conf ]; then + . ${OPENSLX_DEFAULT_CONFDIR}/plugins/vmchooser/vmchooser.conf +fi + +for FILE in $1/*.xml; do + # filter all xmls which aren't set active + if [ $(grep " - + + + - + diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index a24845a3..62ef769d 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -203,7 +203,7 @@ writelog "\tNetwork kind:\t\t${network_kind}" #writelog "\tCD-ROM1:\t${cdrom0}" #writelog "\tCD-ROM2:\t${cdrom1}" #writelog "\tFloppy_A:\t${floppy0}" -writelog "\tShared Folders 'Home':\t/home/${USER}" +writelog "\tShared Folders 'home':\t/home/${USER}" ################################################################################ ### Pepare and configure virtual machine and disk image @@ -219,11 +219,11 @@ writelog "\tShared Folders 'Home':\t/home/${USER}" # add rw share to vm, if existing if [ -n "${rwshare}" ]; then - sharedf='" sed -i "s,, ${sharedf}\n ," \ "${machconfig}" - writelog "\tShared Folders 'Share':\t${rwshare}" + writelog "\tShared Folders 'share':\t${rwshare}" fi # add ssh port if linux and NAT diff --git a/os-plugins/plugins/vmchooser/files/run-virt.sh b/os-plugins/plugins/vmchooser/files/run-virt.sh index 690a7fea..6df6bf84 100644 --- a/os-plugins/plugins/vmchooser/files/run-virt.sh +++ b/os-plugins/plugins/vmchooser/files/run-virt.sh @@ -237,7 +237,6 @@ writelog () # Logo for console cat </dev/null] && [ ${runningvms} -gt 1 ]; then +if [ ${vmchooser_active} -eq 1 2>/dev/null ] && [ ${runningvms} -gt 1 ]; then # only allow one instance of vmgrid writelog "Already 1 VMs running and vmchooser plugin is active." writelog "Can't start ${xmlfile}, exiting!" @@ -109,7 +110,6 @@ fi ################################################################################ cat <{name} =~ m{^(.+)::(.+)$}) { my $system = $1; my $exportType = $2; - $label = $system . "-xen" . ' ' x (36-length($system)) . $exportType; + $label = $system . "-xen" . ' ' x (36-length($system)) + . $exportType; } else { $label = $info->{name}; } @@ -106,6 +107,7 @@ sub _xenBootEntry # Example: # KERNEL mboot.c32 vendor-os/xen.gz dom0_mem=128000 --- # vendor-os/vmlinuz-xen debug=3 --- vendor-os/initramfs-1 + # TODO: versionsort oder per attr? if ($info->{xen::active} eq 1) { my $xenKernel = slxsystem(ls /boot/xen* | sort | tail -n 1); $append .= " file=$bootURI" if length($bootURI); -- cgit v1.2.3-55-g7522 From 3f82922eef9a7b3e894d629d6cac59cadb66e2de Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Mon, 22 Mar 2010 19:06:22 +0100 Subject: small bugfix regarding xmlfile and paths. writelog now additional into rwshare. virtualbox rmdirs new. qemukvm plugin added new konfigurations and headless support, to be tested --- os-plugins/plugins/qemukvm/XX_qemukvm.sh | 22 +-- os-plugins/plugins/qemukvm/files/kvm.cmdline | 46 +---- os-plugins/plugins/qemukvm/files/run-virt.include | 206 +++++++++++++++++++-- os-plugins/plugins/virtualbox/XX_virtualbox.sh | 2 +- .../plugins/virtualbox/files/run-virt.include | 23 ++- os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 42 +++-- os-plugins/plugins/vmgrid/files/vmgrid | 30 +-- 7 files changed, 254 insertions(+), 117 deletions(-) (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/qemukvm/XX_qemukvm.sh b/os-plugins/plugins/qemukvm/XX_qemukvm.sh index 47d2689f..b595aab0 100644 --- a/os-plugins/plugins/qemukvm/XX_qemukvm.sh +++ b/os-plugins/plugins/qemukvm/XX_qemukvm.sh @@ -14,7 +14,7 @@ # include default directories . /etc/openslx.conf -CONFFILE="/initramfs/plugin-conf/qemukvm.conf" +CONFFILE=/initramfs/plugin-conf/qemukvm.conf PLUGINCONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/qemukvm PLUGINDIR=${OPENSLX_DEFAULT_DIR}/plugin-repo/qemukvm VIRTDIR=/mnt/${OPENSLX_DEFAULT_VIRTDIR}/qemukvm @@ -33,14 +33,19 @@ if [ -e ${CONFFILE} ]; then # load general configuration . /initramfs/machine-setup - # load needed variables - . /initramfs/plugin-conf/qemukvm.conf + + # copy virtualization include files and qemukvm.conf to config dir + testmkd ${PLUGINCONFDIR} + cp /mnt/${PLUGINDIR}/run-virt.include ${PLUGINCONFDIR} + cp ${CONFFILE} ${PLUGINCONFDIR} # check for the virtualization CPU features - if grep -q "svm" /proc/cpuinfo && modprobe ${MODPRV} kvm_amd ; then - [ $DEBUGLEVEL -gt 0 ] && echo " * Loaded kvm_amd module" - elif grep -q "vmx" /proc/cpuinfo && modprobe ${MODPRV} kvm_intel ; then + if grep -q "vmx" /proc/cpuinfo && modprobe ${MODPRV} kvm_intel ; then [ $DEBUGLEVEL -gt 0 ] && echo " * Loaded kvm_intel module" + echo "kvm=intel" >> ${PLUGINCONFDIR}/qemukvm.conf + elif grep -q "svm" /proc/cpuinfo && modprobe ${MODPRV} kvm_amd ; then + [ $DEBUGLEVEL -gt 0 ] && echo " * Loaded kvm_amd module" + echo "kvm=amd" >> ${PLUGINCONFDIR}/qemukvm.conf elif modprobe ${MODPRV} kqemu ; then [ $DEBUGLEVEL -gt 0 ] && \ error " * Successfully loaded the kqemu module, but loading of kvm_amd \ @@ -51,7 +56,6 @@ CPU." nonfatal error " * All module loading failed including the kqemu module, which \ was either\n not found or couldn't be loaded for other reasons. Thus using \ qemu(-kvm)\n makes not much sense." nonfatal - exit 1 fi # load the tunnel device module @@ -73,10 +77,6 @@ qemu(-kvm)\n makes not much sense." nonfatal ${qemukvm_imagesrc}." nonfatal fi - # copy virtualization include files to config dir - testmkd ${PLUGINCONFDIR} - - cp /mnt/${PLUGINDIR}/run-virt.include ${PLUGINCONFDIR} # create a network configuration template (variables should be setable in # the future, see vmware plugin) natnetwork="192.168.101" diff --git a/os-plugins/plugins/qemukvm/files/kvm.cmdline b/os-plugins/plugins/qemukvm/files/kvm.cmdline index b3352cb5..c566879d 100644 --- a/os-plugins/plugins/qemukvm/files/kvm.cmdline +++ b/os-plugins/plugins/qemukvm/files/kvm.cmdline @@ -149,48 +149,4 @@ ctrl-alt-f toggle full screen ctrl-alt-n switch to virtual console 'n' ctrl-alt toggle mouse and keyboard grab -When using -nographic, press 'ctrl-a h' to get some help. -root@lsfks19:~# kvm >kvm.cmd -open /dev/kvm: No such file or directory -Could not initialize KVM, will disable KVM support -root@lsfks19:~# vim kvm.cmd - -QEMU PC emulator version 0.9.1 (kvm-84), Copyright (c) 2003-2008 Fabrice Bellard -usage: qemu [options] [disk_image] - -'disk_image' is a raw hard image image for IDE hard disk 0 - -Standard options: --h or -help display this help and exit --M machine select emulated machine (-M ? for list) --cpu cpu select CPU (-cpu ? for list) --smp n set the number of CPUs to 'n' [default=1] --fda/-fdb file use 'file' as floppy disk 0/1 image --hda/-hdb file use 'file' as IDE hard disk 0/1 image --hdc/-hdd file use 'file' as IDE hard disk 2/3 image --cdrom file use 'file' as IDE cdrom image (cdrom is ide1 master) --drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i] - [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off] - [,cache=writethrough|writeback|none][,format=f][,serial=s] - [,boot=on|off] - use 'file' as a drive image --mtdblock file use 'file' as on-board Flash memory image --sd file use 'file' as SecureDigital card image --pflash file use 'file' as a parallel flash image --boot [a|c|d|n] boot on floppy (a), hard disk (c), CD-ROM (d), or network (n) --snapshot write to temporary files instead of disk image files --m megs set virtual RAM size to megs MB [default=128] --k language use keyboard layout (for example "fr" for French) --audio-help print list of audio drivers and their options --soundhw c1,... enable audio support - and only specified sound cards (comma separated list) - use -soundhw ? to get the list of supported cards - use -soundhw all to enable all of them --usb enable the USB driver (will be the default soon) --usbdevice name add the host or guest USB device 'name' --name string set the name of the guest --uuid %08x-%04x-%04x-%04x-%012x - specify machine UUID - -Display options: --nographic disable graphical output and redirect serial I/Os to console \ No newline at end of file +When using -nographic, press 'ctrl-a h' to get some help. \ No newline at end of file diff --git a/os-plugins/plugins/qemukvm/files/run-virt.include b/os-plugins/plugins/qemukvm/files/run-virt.include index 8d6d442b..0cec83da 100644 --- a/os-plugins/plugins/qemukvm/files/run-virt.include +++ b/os-plugins/plugins/qemukvm/files/run-virt.include @@ -28,31 +28,108 @@ else fi ################################################################################ -### Pepare and configure virtual machine and disk image +### Declaration of default variables ################################################################################ -permem=50 -mem=$(expr ${totalmem} / 100 \* ${permem}) +PLUGINCONFVIRTUALBOX="${PLUGINCONFROOT}/${self}" +# create TMPDIR for all users +mkdir -m 1777 /tmp/${self} 2>/dev/null +# TMPDIR +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 +# vmpath is the path to the vm, here an image (img|qcow*|vmdk) +diskfile=${vmpath} + +# check the file type +if echo ${imgname} | grep -iE "img|qcow|vmdk" >/dev/null 2>&1; then + imgtype=$(echo ${imgname#*.} | tr [a-z] [A-Z]) +else + writelog "${imgname} is not a valid image type (img|qcow*|vmdk), exiting!" + exit 1 +fi + +# display name +VIRTCMDOPTS="${VIRTCMDOPTS} -name ${displayname}" + +writelog "Directories:" +writelog "\tTMPDIR:\t\t$QKTMPDIR" +writelog "Diskimage:" +writelog "\tDisk type:\t\t$imgtype" +writelog "\tDisk file:\t\t$diskfile" + +################################################################################ +### Hardware checks +################################################################################ + +# memory part equal to vmware plugin +# percentage of memory to use for virtualbox in standard case +if [ -n "${forcemem}" ]; then + mem="${forcemem}" +else +# 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 +# # 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 + # static first + permem=50 + mem=$(expr ${totalmem} / 100 \* ${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 + VIRTCMDOPTS="${VIRTCMDOPTS} -m ${mem}" # network adaptor alternatives: rtl8139, pcnet, e1000 -VIRTCMDOPTS="${VIRTCMDOPTS} -net nic,model=pcnet" +network_card=${network_card:=pcnet} +VIRTCMDOPTS="${VIRTCMDOPTS} -net nic,model=${network_card}" case "${network_kind}" in bridge*) VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap0" ;; - nat|NAT) - VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap1" - ;; - hostonly) + hostonly|host-only) VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap2" ;; + *) + network_kind="NAT" + VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap1" + ;; esac +# external GUI port +vncport="590${VM_ID}" + +# TODO: most of the following does not make much sense yet ... # virtual fd/cd/dvd and drive devices, floppy b: for configuration -#VIRTCMDOPTS="${VIRTCMDOPTS} -fda /dev/fd0" -VIRTCMDOPTS="${VIRTCMDOPTS} -fdb /var/lib/virt/vmchooser/loopimg/fd.img" # if $floppy_0 from run-virt.include set then fdtest="TRUE" fdtest= fdtest=${floppy_0:+"TRUE"} @@ -75,19 +152,114 @@ cdrom1=${cdtest:-"FALSE"} ide="TRUE" hddrv="ide" +# TODO: nur bei vmchooser +#VIRTCMDOPTS="${VIRTCMDOPTS} -fda /dev/fd0" +#VIRTCMDOPTS="${VIRTCMDOPTS} -fdb ${floppy1name}" + # audio VIRTCMDOPTS="${VIRTCMDOPTS} -soundhw all" # serial #VIRTCMDOPTS="${VIRTCMDOPTS} -serial /dev/ttyS0" +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${network_card}" +writelog "\tNetwork kind:\t\t${network_kind}" +#writelog "\tCD-ROM1:\t${cdrom0}" +#writelog "\tCD-ROM2:\t${cdrom1}" +#writelog "\tFloppy_A:\t${floppy0}" +#writelog "\tFloppy_B:\t${floppy1}" +#writelog "\tShared Folders 'home':\t/home/${USER}" + +################################################################################ +### finally set env for run-virt.sh +################################################################################ + +#-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i] +# [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off] +# [,cache=writethrough|writeback|none][,format=f][,serial=s] +# [,boot=on|off] +#-snapshot write to temporary files instead of disk image files +#-usb enable the USB driver (will be the default soon) +#-usbdevice name add the host or guest USB device 'name' +#-nographic disable graphical output and redirect serial I/Os to console +#-vga [std|cirrus|vmware|none] select video card type +#-vnc display start a VNC server on display +#-tftp dir allow tftp access to files in dir [-net user] +#-bootp file advertise file in BOOTP replies +#-no-fd-bootchk disable boot signature checking for floppy disks +#-no-acpi disable ACPI +#-kernel bzImage use 'bzImage' as kernel image +#-append cmdline use 'cmdline' as kernel command line +#-initrd file use 'file' as initial ram disk +#-serial dev redirect the serial port to char device 'dev' +#-parallel dev redirect the parallel port to char device 'dev' +#-monitor dev redirect the monitor to char device 'dev' +#-pidfile file write PID to 'file' +#-d item1,... output log to /tmp/qemu.log (use -d ? for a list of log items) +#-L path set the directory for the BIOS, VGA BIOS and keymaps +#-bios file set the filename for the BIOS +#-no-kvm disable KVM hardware virtualization +#-enable-nesting enable support for running a VM inside the VM (AMD only) +#-no-reboot exit instead of rebooting +#-no-shutdown stop before shutdown +#-loadvm [tag|id] +# start right away with a saved state (loadvm in monitor) +#-daemonize daemonize QEMU after initializing +#-kvm-shadow-memory megs set the amount of shadow pages to be allocated +#-mem-path set the path to hugetlbfs/tmpfs mounted directory, also +# enables allocation of guest memory with huge pages +#-mem-prealloc toggles preallocation of -mem-path backed physical memory +# at startup. Default is enabled. +#-option-rom rom load a file, rom, into the option ROM space +#-localtime set the real time clock to local time [default=utc] +#-startdate select initial date of the clock +#-icount [N|auto] +# enable virtual instruction counter with 2^N clock ticks per instruction +#-echr chr set terminal escape character instead of ctrl-a +#-virtioconsole c +# set virtio console +#-show-cursor show cursor + +# check for kvm modules +# TODO: check for /dev/kvm +if [ -n "${kvm}" ]; then + if lsmod |Êgrep ${kvm}; then + for tool in kvm qemu-kvm; do + VIRTCMD=$(which ${tool} 2>/dev/null) + [ -n "$VIRTCMD" ] && break + done + else + writelog "KVM available but no modules loaded, maybe compiled into kernel?" + VIRTCMD=$(which qemu 2>/dev/null) + fi +fi + # set the variables appropriately -for tool in kvm qemu-kvm qemu; do - VIRTCMD=$(which ${tool} 2>/dev/null) - [ "x$VIRTCMD" != "x" ] && break -done +#for tool in kvm qemu-kvm qemu; do +# VIRTCMD=$(which ${tool} 2>/dev/null) +# [ -n "$VIRTCMD" ] && break +#done + +if [ -z "${VIRTCMD}" ]; then + writelog "No QEMU/KVM found." + rm -rf ${RMDIRS} + exit 1 +elif [ "${VIRTCMD}" = "qemu" ]; then + writelog "No KVM fouund. Starting slow QEMU emulation" + VIRTCMD="qemu" +else + VIRTCMD="sudo $VIRTCMD" +fi -[ -z $VIRTCMD ] && { writelog "No qemu/kvm tool found."; exit 1; } +# set headless mode +VIRTCMDHL="$VIRTCMD" +VIRTCMDOPTSHL="${VIRTCMDOPTS} -boot c -alt-grab -nographic" -VIRTCMD="sudo $VIRTCMD" -VIRTCMDOPTS="${VIRTCMDOPTS} -boot c -alt-grab ${diskfile}" +# graphical start +VIRTCMD="$VIRTCMD" +VIRTCMDOPTS="${VIRTCMDOPTS} -boot c -alt-grab -full-screen ${diskfile}" diff --git a/os-plugins/plugins/virtualbox/XX_virtualbox.sh b/os-plugins/plugins/virtualbox/XX_virtualbox.sh index 4fa0b7bb..998dabd7 100644 --- a/os-plugins/plugins/virtualbox/XX_virtualbox.sh +++ b/os-plugins/plugins/virtualbox/XX_virtualbox.sh @@ -14,7 +14,7 @@ # include default directories . /etc/openslx.conf -CONFFILE="/initramfs/plugin-conf/virtualbox.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 diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index 62ef769d..eb1cb0e9 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -37,7 +37,9 @@ mkdir -m 1777 /tmp/${self} 2>/dev/null 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 +# define dirs and files which can be removed after exit, be carefull! +RMDIRS="${snapshotdir} ${confdir} /tmp/.vbox-${USER}-ipc" 2>/dev/null +rm -rf ${RMDIRS} 2>/dev/null machfolder="${VBOX_USER_HOME}/Machines" # imgname is the name of the virtual image file # use vm_shortname since vm_name can be very long @@ -45,16 +47,16 @@ 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} +mkdir -p ${diskfolder} ${snapshotdir} 2>/dev/null 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 + writelog "${imgname} is not a valid image type (vdi), exiting!" #vmdk|vhd + exit 1 fi # TODO: maybe rewrite, to reduce checks, merge it with network option, @@ -151,7 +153,7 @@ case "${network_kind}" in bridged) network_kind='BridgedInterface name="br0"' ;; - host-only) + hostonly|host-only) network_kind='HostOnlyInterface name="vboxnet0"' ;; *) @@ -159,8 +161,10 @@ case "${network_kind}" in ;; esac +# external GUI vrdpport="590${VM_ID}" +# TODO: nur bei vmchooser # 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" @@ -200,9 +204,12 @@ writelog "\tGuest RAM:\t\t${mem} MB" writelog "\tMAC address:\t\t$macaddr" writelog "\tNetwork card:\t\t${vb_network_card}" writelog "\tNetwork kind:\t\t${network_kind}" +# TODO: server start activate via xml, etc... +#writelog "\tGuest VRDP port:\t${vrdpport}" #writelog "\tCD-ROM1:\t${cdrom0}" #writelog "\tCD-ROM2:\t${cdrom1}" #writelog "\tFloppy_A:\t${floppy0}" +#writelog "\tFloppy_B:\t${floppy1}" writelog "\tShared Folders 'home':\t/home/${USER}" ################################################################################ @@ -245,7 +252,7 @@ cat ${OPENSLX_DEFAULT_DIR}/plugin-repo/virtualbox/empty-diff.vdi.gz | \ gunzip > "${snapshotdir}/{${snapshotuuid}}.vdi" ################################################################################ -# finally set env for run-virt.sh +### finally set env for run-virt.sh ################################################################################ # wait for a certain command to settle @@ -268,9 +275,6 @@ done # fi #done -# 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" @@ -283,4 +287,3 @@ VIRTCMDOPTS="--startvm ${machineuuid} --start-running" # set headless mode VIRTCMDHL=$(which VBoxHeadless 2>/dev/null) VIRTCMDOPTSHL="-s ${machineuuid}" - diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index 4a09f237..18e62ea0 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -17,24 +17,13 @@ . /etc/opt/openslx/openslx.conf -################################################################################ -### Functions used throughout the script -################################################################################ - -# function to write to stdout and logfile -writelog () { - # write to stdout - echo -e "$1" - # log into file - echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log -} - ################################################################################ ### Define default dirs / get configs ################################################################################ PLUGINCONFROOT=${OPENSLX_DEFAULT_CONFDIR}/plugins PLUGINCONFVMGRID=${PLUGINCONFROOT}/vmgrid +RWSHARE=/var/opt/openslx/plugins/vmgrid/share # include general configuration from vmgrid [ -f ${PLUGINCONFVMGRID}/vmgrid.conf ] && \ . ${PLUGINCONFVMGRID}/vmgrid.conf @@ -44,22 +33,37 @@ PLUGINCONFVMGRID=${PLUGINCONFROOT}/vmgrid [ -f ${PLUGINCONFROOT}/vmchooser/vmchooser.conf ] && \ . ${PLUGINCONFROOT}/vmchooser/vmchooser.conf +################################################################################ +### Functions used throughout the script +################################################################################ + +# function to write to stdout and logfile +mkdir -p ${RWSHARE}/var/log/openslx 2>/dev/null +writelog () { + # write to stdout + echo -e "$1" + # log into file + echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log + # log into share dir, so that log is available in vm as well + echo -e "$1" >> ${RWSHARE}/var/log/openslx/run-vmgrid.${USER}.$$.log +} + ################################################################################ ### Get XML file and dir ################################################################################ # check if forcemem set -# TODO: klappt noch nicht immer :( if [ "$1" = "--forcemem" ]; then forcemem=$2 - xmlfile=${3##*/} + xmlfile=$3 else - xmlfile=${1##*/} + xmlfile=$1 fi # absolute or relative path? -if ls ${1} 2>/dev/null | grep '/' >/dev/null 2>&1; then - xmlpath=$(dirname ${1}) +if ls ${xmlfile} 2>/dev/null | grep '/' >/dev/null 2>&1; then + xmlpath=$(dirname ${xmlfile}) + xmlfile=$(basename ${xmlfile}) else xmlpath=${vmgrid_xmlpath} fi @@ -265,8 +269,6 @@ ide="TRUE" scsi="FALSE" hddrv="ide" -# TODO: vncclient IP:59001 oder Plugin? - # add rw share rwshare="/var/opt/openslx/plugins/vmgrid/share" @@ -296,7 +298,7 @@ fi # start headless if [ -n "${VIRTCMDHL}" ]; then - writelog "Starting ${vmgrid_virt} head-less..." + writelog "Starting ${vmgrid_virt} headless..." ${VIRTCMDHL} ${VIRTCMDOPTSHL} else writelog "${vmgrid_virt}: No headless mode defined, exiting!" diff --git a/os-plugins/plugins/vmgrid/files/vmgrid b/os-plugins/plugins/vmgrid/files/vmgrid index 66291aea..7257226e 100644 --- a/os-plugins/plugins/vmgrid/files/vmgrid +++ b/os-plugins/plugins/vmgrid/files/vmgrid @@ -27,29 +27,18 @@ if [ -n "$1" ]; then echo "Usage: vmgrid [[/path/]filename[.xml]]" exit 0 else - run-vmgrid.sh $1 & + run-vmgrid.sh $@ & exit 0 fi fi -################################################################################ -### Functions used throughout the script -################################################################################ - -# function to write to stdout and logfile -writelog () { - # write to stdout - echo -e "$1" - # log into file - echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log -} - ################################################################################ ### Define default dirs / get configs ################################################################################ PLUGINCONFROOT=${OPENSLX_DEFAULT_CONFDIR}/plugins PLUGINCONFDIR=${PLUGINCONFROOT}/vmgrid +RWSHARE=/var/opt/openslx/plugins/vmgrid/share # include general configuration from vmgrid [ -f ${PLUGINCONFDIR}/vmgrid.conf ] && \ . ${PLUGINCONFDIR}/vmgrid.conf @@ -57,6 +46,21 @@ PLUGINCONFDIR=${PLUGINCONFROOT}/vmgrid [ -f ${PLUGINCONFROOT}/vmchooser/vmchooser.conf ] && \ . ${PLUGINCONFROOT}/vmchooser/vmchooser.conf +################################################################################ +### Functions used throughout the script +################################################################################ + +# function to write to stdout and logfile +mkdir -p ${RWSHARE}/var/log/openslx 2>/dev/null +writelog () { + # write to stdout + echo -e "$1" + # log into file + echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log + # log into share dir, so that log is available in vm as well + echo -e "$1" >> ${RWSHARE}/var/log/openslx/run-vmgrid.${USER}.$$.log +} + ################################################################################ ### Configure VMs for autostart and set RAM ################################################################################ -- cgit v1.2.3-55-g7522 From d50ca9e27cfb7fd8aba92ec557eb07944f3a33ad Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Mon, 22 Mar 2010 23:50:43 +0100 Subject: qemukvm weiter, sollte laufen (ungetestet), noch anpassungen an scripten notwendig (XX_qemu.., ifup), sudoers, /dev/fb0 für jedermann zugreifbar --- .../plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm | 38 +++++++------ os-plugins/plugins/qemukvm/XX_qemukvm.sh | 30 ++++++----- os-plugins/plugins/qemukvm/files/ifdown | 31 +++++++++++ os-plugins/plugins/qemukvm/files/ifup | 62 +++++++++++++++++++++ os-plugins/plugins/qemukvm/files/qemu-ifdown | 31 ----------- os-plugins/plugins/qemukvm/files/qemu-ifup | 63 ---------------------- os-plugins/plugins/qemukvm/files/run-virt.include | 50 +++++++++-------- .../init-hooks/60-have-servconfig/vm-dhcpd.sh | 11 ++-- .../virtualbox/OpenSLX/OSPlugin/virtualbox.pm | 9 ++-- .../plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm | 2 +- os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 2 +- os-plugins/plugins/vmgrid/files/vmgrid | 2 +- 12 files changed, 177 insertions(+), 154 deletions(-) create mode 100644 os-plugins/plugins/qemukvm/files/ifdown create mode 100644 os-plugins/plugins/qemukvm/files/ifup delete mode 100644 os-plugins/plugins/qemukvm/files/qemu-ifdown delete mode 100644 os-plugins/plugins/qemukvm/files/qemu-ifup (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm index 52255116..c9388210 100644 --- a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm +++ b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm @@ -103,7 +103,7 @@ sub installationPhase { my $self = shift; my $info = shift; - + $self->{pluginRepositoryPath} = $info->{'plugin-repo-path'}; $self->{pluginTempPath} = $info->{'plugin-temp-path'}; $self->{openslxBasePath} = $info->{'openslx-base-path'}; @@ -111,8 +111,9 @@ sub installationPhase $self->{attrs} = $info->{'plugin-attrs'}; my $engine = $self->{'os-plugin-engine'}; - my $pluginRepoPath = "$self->{pluginRepositoryPath}"; - + my $pluginRepoPath = $info->{'plugin-repo-path'}; + my $openslxBasePath = $info->{'openslx-base-path'}; + # Different names of the tool (should be unified somehow!?) if (!isInPath('qemu-kvm') || !isInPath('kvm')) { $engine->installPackages( @@ -123,19 +124,26 @@ sub installationPhase if (!isInPath('sudo')) { $engine->installPackages($self->{distro}->getPackageName('sudo')); } - # Copy run-virt.include to the appropriate place for inclusion in stage4 - copyFile("$self->{openslxBasePath}/lib/plugins/qemukvm/files/run-virt.include", - "$self->{pluginRepositoryPath}/"); - # Copy the later /etc/qemu-ifup,down - copyFile("$self->{openslxBasePath}/lib/plugins/qemukvm/files/qemu-if*", - "$self->{pluginRepositoryPath}/"); - chmod 0755, "$self->{pluginRepositoryPath}/qemu-ifup"; - chmod 0755, "$self->{pluginRepositoryPath}/qemu-ifdown"; + + # Copy run-virt.include and template files to the appropriate place for + # inclusion in stage4 + my $pluginName = $self->{'name'}; + my $pluginBasePath = "$openslxBasePath/lib/plugins/$pluginName/files"; + foreach my $file ( qw( run-virt.include ifup ifdown ) ) { + copyFile("$pluginBasePath/$file", "$pluginRepoPath/"); + } + chmod 0755, "$pluginRepoPath/if*"; +# # Create kvm link +# my $kvmPath = pathOf('qemu-kvm') || pathOf('kvm') || pathOf('qemu'); +# if (defined $kvmPath) { +# linkFile($kvmPath, "$pluginRepoPath/qemukvm") +# } my $initFile = newInitFile(); $initFile->setName("qemukvm"); $initFile->setDesc("Setup environment for QEMU/KVM"); + # TODO: default dirs als globale funktion anbieten $initFile-> addToBlock('head','. /etc/opt/openslx/plugins/qemukvm/network.conf'); my $do_start = unshiftHereDoc(<<' End-of-Here'); @@ -157,23 +165,23 @@ sub installationPhase echo "0" >/proc/sys/net/ipv4/conf/br0/forwarding echo "0" >/proc/sys/net/ipv4/conf/tap0/forwarding End-of-Here - + # add helper functions to initfile # first parameter name of the function # second parameter content of the function $initFile->addFunction('do_start', $do_start); $initFile->addFunction('do_stop', $do_stop); $initFile->addFunction('do_restart', " : # do nothing here"); - + # place a call of the helper function in the stop block of the init file # first parameter name of the function # second parameter name of the block $initFile->addFunctionCall('do_start', 'start'); $initFile->addFunctionCall('do_stop', 'stop'); $initFile->addFunctionCall('do_restart', 'restart'); - + my $distro = (split('-',$self->{'os-plugin-engine'}->distroName()))[0]; - + # write qemukvm initfile to plugin path spitFile( "$pluginRepoPath/qemukvm", diff --git a/os-plugins/plugins/qemukvm/XX_qemukvm.sh b/os-plugins/plugins/qemukvm/XX_qemukvm.sh index b595aab0..d6c712ac 100644 --- a/os-plugins/plugins/qemukvm/XX_qemukvm.sh +++ b/os-plugins/plugins/qemukvm/XX_qemukvm.sh @@ -91,22 +91,24 @@ ${qemukvm_imagesrc}." nonfatal # copy the /etc/qemu-ifup script and enable extended rights for running # the emulator and certain network commands via sudo - ln -sf ${PLUGINDIR}/qemu-ifup /mnt/etc/qemu-ifup - ln -sf ${PLUGINDIR}/qemu-ifdown /mnt/etc/qemu-ifdown - ln -sf ${PLUGINDIR}/qemu-ifup /mnt/etc/kvm-ifup - ln -sf ${PLUGINDIR}/qemu-ifdown /mnt/etc/kvm-ifdown + ln -sf ${PLUGINDIR}/ifup ${PLUGINCONFDIR}/ifup + ln -sf ${PLUGINDIR}/ifdown ${PLUGINCONFDIR}/ifdown - for qemubin in qemu kvm ; do - qemu="$(binfinder ${qemubin})" - [ -n "${qemu}" ] && \ - echo "ALL ALL=NOPASSWD: ${qemu}" >>/mnt/etc/sudoers + for qemubin in qemu-kvm kvm qemu ; do + qemu=$(binfinder ${qemubin}) + [ -n "${qemu}" ] && echo "ALL ALL=NOPASSWD: ${qemu}" >>/mnt/etc/sudoers done - echo -e "#ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/sbin/tunctl -t tap*\n\ -#ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/sbin/ip addr add * dev tap*\n\ -#ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tap*\n\ -ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/usr/sbin/udhcpd -S /tmp/qemu*\n\ -# TODO: killall nur mit fullpath!!! -ALL ALL=NOPASSWD: /usr/bin/killall udhcpd" >>/mnt/etc/sudoers + killall=$(binfinder killall) + # TODO: notwendig, oder reicht ifup/down + # TODO: /dev/fb0 mit jedermann + cat <>/mnt/etc/sudoers fi else [ $DEBUGLEVEL -gt 0 ] && echo " * Configuration of 'qemukvm' plugin failed" diff --git a/os-plugins/plugins/qemukvm/files/ifdown b/os-plugins/plugins/qemukvm/files/ifdown new file mode 100644 index 00000000..8c52d76f --- /dev/null +++ b/os-plugins/plugins/qemukvm/files/ifdown @@ -0,0 +1,31 @@ +#!/bin/sh +# Copyright (c) 2009 - OpenSLX GmbH +# +# This program 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 suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# qemu-ifup +# - Script used for network cleanup of qemukvm in stage4 +# ----------------------------------------------------------------------------- + +# Clean up script + +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 + ;; + tap2) + # Bringing down the dhcp server + killall udhcpd 2>/dev/null + ;; +esac + +# Produce a clean exit status +exit 0 diff --git a/os-plugins/plugins/qemukvm/files/ifup b/os-plugins/plugins/qemukvm/files/ifup new file mode 100644 index 00000000..ed4a277d --- /dev/null +++ b/os-plugins/plugins/qemukvm/files/ifup @@ -0,0 +1,62 @@ +#!/bin/sh +# Copyright (c) 2009..2010 - OpenSLX GmbH +# +# This program 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 suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# ifup +# - Script used for network setup of qemukvm in stage4 +# ----------------------------------------------------------------------------- + +. /etc/opt/openslx/openslx.conf + +PLUGINCONFDIR=${OPENSLX_DEFAULT_CONFDIR}/plugins/qemukvm +QKTMPDIR=/tmp/qemukvm/$USER/$$ + +# Use the udhcpcd as DHCP server and brctl as provided by default in OpenSLX +# environments via uclibc-wrapper. +. ${PLUGINCONFDIR}/network.conf + +# Just decide by the virtual network device used which kind of connection +# should be set up (passed in $1): tap0 = bridge, tap1 = nat, tap2 = hostonly. +case "$1" in + tap0) + # Adding the tap0 interface to the existing bridge configured in stage3 + # brctl addif br0 tap0 + ;; + tap1) + # Configuring DHCP on host tap1 interface and enable IP masquerading + [ -d ${QKTMPDIR} ] || mkdir -p ${QKTMPDIR} + # cut the last .NNN/MM from nataddress + sed -e "s,NWIF,tap1,;s,/misc/,/qemu/," \ + -e "s,CNETWORK,${nataddress%.*},;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 tap1 up + # ip addr add 192.168.101.254/24 dev tap1 + sudo /opt/openslx/uclib-rootfs/usr/sbin/udhcpd \ + -S ${QKTMPDIR}/udhcpd.conf + # iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE + ;; + tap2) + # Configuring DHCP on host tap2 interface + [ -d ${QKTMPDIR} ] || mkdir -p /tmp/qemu-$USER + sed "s,NWIF,tap2,;s,/misc/,/qemu/,;s,USER,$USER,;s,CNETWORK,$hoaddress," \ + ${OPENSLX_DEFAULT_CONFDIR}/udhcpd.conf >${QKTMPDIR}/udhcpd.conf + touch ${QKTMPDIR}/udhcpd.leases + # ip link set tap2 up + # ip addr add 192.168.101.254/24 dev tap2 + 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/qemu-ifdown b/os-plugins/plugins/qemukvm/files/qemu-ifdown deleted file mode 100644 index 8c52d76f..00000000 --- a/os-plugins/plugins/qemukvm/files/qemu-ifdown +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -# Copyright (c) 2009 - OpenSLX GmbH -# -# This program 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 suggestions, praise, or complaints to feedback@openslx.org -# -# General information about OpenSLX can be found at http://openslx.org/ -# ----------------------------------------------------------------------------- -# qemu-ifup -# - Script used for network cleanup of qemukvm in stage4 -# ----------------------------------------------------------------------------- - -# Clean up script - -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 - ;; - tap2) - # Bringing down the dhcp server - killall udhcpd 2>/dev/null - ;; -esac - -# Produce a clean exit status -exit 0 diff --git a/os-plugins/plugins/qemukvm/files/qemu-ifup b/os-plugins/plugins/qemukvm/files/qemu-ifup deleted file mode 100644 index 1f1e0cc6..00000000 --- a/os-plugins/plugins/qemukvm/files/qemu-ifup +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -# Copyright (c) 2009..2010 - OpenSLX GmbH -# -# This program 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 suggestions, praise, or complaints to feedback@openslx.org -# -# General information about OpenSLX can be found at http://openslx.org/ -# ----------------------------------------------------------------------------- -# qemu-ifup -# - Script used for network setup of qemukvm in stage4 -# ----------------------------------------------------------------------------- - -. /etc/opt/openslx/openslx.conf - -PLUGINCONFDIR=${OPENSLX_DEFAULT_CONFDIR}/plugins/qemukvm -PLUGINDIR=${OPENSLX_DEFAULT_PLUGINDIRDIR}/qemukvm - -# Use the udhcpcd as DHCP server and brctl as provided by default in OpenSLX -# environments via uclibc-wrapper. -. ${PLUGINCONFDIR}/network.conf - -# Just decide by the virtual network device used which kind of connection -# should be set up (passed in $1): tap0 = bridge, tap1 = nat, tap2 = hostonly. -case "$1" in - tap0) - # Adding the tap0 interface to the existing bridge configured in stage3 - # brctl addif br0 tap0 - ;; - tap1) - # Configuring DHCP on host tap1 interface and enable IP masquerading - [ -d /tmp/qemu-$USER ] || mkdir -p /tmp/qemu-$USER - # cut the last .NNN/MM from nataddress - sed -e "s,NWIF,tap1,;s,/misc/,/qemu/," \ - -e "s,CNETWORK,${nataddress%.*},;s,PIDFILE,/tmp/qemu-$USER/udhcpd.pid," \ - -e "s,LEASEFILE,/tmp/qemu-$USER/udhcpd.leases," \ - ${PLUGINDIR}/udhcpd.conf \ - >/tmp/qemu-$USER/udhcpd.conf - touch /tmp/qemu-$USER/udhcpd.leases - # ip link set tap1 up - # ip addr add 192.168.101.254/24 dev tap1 - sudo /opt/openslx/uclib-rootfs/usr/sbin/udhcpd \ - -S /tmp/qemu-$USER/udhcpd.conf - # iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE - ;; - tap2) - # Configuring DHCP on host tap2 interface - [ -d /tmp/qemu-$USER ] || mkdir -p /tmp/qemu-$USER - sed "s,NWIF,tap2,;s,/misc/,/qemu/,;s,USER,$USER,;s,CNETWORK,$hoaddress," \ - /etc/opt/openslx/udhcpd.conf >/tmp/qemu-$USER/udhcpd.conf - touch /tmp/qemu-$USER/udhcpd.leases - # ip link set tap2 up - # ip addr add 192.168.101.254/24 dev tap2 - sudo /opt/openslx/uclib-rootfs/usr/sbin/udhcpd \ - -S /tmp/qemu-$USER/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 0cec83da..bdf9666f 100644 --- a/os-plugins/plugins/qemukvm/files/run-virt.include +++ b/os-plugins/plugins/qemukvm/files/run-virt.include @@ -31,7 +31,8 @@ fi ### Declaration of default variables ################################################################################ -PLUGINCONFVIRTUALBOX="${PLUGINCONFROOT}/${self}" +PLUGINCONFQK="${PLUGINCONFROOT}/${self}" +PLUGINDIRQK=${OPENSLX_DEFAULT_DIR}/plugin-repo/${self} # create TMPDIR for all users mkdir -m 1777 /tmp/${self} 2>/dev/null # TMPDIR @@ -51,11 +52,12 @@ else exit 1 fi -# display name +# display name, remove blanks because of cmdline problems +displayname=$(echo ${displayname} | sed -e "s, ,-,g") VIRTCMDOPTS="${VIRTCMDOPTS} -name ${displayname}" writelog "Directories:" -writelog "\tTMPDIR:\t\t$QKTMPDIR" +writelog "\tTMPDIR:\t\t\t$QKTMPDIR" writelog "Diskimage:" writelog "\tDisk type:\t\t$imgtype" writelog "\tDisk file:\t\t$diskfile" @@ -112,16 +114,21 @@ VIRTCMDOPTS="${VIRTCMDOPTS} -m ${mem}" network_card=${network_card:=pcnet} VIRTCMDOPTS="${VIRTCMDOPTS} -net nic,model=${network_card}" +# define net kind and apply script +qemu_ifscripts="script=${PLUGINDIRQK}/ifup,downscript=${PLUGINDIRQK}/ifdown" case "${network_kind}" in bridge*) - VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap0" + VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap0,${qemu_ifscripts}" + ;; + NAT|nat) + VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap1,${qemu_ifscripts}" ;; hostonly|host-only) - VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap2" + VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap2,${qemu_ifscripts}" ;; *) - network_kind="NAT" - VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap1" + network_kind="user" + VIRTCMDOPTS="${VIRTCMDOPTS} -net user" ;; esac @@ -226,40 +233,39 @@ writelog "\tNetwork kind:\t\t${network_kind}" #-show-cursor show cursor # check for kvm modules -# TODO: check for /dev/kvm if [ -n "${kvm}" ]; then - if lsmod |Êgrep ${kvm}; then + if [ -e /dev/kvm ]; then for tool in kvm qemu-kvm; do VIRTCMD=$(which ${tool} 2>/dev/null) [ -n "$VIRTCMD" ] && break done else - writelog "KVM available but no modules loaded, maybe compiled into kernel?" VIRTCMD=$(which qemu 2>/dev/null) + writelog "KVM available but /dev/kvm not found!" + writelog "Trying fallback to QEMU emulation." fi fi -# set the variables appropriately -#for tool in kvm qemu-kvm qemu; do -# VIRTCMD=$(which ${tool} 2>/dev/null) -# [ -n "$VIRTCMD" ] && break -#done - if [ -z "${VIRTCMD}" ]; then - writelog "No QEMU/KVM found." + writelog "No QEMU/KVM found, exiting!" rm -rf ${RMDIRS} exit 1 -elif [ "${VIRTCMD}" = "qemu" ]; then - writelog "No KVM fouund. Starting slow QEMU emulation" - VIRTCMD="qemu" +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 +# TODO: boot als var, -boot n, tftp... +VIRTCMDOPTS="${VIRTCMDOPTS} -boot c" + # set headless mode +# define first, you do not want VIRTCMDOPTS from graphical start VIRTCMDHL="$VIRTCMD" -VIRTCMDOPTSHL="${VIRTCMDOPTS} -boot c -alt-grab -nographic" +VIRTCMDOPTSHL="${VIRTCMDOPTS} -alt-grab -nographic -snapshot ${diskfile}" # graphical start VIRTCMD="$VIRTCMD" -VIRTCMDOPTS="${VIRTCMDOPTS} -boot c -alt-grab -full-screen ${diskfile}" +VIRTCMDOPTS="${VIRTCMDOPTS} -alt-grab -full-screen -snapshot ${diskfile}" diff --git a/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh b/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh index 153cac68..ed67bddb 100755 --- a/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh +++ b/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh @@ -13,9 +13,13 @@ # (should be kept identical to the files of virtualbox and vmware plugins) ############################################################################# +. /etc/openslx.conf + +CONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR} +testmkd ${CONFDIR} + # configuring dhcpd stub for virtual networks -testmkd /mnt/etc/opt/openslx -echo " +cat </mnt/etc/opt/openslx/udhcpd.conf +EOF \ + >${CONFDIR}/udhcpd.conf diff --git a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm index 8e04fdd6..26a2d926 100644 --- a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm +++ b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm @@ -118,8 +118,10 @@ sub installationPhase $self->{distro}->installVbox(); } if (!isInPath('VirtualBox')) { - print "VirtualBox is not installed. VirtualBox Plugin won't be installed!\n"; -# exit + print + "VirtualBox is not installed. VirtualBox Plugin won't be installed!\n" + ; + #exit } $self->_writeRunlevelScript(); @@ -127,7 +129,8 @@ sub installationPhase # 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"; + 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}/"); diff --git a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm index a4f08bc1..c3186251 100644 --- a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm +++ b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm @@ -217,7 +217,7 @@ sub installationPhase { my $self = shift; my $info = shift; - + my $pluginRepoPath = $info->{'plugin-repo-path'}; my $openslxBasePath = $info->{'openslx-base-path'}; diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index 18e62ea0..8d199ccf 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -38,7 +38,7 @@ RWSHARE=/var/opt/openslx/plugins/vmgrid/share ################################################################################ # function to write to stdout and logfile -mkdir -p ${RWSHARE}/var/log/openslx 2>/dev/null +mkdir -m 1777 -p ${RWSHARE}/var/log/openslx 2>/dev/null writelog () { # write to stdout echo -e "$1" diff --git a/os-plugins/plugins/vmgrid/files/vmgrid b/os-plugins/plugins/vmgrid/files/vmgrid index 7257226e..b8806ab3 100644 --- a/os-plugins/plugins/vmgrid/files/vmgrid +++ b/os-plugins/plugins/vmgrid/files/vmgrid @@ -51,7 +51,7 @@ RWSHARE=/var/opt/openslx/plugins/vmgrid/share ################################################################################ # function to write to stdout and logfile -mkdir -p ${RWSHARE}/var/log/openslx 2>/dev/null +mkdir -m 1777 -p ${RWSHARE}/var/log/openslx 2>/dev/null writelog () { # write to stdout echo -e "$1" -- cgit v1.2.3-55-g7522 From 67a9870012a281c5489e482c69201e8364dec5be Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Tue, 23 Mar 2010 21:23:55 +0100 Subject: qemukvm further modifications, first xen runscripts --- boot-env/syslinux/extlinux | Bin 52714 -> 52294 bytes .../plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm | 12 +- os-plugins/plugins/qemukvm/XX_qemukvm.sh | 16 +- os-plugins/plugins/qemukvm/files/ifdown | 2 +- os-plugins/plugins/qemukvm/files/run-virt.include | 12 +- .../init-hooks/60-have-servconfig/vm-dhcpd.sh | 5 +- .../plugins/virtualbox/files/run-virt.include | 9 +- os-plugins/plugins/vmgrid/XX_vmgrid.sh | 1 - os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm | 107 ++++---- os-plugins/plugins/xen/XX_xen.sh | 9 +- os-plugins/plugins/xen/files/machine.include | 189 ++++++++++++++ os-plugins/plugins/xen/files/run-virt.include | 290 +++++++++++++++++++++ 12 files changed, 574 insertions(+), 78 deletions(-) create mode 100644 os-plugins/plugins/xen/files/machine.include create mode 100644 os-plugins/plugins/xen/files/run-virt.include (limited to 'os-plugins/plugins') diff --git a/boot-env/syslinux/extlinux b/boot-env/syslinux/extlinux index d97dd70c..69d8bf56 100755 Binary files a/boot-env/syslinux/extlinux and b/boot-env/syslinux/extlinux differ diff --git a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm index c9388210..8029102c 100644 --- a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm +++ b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm @@ -132,7 +132,7 @@ sub installationPhase foreach my $file ( qw( run-virt.include ifup ifdown ) ) { copyFile("$pluginBasePath/$file", "$pluginRepoPath/"); } - chmod 0755, "$pluginRepoPath/if*"; + chmod 0755, "$pluginRepoPath/ifup", "$pluginRepoPath/ifdown"; # # Create kvm link # my $kvmPath = pathOf('qemu-kvm') || pathOf('kvm') || pathOf('qemu'); # if (defined $kvmPath) { @@ -147,7 +147,7 @@ sub installationPhase $initFile-> addToBlock('head','. /etc/opt/openslx/plugins/qemukvm/network.conf'); my $do_start = unshiftHereDoc(<<' End-of-Here'); - # Adding the tap0 interface to the existing bridge configured in stage3 + # configuring the tap0 interface to the existing bridge configured in stage3 for i in 0 1 2; do /opt/openslx/uclib-rootfs/sbin/tunctl -t tap${i} >/dev/null 2>&1 ip link set dev tap${i} up @@ -157,6 +157,8 @@ sub installationPhase ip addr add ${hoaddress} dev tap2 echo "1" >/proc/sys/net/ipv4/conf/br0/forwarding echo "1" >/proc/sys/net/ipv4/conf/tap0/forwarding + # TODO: maybe solve via group or udev, etc... + chmod 766 /dev/fb* End-of-Here my $do_stop = unshiftHereDoc(<<' End-of-Here'); /opt/openslx/uclib-rootfs/usr/sbin/brctl delif br0 tap0 @@ -164,6 +166,10 @@ sub installationPhase ip addr del ${hoaddress} dev tap2 echo "0" >/proc/sys/net/ipv4/conf/br0/forwarding echo "0" >/proc/sys/net/ipv4/conf/tap0/forwarding + chmod 760 /dev/fb* + End-of-Here + my $do_restart = unshiftHereDoc(<<' End-of-Here'); + do_stop && do_start End-of-Here # add helper functions to initfile @@ -171,7 +177,7 @@ sub installationPhase # second parameter content of the function $initFile->addFunction('do_start', $do_start); $initFile->addFunction('do_stop', $do_stop); - $initFile->addFunction('do_restart', " : # do nothing here"); + $initFile->addFunction('do_restart', $do_restart); # place a call of the helper function in the stop block of the init file # first parameter name of the function diff --git a/os-plugins/plugins/qemukvm/XX_qemukvm.sh b/os-plugins/plugins/qemukvm/XX_qemukvm.sh index d6c712ac..b3c4ccf0 100644 --- a/os-plugins/plugins/qemukvm/XX_qemukvm.sh +++ b/os-plugins/plugins/qemukvm/XX_qemukvm.sh @@ -98,17 +98,17 @@ ${qemukvm_imagesrc}." nonfatal qemu=$(binfinder ${qemubin}) [ -n "${qemu}" ] && echo "ALL ALL=NOPASSWD: ${qemu}" >>/mnt/etc/sudoers done - killall=$(binfinder killall) - # TODO: notwendig, oder reicht ifup/down - # TODO: /dev/fb0 mit jedermann - cat <> /mnt/etc/sudoers << EOF +# TODO: check if kvm / qemu sufficient +#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: /opt/openslx/uclib-rootfs/sbin/tunctl -t tap* #ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/sbin/ip addr add * dev tap* #ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tap* -EOF \ - >>/mnt/etc/sudoers +EOF fi else [ $DEBUGLEVEL -gt 0 ] && echo " * Configuration of 'qemukvm' plugin failed" diff --git a/os-plugins/plugins/qemukvm/files/ifdown b/os-plugins/plugins/qemukvm/files/ifdown index 8c52d76f..be6ec913 100644 --- a/os-plugins/plugins/qemukvm/files/ifdown +++ b/os-plugins/plugins/qemukvm/files/ifdown @@ -9,7 +9,7 @@ # # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- -# qemu-ifup +# ifdown # - Script used for network cleanup of qemukvm in stage4 # ----------------------------------------------------------------------------- diff --git a/os-plugins/plugins/qemukvm/files/run-virt.include b/os-plugins/plugins/qemukvm/files/run-virt.include index bdf9666f..84e534e8 100644 --- a/os-plugins/plugins/qemukvm/files/run-virt.include +++ b/os-plugins/plugins/qemukvm/files/run-virt.include @@ -52,6 +52,9 @@ else exit 1 fi +# hot keys ALT+CTRL+SHIFT +VIRTCMDOPTS="${VIRTCMDOPTS} -alt-grab" + # display name, remove blanks because of cmdline problems displayname=$(echo ${displayname} | sed -e "s, ,-,g") VIRTCMDOPTS="${VIRTCMDOPTS} -name ${displayname}" @@ -186,6 +189,7 @@ writelog "\tNetwork kind:\t\t${network_kind}" ### finally set env for run-virt.sh ################################################################################ +# TODO: besser drive statt hda? #-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i] # [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off] # [,cache=writethrough|writeback|none][,format=f][,serial=s] @@ -258,14 +262,18 @@ else VIRTCMD="sudo $VIRTCMD" fi +# using snapshots +VIRTCMDOPTS="${VIRTCMDOPTS} -snapshot" + # TODO: boot als var, -boot n, tftp... VIRTCMDOPTS="${VIRTCMDOPTS} -boot c" # set headless mode # define first, you do not want VIRTCMDOPTS from graphical start VIRTCMDHL="$VIRTCMD" -VIRTCMDOPTSHL="${VIRTCMDOPTS} -alt-grab -nographic -snapshot ${diskfile}" +VIRTCMDOPTSHL="${VIRTCMDOPTS} -nographic ${diskfile}" # graphical start VIRTCMD="$VIRTCMD" -VIRTCMDOPTS="${VIRTCMDOPTS} -alt-grab -full-screen -snapshot ${diskfile}" +# vga std/cirrus/vmware? +VIRTCMDOPTS="${VIRTCMDOPTS} -vga std -full-screen ${diskfile}" diff --git a/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh b/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh index ed67bddb..13771a43 100755 --- a/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh +++ b/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh @@ -19,7 +19,7 @@ CONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR} testmkd ${CONFDIR} # configuring dhcpd stub for virtual networks -cat < ${CONFDIR}/udhcpd.conf << EOF # general udhcpd configuration file for virtual machines written by # $0 during OpenSLX stage3 configuration @@ -57,5 +57,4 @@ option domain virtual.site ${domain_name} #wins #lease #ntpsrv #tftp #bootfile -EOF \ - >${CONFDIR}/udhcpd.conf +EOF diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index eb1cb0e9..27289b41 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -12,7 +12,7 @@ # General information about OpenSLX can be found at http://openslx.org # ----------------------------------------------------------------------------- # run-virt.include -# - Include script for running the Virtual Box on an OpenSLX client via the +# - Include script for running the VirtualBox on an OpenSLX client via the # run-virt.sh or run-vmgrid.sh ################################################################################ @@ -52,10 +52,10 @@ mkdir -p ${diskfolder} ${snapshotdir} 2>/dev/null 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]) +if echo ${imgname} | grep -iE "vdi|vmdk|vhd" >/dev/null 2>&1; then + imgtype=$(echo ${imgname##*.} | tr [a-z] [A-Z]) else - writelog "${imgname} is not a valid image type (vdi), exiting!" #vmdk|vhd + writelog "${imgname} is not a valid image type (vdi|vmdk|vhd), exiting!" exit 1 fi @@ -99,6 +99,7 @@ diskuuid=$(VBoxManage -q showvdiinfo ${diskfile} | grep UUID | \ # snapshot UUID is static snapshotuuid="88bc8b6d-f248-468a-95fe-318084904f8b" +# TODO: MEM muss noch angepasst werden. Maschine crasht wenn nehr als 50% MEM # memory part equal to vmware plugin # percentage of memory to use for virtualbox in standard case if [ -n "${forcemem}" ]; then diff --git a/os-plugins/plugins/vmgrid/XX_vmgrid.sh b/os-plugins/plugins/vmgrid/XX_vmgrid.sh index 004b7891..bdbd4836 100644 --- a/os-plugins/plugins/vmgrid/XX_vmgrid.sh +++ b/os-plugins/plugins/vmgrid/XX_vmgrid.sh @@ -19,7 +19,6 @@ . /etc/functions # hostname? -[ -e /tmp/confviadhcp ] && . /tmp/confviadhcp host_name=${host_name:=$clientip} CONFFILE="/initramfs/plugin-conf/vmgrid.conf" diff --git a/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm b/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm index 671e985f..7ab55d4a 100644 --- a/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm +++ b/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm @@ -59,7 +59,8 @@ sub getAttrInfo End-of-Here content_regex => qr{^(0|1)$}, content_descr => '1 means active - 0 means inactive', - default => '1', + # set active to 0, later set specially created Xen system to 1 + default => '0', }, }; } @@ -70,61 +71,59 @@ sub suggestAdditionalKernelModules my $makeInitRamFSEngine = shift; my @suggestedModules; - - # Xen needs bridge module and for SUSE 10.2 netloop other OS: to be checked - if ($makeInitRamFSEngine->{'distro-name'} =~ m{^suse}i) { - push @suggestedModules, qw( bridge netloop ) - } - - 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; #??? -} + # Xen needs bridge module and netloop + push @suggestedModules, qw( bridge netloop ); -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 - # TODO: versionsort oder per attr? - 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; + 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 +# # TODO: versionsort oder per attr? +# 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/XX_xen.sh b/os-plugins/plugins/xen/XX_xen.sh index ba2c4f00..82142a61 100644 --- a/os-plugins/plugins/xen/XX_xen.sh +++ b/os-plugins/plugins/xen/XX_xen.sh @@ -14,8 +14,13 @@ # script is included from init via the "." load function - thus it has all # variables and functions available -if [ -e /initramfs/plugin-conf/xen.conf ]; then - . /initramfs/plugin-conf/xen.conf +# include default directories +. /etc/openslx.conf + +CONFFILE=/initramfs/plugin-conf/xen.conf + +if [ -e ${CONFFILE} ]; then + . ${CONFFILE} if [ $xen_active -ne 0 ]; then testmkd /mnt/var/log/xen testmkd /mnt/var/run/xend diff --git a/os-plugins/plugins/xen/files/machine.include b/os-plugins/plugins/xen/files/machine.include new file mode 100644 index 00000000..93adca75 --- /dev/null +++ b/os-plugins/plugins/xen/files/machine.include @@ -0,0 +1,189 @@ +# -*- mode: python; -*- +#============================================================================ +# Python configuration setup for 'xm create'. +# This script sets the parameters used when a domain is created using 'xm create'. +# You use a separate script for each domain you want to create, or +# you can set the parameters for the domain on the xm command line. +#============================================================================ + +#---------------------------------------------------------------------------- +# Kernel image file and (optional) ramdisk (initrd). +kernel = "/boot/vmlinuz-xen" +ramdisk = "/boot/initrd-xen" + +# Or use domUloader instead of kernel/ramdisk to get kernel from domU FS +#bootloader = "/usr/lib/xen/boot/domUloader.py" +#bootentry = "hda2:/vmlinuz-xen,/initrd-xen" + +# The domain build function. Default is 'linux'. +#builder='linux' + +# Initial memory allocation (in megabytes) for the new domain. +# +# WARNING: Creating a domain with insufficient memory may cause out of +# memory errors. The domain needs enough memory to boot kernel +# and modules. Allocating less than 32MBs is not recommended. +memory = 64 + +# A name for your domain. All domains must have different names. +name = "ExampleDomain" + +# 128-bit UUID for the domain. The default behavior is to generate a new UUID +# on each call to 'xm create'. +#uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9" + +# List of which CPUS this domain is allowed to use, default Xen picks +#cpus = "" # leave to Xen to pick +#cpus = "0" # all vcpus run on CPU0 +#cpus = "0-3,5,^1" # run on cpus 0,2,3,5 + +# Number of Virtual CPUS to use, default is 1 +#vcpus = 1 + +#---------------------------------------------------------------------------- +# Define network interfaces. + +# By default, no network interfaces are configured. You may have one created +# with sensible defaults using an empty vif clause: +# +# vif = [ '' ] +# +# or optionally override backend, bridge, ip, mac, script, type, or vifname: +# +# vif = [ 'mac=00:16:3e:00:00:11, bridge=xenbr0' ] +# +# or more than one interface may be configured: +# +# vif = [ '', 'bridge=xenbr1' ] + +vif = [ '' ] + +#---------------------------------------------------------------------------- +# Define the disk devices you want the domain to have access to, and +# what you want them accessible as. +# Each disk entry is of the form phy:UNAME,DEV,MODE +# where UNAME is the device, DEV is the device name the domain will see, +# and MODE is r for read-only, w for read-write. + +disk = [ 'phy:hda1,hda1,w' ] + +#---------------------------------------------------------------------------- +# Define frame buffer device. +# +# By default, no frame buffer device is configured. +# +# To create one using the SDL backend and sensible defaults: +# +# vfb = [ 'type=sdl' ] +# +# This uses environment variables XAUTHORITY and DISPLAY. You +# can override that: +# +# vfb = [ 'type=sdl,xauthority=/home/bozo/.Xauthority,display=:1' ] +# +# To create one using the VNC backend and sensible defaults: +# +# vfb = [ 'type=vnc' ] +# +# The backend listens on 127.0.0.1 port 5900+N by default, where N is +# the domain ID. You can override both address and N: +# +# vfb = [ 'type=vnc,vnclisten=127.0.0.1,vncdisplay=1' ] +# +# Or you can bind the first unused port above 5900: +# +# vfb = [ 'type=vnc,vnclisten=0.0.0.0,vnunused=1' ] +# +# You can override the password: +# +# vfb = [ 'type=vnc,vncpasswd=MYPASSWD' ] +# +# Empty password disables authentication. Defaults to the vncpasswd +# configured in xend-config.sxp. + +#---------------------------------------------------------------------------- +# Define to which TPM instance the user domain should communicate. +# The vtpm entry is of the form 'instance=INSTANCE,backend=DOM' +# where INSTANCE indicates the instance number of the TPM the VM +# should be talking to and DOM provides the domain where the backend +# is located. +# Note that no two virtual machines should try to connect to the same +# TPM instance. The handling of all TPM instances does require +# some management effort in so far that VM configration files (and thus +# a VM) should be associated with a TPM instance throughout the lifetime +# of the VM / VM configuration file. The instance number must be +# greater or equal to 1. +#vtpm = [ 'instance=1,backend=0' ] + +#---------------------------------------------------------------------------- +# Set the kernel command line for the new domain. +# You only need to define the IP parameters and hostname if the domain's +# IP config doesn't, e.g. in ifcfg-eth0 or via DHCP. +# You can use 'extra' to set the runlevel and custom environment +# variables used by custom rc scripts (e.g. VMID=, usr= ). + +# Set if you want dhcp to allocate the IP address. +#dhcp="dhcp" +# Set netmask. +#netmask= +# Set default gateway. +#gateway= +# Set the hostname. +#hostname= "vm%d" % vmid + +# Set root device. +root = "/dev/hda1" + +# Root device for nfs. +#root = "/dev/nfs" +# The nfs server. +#nfs_server = '169.254.1.0' +# Root directory on the nfs server. +#nfs_root = '/full/path/to/root/directory' + +# Extra arguments to pass to the kernel. +extra = "" + +#---------------------------------------------------------------------------- +# Configure the behaviour when a domain exits. There are three 'reasons' +# for a domain to stop: poweroff, reboot, and crash. For each of these you +# may specify: +# +# "destroy", meaning that the domain is cleaned up as normal; +# "restart", meaning that a new domain is started in place of the old +# one; +# "preserve", meaning that no clean-up is done until the domain is +# manually destroyed (using xm destroy, for example); or +# "rename-restart", meaning that the old domain is not cleaned up, but is +# renamed and a new domain started in its place. +# +# In the event a domain stops due to a crash, you have the additional options: +# +# "coredump-destroy", meaning dump the crashed domain's core and then destroy; +# "coredump-restart', meaning dump the crashed domain's core and the restart. +# +# The default is +# +# on_poweroff = 'destroy' +# on_reboot = 'restart' +# on_crash = 'restart' +# +# For backwards compatibility we also support the deprecated option restart +# +# restart = 'onreboot' means on_poweroff = 'destroy' +# on_reboot = 'restart' +# on_crash = 'destroy' +# +# restart = 'always' means on_poweroff = 'restart' +# on_reboot = 'restart' +# on_crash = 'restart' +# +# restart = 'never' means on_poweroff = 'destroy' +# on_reboot = 'destroy' +# on_crash = 'destroy' + +#on_poweroff = 'destroy' +#on_reboot = 'restart' +#on_crash = 'restart' + +#============================================================================ diff --git a/os-plugins/plugins/xen/files/run-virt.include b/os-plugins/plugins/xen/files/run-virt.include new file mode 100644 index 00000000..beba0bb6 --- /dev/null +++ b/os-plugins/plugins/xen/files/run-virt.include @@ -0,0 +1,290 @@ +# 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 +# +# 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 +# ----------------------------------------------------------------------------- +# run-virt.include +# - Include script for running Xen 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 +################################################################################ + +exit +#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} +# define dirs and files which can be removed after exit, be carefull! +#RMDIRS="${snapshotdir} ${confdir} /tmp/.vbox-${USER}-ipc" 2>/dev/null +#rm -rf ${RMDIRS} 2>/dev/null +#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 +#diskfile="${diskfolder}/${imgname}" +#mkdir -p ${diskfolder} ${snapshotdir} 2>/dev/null +#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), exiting!" #vmdk|vhd +# exit 1 +#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') +# +# 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 +#if [ -n "${forcemem}" ]; then +# mem="${forcemem}" +#else +# 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 +# # 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 +# +# 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"' +# ;; +# hostonly|host-only) +# network_kind='HostOnlyInterface name="vboxnet0"' +# ;; +# *) +# network_kind="NAT" +# ;; +#esac +# +# external GUI +#vrdpport="590${VM_ID}" +# +# TODO: nur bei vmchooser +# 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= +#fdtest=${floppy_0:+"TRUE"} +# if $fdtest not set floppy0="FALSE", else "TRUE" +#floppy0=${fdtest:-"FALSE"} +#floppy1="TRUE" +#floppy1name="/var/lib/virt/vmchooser/loopimg/fd.img" +# if $cdrom_0 from run-virt.include set then cdtest="TRUE" +#cdtest= +#cdtest=${cdrom_0:+"TRUE"} +# if $cdtest not set cdrom0="FALSE", else "TRUE" +#cdrom0=${cdtest:-"FALSE"} +# if $cdrom_1 from run-virt.include set then cdtest="TRUE" +#cdtest= +#cdtest=${cdrom_1:+"TRUE"} +# if $cdtest not set cdrom1="FALSE", else "TRUE" +#cdrom1=${cdtest:-"FALSE"} +# ide is expected default, test for the virtual disk image type should +# be done while creating the runscripts ... +#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}" +# TODO: server start activate via xml, etc... +#writelog "\tGuest VRDP port:\t${vrdpport}" +#writelog "\tCD-ROM1:\t${cdrom0}" +#writelog "\tCD-ROM2:\t${cdrom1}" +#writelog "\tFloppy_A:\t${floppy0}" +#writelog "\tFloppy_B:\t${floppy1}" +#writelog "\tShared Folders 'home':\t/home/${USER}" +# +################################################################################ +### Pepare and configure virtual machine and disk image +################################################################################ +# +# TODO: date wichtig? +#date="$(date +%Y-%m-%dT%H:%M:%SZ)" +#. ${PLUGINCONFVIRTUALBOX}/virtualbox.include >"${VBOX_USER_HOME}/VirtualBox.xml" +# +# shortened date YYYY-MM-DD +#date=${date%T*} +#. ${PLUGINCONFVIRTUALBOX}/machine.include >"${machconfig}" +# +# add rw share to vm, if existing +#if [ -n "${rwshare}" ]; then +# sharedf='" +# sed -i "s,, ${sharedf}\n ," \ +# "${machconfig}" +# writelog "\tShared Folders 'share':\t${rwshare}" +#fi +# +# add ssh port if linux and NAT +#if [ "${vmostype}" = "Linux26" ] && [ "${network_kind}" = "NAT" ]; then +# vmsshport="220${VM_ID}" +# extradataitem='" +# extradataprotocol='Protocol" value="TCP"/>' +# sed -i "s,, ${extradataitem}${extradataguestport}\n\ +# ${extradataitem}${extradatahostport}\n\ +# ${extradataitem}${extradataprotocol}\n\ +# ," "${machconfig}" +# writelog "\tGuest SSH port:\t\t${vmsshport}" +#fi +# +#cat ${OPENSLX_DEFAULT_DIR}/plugin-repo/virtualbox/empty-diff.vdi.gz | \ +# gunzip > "${snapshotdir}/{${snapshotuuid}}.vdi" +# +################################################################################ +### 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 +# +# set the variables appropriately (several interfaces with different names) +#VIRTCMD=$(which VirtualBox 2>/dev/null) +#VIRTCMDOPTS="--startvm ${machineuuid} --start-running" +# +# SDL tests +#VIRTCMDSDL=$(which VBoxSDL 2>/dev/null) +#VIRTCMDOPTSSDL="--startvm ${machineuuid} --fullscreen --hwvirtex --memory 1024 \ +# --fixedmode 1680 1050 24 --hostkey 302 0" +# +# set headless mode +#VIRTCMDHL=$(which VBoxHeadless 2>/dev/null) +#VIRTCMDOPTSHL="-s ${machineuuid}" -- cgit v1.2.3-55-g7522 From 1f031fbafab207fe0879217ae9215caea783ed00 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Wed, 24 Mar 2010 20:01:46 +0100 Subject: new run-virt.include for xen plugin. qemukvm modules now loaded via runlevelscript qemukvm, script added to sudoers as well. better ideas? --- .../plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm | 27 +- os-plugins/plugins/qemukvm/XX_qemukvm.sh | 42 +-- .../plugins/virtualbox/files/run-virt.include | 4 +- os-plugins/plugins/vmchooser/files/run-virt.sh | 2 + os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 36 ++- os-plugins/plugins/xen/XX_xen.sh | 5 +- os-plugins/plugins/xen/files/hvm.include | 209 ++++++++++++++ os-plugins/plugins/xen/files/machine.include | 114 +++----- os-plugins/plugins/xen/files/run-virt.include | 318 +++++---------------- 9 files changed, 403 insertions(+), 354 deletions(-) create mode 100644 os-plugins/plugins/xen/files/hvm.include (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm index 8029102c..203a7ed3 100644 --- a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm +++ b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm @@ -133,11 +133,6 @@ sub installationPhase copyFile("$pluginBasePath/$file", "$pluginRepoPath/"); } chmod 0755, "$pluginRepoPath/ifup", "$pluginRepoPath/ifdown"; -# # Create kvm link -# my $kvmPath = pathOf('qemu-kvm') || pathOf('kvm') || pathOf('qemu'); -# if (defined $kvmPath) { -# linkFile($kvmPath, "$pluginRepoPath/qemukvm") -# } my $initFile = newInitFile(); $initFile->setName("qemukvm"); @@ -146,7 +141,24 @@ sub installationPhase # TODO: default dirs als globale funktion anbieten $initFile-> addToBlock('head','. /etc/opt/openslx/plugins/qemukvm/network.conf'); + + # TODO: remove all runlevel links for qemu-kvm or kvm + my $kvm_module = unshiftHereDoc(<<' End-of-Here'); + # Figure out which module we need. + if grep -q ^flags.*\\\ /proc/cpuinfo; then + module=kvm_intel + elif grep -q ^flags.*\\\ /proc/cpuinfo; then + module=kvm_amd + else + unset module + fi + End-of-Here + my $do_start = unshiftHereDoc(<<' End-of-Here'); + # loading kvm module + [ -n "${module}" ] && modprobe -q ${module} + # load the tunnel device module + modprobe -q tun # configuring the tap0 interface to the existing bridge configured in stage3 for i in 0 1 2; do /opt/openslx/uclib-rootfs/sbin/tunctl -t tap${i} >/dev/null 2>&1 @@ -157,10 +169,14 @@ sub installationPhase ip addr add ${hoaddress} dev tap2 echo "1" >/proc/sys/net/ipv4/conf/br0/forwarding echo "1" >/proc/sys/net/ipv4/conf/tap0/forwarding + # make /dev/fb0 writable for all # TODO: maybe solve via group or udev, etc... chmod 766 /dev/fb* End-of-Here + my $do_stop = unshiftHereDoc(<<' End-of-Here'); + [ -n "${module}" ] && modprobe -q -r ${module} + modprobe -q -r tun /opt/openslx/uclib-rootfs/usr/sbin/brctl delif br0 tap0 ip addr del ${nataddress} dev tap1 ip addr del ${hoaddress} dev tap2 @@ -168,6 +184,7 @@ sub installationPhase echo "0" >/proc/sys/net/ipv4/conf/tap0/forwarding chmod 760 /dev/fb* End-of-Here + my $do_restart = unshiftHereDoc(<<' End-of-Here'); do_stop && do_start End-of-Here diff --git a/os-plugins/plugins/qemukvm/XX_qemukvm.sh b/os-plugins/plugins/qemukvm/XX_qemukvm.sh index b3c4ccf0..2a907861 100644 --- a/os-plugins/plugins/qemukvm/XX_qemukvm.sh +++ b/os-plugins/plugins/qemukvm/XX_qemukvm.sh @@ -39,27 +39,27 @@ if [ -e ${CONFFILE} ]; then cp /mnt/${PLUGINDIR}/run-virt.include ${PLUGINCONFDIR} cp ${CONFFILE} ${PLUGINCONFDIR} - # check for the virtualization CPU features - if grep -q "vmx" /proc/cpuinfo && modprobe ${MODPRV} kvm_intel ; then - [ $DEBUGLEVEL -gt 0 ] && echo " * Loaded kvm_intel module" - echo "kvm=intel" >> ${PLUGINCONFDIR}/qemukvm.conf - elif grep -q "svm" /proc/cpuinfo && modprobe ${MODPRV} kvm_amd ; then - [ $DEBUGLEVEL -gt 0 ] && echo " * Loaded kvm_amd module" - echo "kvm=amd" >> ${PLUGINCONFDIR}/qemukvm.conf - elif modprobe ${MODPRV} kqemu ; then - [ $DEBUGLEVEL -gt 0 ] && \ - error " * Successfully loaded the kqemu module, but loading of kvm_amd \ -or kvm_intel\n failed, because no virtualization extenstion found in this \ -CPU. Please\n enable the extension within your machines BIOS or get another \ -CPU." nonfatal - else - error " * All module loading failed including the kqemu module, which \ -was either\n not found or couldn't be loaded for other reasons. Thus using \ -qemu(-kvm)\n makes not much sense." nonfatal - fi +# # check for the virtualization CPU features +# if grep -q "vmx" /proc/cpuinfo && modprobe ${MODPRV} kvm_intel ; then +# [ $DEBUGLEVEL -gt 0 ] && echo " * Loaded kvm_intel module" +# echo "kvm=intel" >> ${PLUGINCONFDIR}/qemukvm.conf +# elif grep -q "svm" /proc/cpuinfo && modprobe ${MODPRV} kvm_amd ; then +# [ $DEBUGLEVEL -gt 0 ] && echo " * Loaded kvm_amd module" +# echo "kvm=amd" >> ${PLUGINCONFDIR}/qemukvm.conf +# elif modprobe ${MODPRV} kqemu ; then +# [ $DEBUGLEVEL -gt 0 ] && \ +# error " * Successfully loaded the kqemu module, but loading of kvm_amd \ +#or kvm_intel\n failed, because no virtualization extenstion found in this \ +#CPU. Please\n enable the extension within your machines BIOS or get another \ +#CPU." nonfatal +# else +# error " * All module loading failed including the kqemu module, which \ +#was either\n not found or couldn't be loaded for other reasons. Thus using \ +#qemu(-kvm)\n makes not much sense." nonfatal +# fi - # load the tunnel device module - modprobe tun 2>/dev/null +# # load the tunnel device module +# modprobe tun 2>/dev/null # get source of qemukvm image server (get type, server and path) if strinstr "/" "${qemukvm_imagesrc}" ; then @@ -100,6 +100,8 @@ ${qemukvm_imagesrc}." nonfatal done #killall=$(binfinder killall) cat >> /mnt/etc/sudoers << EOF +# allow to start and stop kvm services / load-/unload kvm modules +ALL ALL=NOPASSWD: /etc/init.d/qemukvm # TODO: check if kvm / qemu sufficient #ALL ALL=NOPASSWD: ${killall} udhcpd #ALL ALL=NOPASSWD: ${PLUGINDIR}/ifup diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index 27289b41..e3650ebd 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -41,9 +41,7 @@ export VBOX_USER_HOME=${confdir} RMDIRS="${snapshotdir} ${confdir} /tmp/.vbox-${USER}-ipc" 2>/dev/null rm -rf ${RMDIRS} 2>/dev/null 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") +# use vm_shortname for VM name since vm_name can be very long machconfig="${machfolder}/${vm_shortname}/${vm_shortname}.xml" diskfolder="${VBOX_USER_HOME}/HardDisks" snapshotdir=${machfolder}/${vm_shortname}/Snapshots diff --git a/os-plugins/plugins/vmchooser/files/run-virt.sh b/os-plugins/plugins/vmchooser/files/run-virt.sh index 6df6bf84..38dd5ac6 100644 --- a/os-plugins/plugins/vmchooser/files/run-virt.sh +++ b/os-plugins/plugins/vmchooser/files/run-virt.sh @@ -69,6 +69,8 @@ vm_name=$(grep -o "short_description param=.*\"" ${xml} | \ # If ${short_description} not defined use ${image_name} # if ${vm_name} not defined use ${imgname} vm_name=${vm_name:-"${imgname%.*}"} +# define vm_shortname since vm_name can be very long +vm_shortname=$(echo ${imgname%.*} | sed -e "s, ,-,g") displayname=${vm_name} # remove blanks vm_name=$(echo ${vm_name} | sed -e "s, ,-,g") diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index 8d199ccf..ce707830 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -131,10 +131,10 @@ writelog "Starting configuration..." writelog "\tVM-ID:\t\t\t${VM_ID}" writelog "\tLogfile:\t\t${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log" writelog "\t$(df -h | grep " /tmp$" | awk '{print $2}') \c" -writelog "/tmp info:\t\t$(grep "/tmp " /proc/mounts | sed -e "s,/tmp ,,")" +writelog "\t/tmp info:\t\t$(grep "/tmp " /proc/mounts) $(df -h | \ + grep " /tmp$" | awk '{print $2}')" writelog "\tVM XML dir:\t\t${vmgrid_xmlpath}" writelog "\tVM Image dir:\t\t${vmgrid_imgpath}" -writelog "VM config:" if ! grep '/dev/null 2>&1; then writelog \ @@ -143,13 +143,18 @@ if ! grep '/dev/null 2>&1; then fi writelog "\tXML file:\t\t$xmlfile" +writelog "VM config:" -imgpath=${vmgrid_imgpath} - -# name of the virt image of dir -imgname=$(grep -io 'image_name param=.*"' ${xmlfile} | sed -e "s/&.*;/; /g" | \ - awk -F '"' '{ print $2 }') -# full path +# name of the virt image or dir +imgname=$(grep -io '/dev/null | grep '/' >/dev/null 2>&1; then + imgpath=$(dirname ${imgname}) + imgname=$(basename ${imgname}) +else + imgpath=${vmgrid_imgpath} +fi +# set default v path vmpath=${imgpath}/${imgname} # check if virtual machine container file exists @@ -163,16 +168,17 @@ writelog "\tVM file/dir:\t\t$vmpath" # name of the virt machine, sed because of Windows formatting vm_name=$(grep -o 'short_description param=.*"' ${xmlfile} | \ sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}') +# if ${vm_name} not defined use ${imgname} +vm_name=${vm_name:-"${imgname%.*}"} +# define vm_shortname since vm_name can be very long +vm_shortname=$(echo ${imgname%.*} | sed -e "s, ,-,g") +# vm_name = displayname, define for old scripts +displayname=${vm_name} # is there an additional configuration provided? additional_config=$(grep -o 'additional_config param=.*"' ${xmlfile} | \ sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}') -# if ${vm_name} not defined use ${imgname} -vm_name=${vm_name:-"${imgname%.*}"} -displayname=${vm_name} -# remove blanks - # image is for the following virtual machine xmlvirt=$(grep -o 'virtualmachine param=.*"' ${xmlfile} | \ sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}') @@ -231,8 +237,8 @@ network_card=$(grep -io 'netcard param=.*"' ${xmlfile} | \ awk -F '"' '{ print $2 }') writelog "\tVirtualization:\t\t$xmlvirt" -writelog "\tVM Name:\t\t$vm_name" -writelog "\tVM Displayname:\t\t$displayname" +writelog "\tVM name:\t\t$vm_name" +writelog "\tVM short name:\t\t$vm_shortname" ############################################################################### ### Declaration of default variables diff --git a/os-plugins/plugins/xen/XX_xen.sh b/os-plugins/plugins/xen/XX_xen.sh index 82142a61..d3620c76 100644 --- a/os-plugins/plugins/xen/XX_xen.sh +++ b/os-plugins/plugins/xen/XX_xen.sh @@ -26,8 +26,9 @@ if [ -e ${CONFFILE} ]; then testmkd /mnt/var/run/xend testmkd /mnt/var/run/xenstored - rllinker "xendomains" 14 8 - rllinker "xend" 13 9 +# TODO: disable for testing purposes. suse 11.0 kills network +# rllinker "xendomains" 14 8 +# rllinker "xend" 13 9 modprobe loop max_loop=64 fi diff --git a/os-plugins/plugins/xen/files/hvm.include b/os-plugins/plugins/xen/files/hvm.include new file mode 100644 index 00000000..beb9315a --- /dev/null +++ b/os-plugins/plugins/xen/files/hvm.include @@ -0,0 +1,209 @@ +# This is an machine template for run-virt.include of the Xen plugin. +# This template was taken from an example in openSUSE 11.2 +# HVM template + +cat < 1 +#apic=1 + +# Enable/disable extended power management support within HVM guest, i.e., beyond +# S3, S4, S5 within guest like exposing battery meter. +# 0 (default option, extended power management support disabled) +# 1 (pass-through mode; uses pass-through as needed; efficient but limited in scope) +# 2 (non pass-through mode; extended scope, likely to work on all applicable environment +# but comparitively less efficient than pass-through mode) +# xen_extended_power_mgmt=0 + +# List of which CPUS this domain is allowed to use, default Xen picks +#cpus = "" # leave to Xen to pick +#cpus = "0" # all vcpus run on CPU0 +#cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5 +#cpus = ["2", "3"] # VCPU0 runs on CPU2, VCPU1 runs on CPU3 + +#---------------------------------------------------------------------------- +# Optionally define mac and/or bridge for the network interfaces. +# Random MACs are assigned if not given. +#vif = [ 'type=ioemu, mac=00:16:3e:00:00:11, bridge=xenbr0, model=ne2k_pci' ] +# type=ioemu specify the NIC is an ioemu device not netfront +#vif = [ 'type=ioemu, bridge=xenbr0' ] +vif = [ '${xen_vif}' ] + +#---------------------------------------------------------------------------- +# Define the disk devices you want the domain to have access to, and +# what you want them accessible as. +# Each disk entry is of the form phy:UNAME,DEV,MODE +# where UNAME is the device, DEV is the device name the domain will see, +# and MODE is r for read-only, w for read-write. +#disk = [ 'phy:hda1,hda1,r' ] +#disk = [ 'file:/var/lib/xen/images/disk.img,ioemu:hda,w', ',hdc:cdrom,r' ] +disk = [ '${xen_disk}' ] + +#---------------------------------------------------------------------------- +# Configure the behaviour when a domain exits. There are three 'reasons' +# for a domain to stop: poweroff, reboot, and crash. For each of these you +# may specify: +# "destroy", meaning that the domain is cleaned up as normal; +# "restart", meaning that a new domain is started in place of the old +# one; +# "preserve", meaning that no clean-up is done until the domain is +# manually destroyed (using xm destroy, for example); or +# "rename-restart", meaning that the old domain is not cleaned up, but is +# renamed and a new domain started in its place. +# In the event a domain stops due to a crash, you have the additional options: +# "coredump-destroy", meaning dump the crashed domain's core and then destroy; +# "coredump-restart', meaning dump the crashed domain's core and the restart. +# The default is +# on_poweroff = 'destroy' +# on_reboot = 'restart' +# on_crash = 'restart' +#on_poweroff = 'destroy' +#on_reboot = 'restart' +#on_crash = 'restart' + +#============================================================================ +# HVM specific +#============================================================================ +# Device Model to be used +device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm' + +#----------------------------------------------------------------------------- +# boot on floppy (a), hard disk (c), Network (n) or CD-ROM (d) +# default: hard disk, cd-rom, floppy +#boot="cda" + +#----------------------------------------------------------------------------- +# write to temporary files instead of disk image files +#snapshot=1 + +#---------------------------------------------------------------------------- +# enable SDL library for graphics, default = 0 +sdl=0 + +#---------------------------------------------------------------------------- +# enable OpenGL for texture rendering inside the SDL window, default = 1 +# valid only if sdl is enabled. +opengl=1 + +#---------------------------------------------------------------------------- +# enable VNC library for graphics, default = 1 +vnc=1 + +#---------------------------------------------------------------------------- +# address that should be listened on for the VNC server if vnc is set. +# default is to use 'vnc-listen' setting from /etc/xen/xend-config.sxp +#vnclisten="127.0.0.1" + +#---------------------------------------------------------------------------- +# set VNC display number, default = domid +#vncdisplay=1 + +#---------------------------------------------------------------------------- +# try to find an unused port for the VNC server, default = 1 +#vncunused=1 + +#---------------------------------------------------------------------------- +# set password for domain's VNC console +# default is depents on vncpasswd in xend-config.sxp +vncpasswd='' + +#---------------------------------------------------------------------------- +# no graphics, use serial port +#nographic=0 + +#---------------------------------------------------------------------------- +# enable stdvga, default = 0 (use cirrus logic device model) +stdvga=0 + +#----------------------------------------------------------------------------- +# serial port re-direct to pty deivce, /dev/pts/n +# then xm console or minicom can connect +serial='pty' + + +#----------------------------------------------------------------------------- +# Qemu Monitor, default is disable +# Use ctrl-alt-2 to connect +#monitor=1 + + +#----------------------------------------------------------------------------- +# enable sound card support, [sb16|es1370|all|..,..], default none +#soundhw='sb16' + + +#----------------------------------------------------------------------------- +# set the real time clock to local time [default=0 i.e. set to utc] +#localtime=1 + + +#----------------------------------------------------------------------------- +# set the real time clock offset in seconds [default=0 i.e. same as dom0] +#rtc_timeoffset=3600 + +#----------------------------------------------------------------------------- +# start in full screen +#full-screen=1 + + +#----------------------------------------------------------------------------- +# Enable USB support (specific devices specified at runtime through the +# monitor window) +#usb=1 +# Enable USB mouse support (only enable one of the following, `mouse' for +# PS/2 protocol relative mouse, `tablet' for +# absolute mouse) +#usbdevice='mouse' +#usbdevice='tablet' + +#----------------------------------------------------------------------------- +# Set keyboard layout, default is en-us keyboard. +#keymap='de' + +#----------------------------------------------------------------------------- +# Enable/disable xen platform PCI device, default=1 (enabled) +#xen_platform_pci=1 + +#============================================================================ +EOF diff --git a/os-plugins/plugins/xen/files/machine.include b/os-plugins/plugins/xen/files/machine.include index 93adca75..a1573578 100644 --- a/os-plugins/plugins/xen/files/machine.include +++ b/os-plugins/plugins/xen/files/machine.include @@ -1,62 +1,55 @@ +# This is an machine template for run-virt.include of the Xen plugin. +# This template was taken from an example in openSUSE 11.2 + +cat </dev/null +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} +confdir="/tmp/${self}/${USER}/${VM_ID}" +# use vm_shortname for VM name since vm_name can be very long +vm_name=${vm_shortname} +conffile=${confdir}/${vm_name} # define dirs and files which can be removed after exit, be carefull! -#RMDIRS="${snapshotdir} ${confdir} /tmp/.vbox-${USER}-ipc" 2>/dev/null -#rm -rf ${RMDIRS} 2>/dev/null -#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 -#diskfile="${diskfolder}/${imgname}" -#mkdir -p ${diskfolder} ${snapshotdir} 2>/dev/null -#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), exiting!" #vmdk|vhd -# exit 1 -#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" -# +RMDIRS="${confdir}" 2>/dev/null +rm -rf ${RMDIRS} 2>/dev/null + +# TODO: read from XML file +xen_kernel=/boot/vmlinuz-xen +xen_ramdisk=/initrd-xen +xen_root=/dev/sda1 +xen_extra=3 +xen_disk="file:${vmpath},sda1,r" +xen_vif="mac=$macaddr, bridge=xenbr0" +xen_dhcp="dhcp" # off + +writelog "Directories:" +writelog "\tConfig dir:\t\t$confdir" + ################################################################################ ### Hardware checks ################################################################################ -# -# remove ':' from MAC addr for vbox -#macaddr=$(echo ${macaddr} | sed 's/://g') -# -# 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 -#if [ -n "${forcemem}" ]; then -# mem="${forcemem}" -#else -# 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 -# # 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 -# -# 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"' -# ;; -# hostonly|host-only) -# network_kind='HostOnlyInterface name="vboxnet0"' -# ;; -# *) -# network_kind="NAT" -# ;; -#esac -# -# external GUI -#vrdpport="590${VM_ID}" -# -# TODO: nur bei vmchooser -# 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= -#fdtest=${floppy_0:+"TRUE"} -# if $fdtest not set floppy0="FALSE", else "TRUE" -#floppy0=${fdtest:-"FALSE"} -#floppy1="TRUE" -#floppy1name="/var/lib/virt/vmchooser/loopimg/fd.img" -# if $cdrom_0 from run-virt.include set then cdtest="TRUE" -#cdtest= -#cdtest=${cdrom_0:+"TRUE"} -# if $cdtest not set cdrom0="FALSE", else "TRUE" -#cdrom0=${cdtest:-"FALSE"} -# if $cdrom_1 from run-virt.include set then cdtest="TRUE" -#cdtest= -#cdtest=${cdrom_1:+"TRUE"} -# if $cdtest not set cdrom1="FALSE", else "TRUE" -#cdrom1=${cdtest:-"FALSE"} -# ide is expected default, test for the virtual disk image type should -# be done while creating the runscripts ... -#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" +if [ -n "${forcemem}" ]; then + mem="${forcemem}" +else + 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 + # 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 + +writelog "Diskimage:" +writelog "\tMachine diskfile:\t\t$vmpath" +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}" -# TODO: server start activate via xml, etc... -#writelog "\tGuest VRDP port:\t${vrdpport}" -#writelog "\tCD-ROM1:\t${cdrom0}" -#writelog "\tCD-ROM2:\t${cdrom1}" -#writelog "\tFloppy_A:\t${floppy0}" -#writelog "\tFloppy_B:\t${floppy1}" -#writelog "\tShared Folders 'home':\t/home/${USER}" -# +[ -n "${memhost}" ] && writelog "\tHost RAM:\t\t${memhost} MB" +writelog "\tMAC address:\t\t$macaddr" + ################################################################################ ### Pepare and configure virtual machine and disk image ################################################################################ -# -# TODO: date wichtig? -#date="$(date +%Y-%m-%dT%H:%M:%SZ)" -#. ${PLUGINCONFVIRTUALBOX}/virtualbox.include >"${VBOX_USER_HOME}/VirtualBox.xml" -# -# shortened date YYYY-MM-DD -#date=${date%T*} -#. ${PLUGINCONFVIRTUALBOX}/machine.include >"${machconfig}" -# -# add rw share to vm, if existing -#if [ -n "${rwshare}" ]; then -# sharedf='" -# sed -i "s,, ${sharedf}\n ," \ -# "${machconfig}" -# writelog "\tShared Folders 'share':\t${rwshare}" -#fi -# -# add ssh port if linux and NAT -#if [ "${vmostype}" = "Linux26" ] && [ "${network_kind}" = "NAT" ]; then -# vmsshport="220${VM_ID}" -# extradataitem='" -# extradataprotocol='Protocol" value="TCP"/>' -# sed -i "s,, ${extradataitem}${extradataguestport}\n\ -# ${extradataitem}${extradatahostport}\n\ -# ${extradataitem}${extradataprotocol}\n\ -# ," "${machconfig}" -# writelog "\tGuest SSH port:\t\t${vmsshport}" -#fi -# -#cat ${OPENSLX_DEFAULT_DIR}/plugin-repo/virtualbox/empty-diff.vdi.gz | \ -# gunzip > "${snapshotdir}/{${snapshotuuid}}.vdi" -# + +. ${PLUGINCONFXEN}/machine.include > ${conffile} + ################################################################################ ### 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 -# + # set the variables appropriately (several interfaces with different names) -#VIRTCMD=$(which VirtualBox 2>/dev/null) -#VIRTCMDOPTS="--startvm ${machineuuid} --start-running" -# -# SDL tests -#VIRTCMDSDL=$(which VBoxSDL 2>/dev/null) -#VIRTCMDOPTSSDL="--startvm ${machineuuid} --fullscreen --hwvirtex --memory 1024 \ -# --fixedmode 1680 1050 24 --hostkey 302 0" -# +VIRTCMD=$(which xm 2>/dev/null) +VIRTCMDOPTS="create ${conffile}" + # set headless mode -#VIRTCMDHL=$(which VBoxHeadless 2>/dev/null) -#VIRTCMDOPTSHL="-s ${machineuuid}" +VIRTCMDHL=$(which xm 2>/dev/null) +VIRTCMDOPTSHL="create ${conffile}" -- cgit v1.2.3-55-g7522 From 05d263fe3e313bde1c3da2fa67237df894971d43 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Thu, 25 Mar 2010 18:33:20 +0100 Subject: added support for rw disks and netboot --- .../virtualbox/OpenSLX/OSPlugin/virtualbox.pm | 2 +- os-plugins/plugins/virtualbox/XX_virtualbox.sh | 30 +- .../plugins/virtualbox/files/machine.include | 4 +- .../plugins/virtualbox/files/run-virt.include | 86 ++- os-plugins/plugins/virtualbox/files/rwimg.vdi.gz | Bin 0 -> 268 bytes os-plugins/plugins/vmchooser/files/run-virt.sh | 4 + os-plugins/plugins/vmgrid/XX_vmgrid.sh | 31 +- os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 26 +- os-plugins/plugins/vmware/files/run-virt.include | 4 +- os-plugins/plugins/xen/files/xen.examples/README | 51 ++ .../files/xen.examples/README.incompatibilities | 38 + .../files/xen.examples/examples/xmexample.disks | 32 + .../xen.examples/examples/xmexample.domUloader | 28 + .../xen/files/xen.examples/examples/xmexample.hvm | 358 ++++++++++ .../xen.examples/examples/xmexample.hvm-stubdom | 314 ++++++++ .../files/xen.examples/examples/xmexample.pv-grub | 186 +++++ .../xen/files/xen.examples/examples/xmexample1 | 213 ++++++ .../xen/files/xen.examples/examples/xmexample2 | 248 +++++++ .../xen/files/xen.examples/examples/xmexample3 | 234 ++++++ os-plugins/plugins/xen/files/xen.examples/images | 1 + .../plugins/xen/files/xen.examples/qemu-ifup | 23 + .../plugins/xen/files/xen.examples/scripts/blktap | 93 +++ .../plugins/xen/files/xen.examples/scripts/block | 398 +++++++++++ .../xen/files/xen.examples/scripts/block-common.sh | 117 +++ .../xen/files/xen.examples/scripts/block-iscsi | 78 ++ .../xen/files/xen.examples/scripts/block-nbd | 34 + .../xen/files/xen.examples/scripts/block-npiv | 77 ++ .../xen.examples/scripts/block-npiv-common.sh | 238 +++++++ .../files/xen.examples/scripts/block-npiv-vport | 79 ++ .../xen/files/xen.examples/scripts/domain-lock | 83 +++ .../xen.examples/scripts/external-device-migrate | 98 +++ .../xen/files/xen.examples/scripts/locking.sh | 98 +++ .../xen/files/xen.examples/scripts/logging.sh | 22 + .../xen/files/xen.examples/scripts/network-bridge | 380 ++++++++++ .../xen/files/xen.examples/scripts/network-nat | 125 ++++ .../xen/files/xen.examples/scripts/network-route | 27 + .../xen/files/xen.examples/scripts/set-lock | 1 + .../xen/files/xen.examples/scripts/vif-bridge | 100 +++ .../xen/files/xen.examples/scripts/vif-common.sh | 158 ++++ .../plugins/xen/files/xen.examples/scripts/vif-nat | 192 +++++ .../xen/files/xen.examples/scripts/vif-route | 56 ++ .../xen/files/xen.examples/scripts/vm-monitor | 41 ++ .../plugins/xen/files/xen.examples/scripts/vscsi | 22 + .../plugins/xen/files/xen.examples/scripts/vtpm | 22 + .../xen/files/xen.examples/scripts/vtpm-common.sh | 448 ++++++++++++ .../xen/files/xen.examples/scripts/vtpm-delete | 18 + .../xen.examples/scripts/vtpm-hotplug-common.sh | 35 + .../xen/files/xen.examples/scripts/vtpm-impl | 208 ++++++ .../files/xen.examples/scripts/vtpm-migration.sh | 19 + .../files/xen.examples/scripts/xen-hotplug-cleanup | 36 + .../xen.examples/scripts/xen-hotplug-common.sh | 93 +++ .../xen.examples/scripts/xen-network-common.sh | 118 +++ .../xen.examples/scripts/xen-script-common.sh | 44 ++ .../files/xen.examples/scripts/xend-relocation.sh | 159 +++++ .../xen/files/xen.examples/scripts/xmclone.sh | 793 +++++++++++++++++++++ .../plugins/xen/files/xen.examples/xenapiusers | 1 + .../xen/files/xen.examples/xend-config-xenapi.sxp | 193 +++++ .../plugins/xen/files/xen.examples/xend-config.sxp | 323 +++++++++ .../xen/files/xen.examples/xend-pci-permissive.sxp | 27 + .../xen/files/xen.examples/xend-pci-quirks.sxp | 96 +++ .../xen/files/xen.examples/xm-config-xenapi.xml | 43 ++ .../plugins/xen/files/xen.examples/xm-config.xml | 45 ++ 62 files changed, 7102 insertions(+), 49 deletions(-) create mode 100644 os-plugins/plugins/virtualbox/files/rwimg.vdi.gz create mode 100644 os-plugins/plugins/xen/files/xen.examples/README create mode 100644 os-plugins/plugins/xen/files/xen.examples/README.incompatibilities create mode 100644 os-plugins/plugins/xen/files/xen.examples/examples/xmexample.disks create mode 100644 os-plugins/plugins/xen/files/xen.examples/examples/xmexample.domUloader create mode 100644 os-plugins/plugins/xen/files/xen.examples/examples/xmexample.hvm create mode 100644 os-plugins/plugins/xen/files/xen.examples/examples/xmexample.hvm-stubdom create mode 100644 os-plugins/plugins/xen/files/xen.examples/examples/xmexample.pv-grub create mode 100644 os-plugins/plugins/xen/files/xen.examples/examples/xmexample1 create mode 100644 os-plugins/plugins/xen/files/xen.examples/examples/xmexample2 create mode 100644 os-plugins/plugins/xen/files/xen.examples/examples/xmexample3 create mode 120000 os-plugins/plugins/xen/files/xen.examples/images create mode 100755 os-plugins/plugins/xen/files/xen.examples/qemu-ifup create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/blktap create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/block create mode 100644 os-plugins/plugins/xen/files/xen.examples/scripts/block-common.sh create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/block-iscsi create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/block-nbd create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/block-npiv create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/block-npiv-common.sh create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/block-npiv-vport create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/domain-lock create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/external-device-migrate create mode 100644 os-plugins/plugins/xen/files/xen.examples/scripts/locking.sh create mode 100644 os-plugins/plugins/xen/files/xen.examples/scripts/logging.sh create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/network-bridge create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/network-nat create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/network-route create mode 120000 os-plugins/plugins/xen/files/xen.examples/scripts/set-lock create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/vif-bridge create mode 100644 os-plugins/plugins/xen/files/xen.examples/scripts/vif-common.sh create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/vif-nat create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/vif-route create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/vm-monitor create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/vscsi create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/vtpm create mode 100644 os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-common.sh create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-delete create mode 100644 os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-hotplug-common.sh create mode 100644 os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-impl create mode 100644 os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-migration.sh create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/xen-hotplug-cleanup create mode 100644 os-plugins/plugins/xen/files/xen.examples/scripts/xen-hotplug-common.sh create mode 100644 os-plugins/plugins/xen/files/xen.examples/scripts/xen-network-common.sh create mode 100644 os-plugins/plugins/xen/files/xen.examples/scripts/xen-script-common.sh create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/xend-relocation.sh create mode 100755 os-plugins/plugins/xen/files/xen.examples/scripts/xmclone.sh create mode 100644 os-plugins/plugins/xen/files/xen.examples/xenapiusers create mode 100644 os-plugins/plugins/xen/files/xen.examples/xend-config-xenapi.sxp create mode 100644 os-plugins/plugins/xen/files/xen.examples/xend-config.sxp create mode 100644 os-plugins/plugins/xen/files/xen.examples/xend-pci-permissive.sxp create mode 100644 os-plugins/plugins/xen/files/xen.examples/xend-pci-quirks.sxp create mode 100644 os-plugins/plugins/xen/files/xen.examples/xm-config-xenapi.xml create mode 100644 os-plugins/plugins/xen/files/xen.examples/xm-config.xml (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm index 26a2d926..be7f2cb5 100644 --- a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm +++ b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm @@ -132,7 +132,7 @@ sub installationPhase my $pluginBasePath = "$self->{openslxBasePath}/lib/plugins/$pluginName/files"; foreach my $file ( qw( run-virt.include virtualbox.include machine.include - empty-diff*.vdi.gz ) ) { + empty-diff.vdi.gz rwimg.vdi.gz ) ) { copyFile("$pluginBasePath/$file", "$self->{pluginRepositoryPath}/"); chmod 0755, "$self->{pluginRepositoryPath}/$file"; } diff --git a/os-plugins/plugins/virtualbox/XX_virtualbox.sh b/os-plugins/plugins/virtualbox/XX_virtualbox.sh index 998dabd7..4599b197 100644 --- a/os-plugins/plugins/virtualbox/XX_virtualbox.sh +++ b/os-plugins/plugins/virtualbox/XX_virtualbox.sh @@ -18,7 +18,6 @@ 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 ${CONFFILE} ]; then @@ -46,14 +45,39 @@ if [ -e ${CONFFILE} ]; then # 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 + [ $DEBUGLEVEL -gt 1 ] && \ + error " * Incomplete information in variable ${virtualbox_imagesrc}." \ + nonfatal fi + # copy virtualization include files to config dir testmkd ${PLUGINCONFDIR} cp ${PLUGINDIR}/*.include ${PLUGINCONFDIR} # copy ${CONFFILE} to ${PLUGINCONFDIR} just in case cp ${CONFFILE} ${PLUGINCONFDIR} + +# # TODO: create rawdisk if requested +# # create raw disk +# for part in $(grep -qE " 44 | 45 " /etc/disk.partition); do +# case "${part}" in +# * 45 *) +# id4x=$(grep " 45 " /etc/disk.partition | grep -E " 44 | 45 " \ +# | awk '{print $1}' | cut -c -8) +# break +# ;; +# * 44 *) +# id4x=$(grep " 44 " /etc/disk.partition | grep -E " 44 | 45 " \ +# | awk '{print $1}' | cut -c -8) +# break +# ;; +# esac +# if [ -n "${id4x}" ]; then +# mount --bind /dev /mnt/dev +# chroot /mnt VBoxManage -q internalcommands createrawvmdk -filename \ +# ${OPENSLX_DEFAULT_CONFDIR}/plugins/virtualbox/raw.vmdk -rawdisk ${id4x} +# chmod 777 ${OPENSLX_DEFAULT_CONFDIR}/plugins/virtualbox/raw.vmdk +# umount -f /mnt/dev 2>/dev/null +# fi # copy and activate init file cp ${PLUGINDIR}/vbox-slx /mnt/etc/init.d/ diff --git a/os-plugins/plugins/virtualbox/files/machine.include b/os-plugins/plugins/virtualbox/files/machine.include index 6496b616..e11f95c5 100644 --- a/os-plugins/plugins/virtualbox/files/machine.include +++ b/os-plugins/plugins/virtualbox/files/machine.include @@ -22,7 +22,7 @@ cat < - + @@ -61,7 +61,7 @@ cat < - + diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index e3650ebd..11f8d0eb 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -32,21 +32,35 @@ fi PLUGINCONFVIRTUALBOX="${PLUGINCONFROOT}/${self}" # create TMPDIR for all users -mkdir -m 1777 /tmp/${self} 2>/dev/null +TMPDIR=/tmp/${self} +mkdir -m 1777 ${TMPDIR} 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} # define dirs and files which can be removed after exit, be carefull! -RMDIRS="${snapshotdir} ${confdir} /tmp/.vbox-${USER}-ipc" 2>/dev/null +RMDIRS="${snapshotdir} ${confdir} /tmp/.vbox-${USER}-ipc" rm -rf ${RMDIRS} 2>/dev/null -machfolder="${VBOX_USER_HOME}/Machines" +machfolder="${confdir}/Machines" # use vm_shortname for VM name since vm_name can be very long machconfig="${machfolder}/${vm_shortname}/${vm_shortname}.xml" -diskfolder="${VBOX_USER_HOME}/HardDisks" +diskfolder="${confdir}/HardDisks" snapshotdir=${machfolder}/${vm_shortname}/Snapshots -diskfile="${diskfolder}/${imgname}" mkdir -p ${diskfolder} ${snapshotdir} 2>/dev/null + +# configure rwimg +if [ "${imgmode}" = "rwimg" ] && ! [ -e "${vmpath}" ]; then + # what is our rwimg called? + imgname="${imgname}.vdi" + vmpath=${imgpath}/${imgname} + cat ${OPENSLX_DEFAULT_DIR}/plugin-repo/${self}/rwimg.vdi.gz \ + | gunzip > "${vmpath}" + # static rw share image uuid + #rwimguuid="ab20cb01-2d08-4d73-a33c-5594c5d0b8cb" +fi + +# link to image +diskfile="${diskfolder}/${imgname}" ln -sf ${vmpath} ${diskfile} # check the file type @@ -91,9 +105,9 @@ macaddr=$(echo ${macaddr} | sed 's/://g') machineuuid="00000000-0000-0000-0000-${macaddr}" # cosmetical, since UUID in lower case machineuuid=$(echo ${machineuuid} | tr [A-Z] [a-z]) -# get UUID of VBox image -diskuuid=$(VBoxManage -q showvdiinfo ${diskfile} | grep UUID | \ - awk '{print $2}') +# get UUID of VBox image, only if rwimg.vdi not used +diskuuid=$(VBoxManage -q showvdiinfo ${diskfile} | grep UUID \ + | awk '{print $2}') # snapshot UUID is static snapshotuuid="88bc8b6d-f248-468a-95fe-318084904f8b" @@ -188,6 +202,21 @@ cdrom1=${cdtest:-"FALSE"} ide="TRUE" hddrv="ide" +# translate boot, use if set else set to HardDisk +if [ -n "${boot}" ]; then + case ${boot} in + n*) # usually support for a,c,d,n, stands for Floppy, HD, CD-ROM, Network + boot="Network" + ;; + # later maybe c|disk|hd*|sd*) for HD and d|cd*) for CD-ROM + *) + boot="HardDisk" + ;; + esac +else + boot="HardDisk" +fi + writelog "\tSnapshots dir:\t\t$snapshotdir" writelog "Diskimage:" writelog "\tDisk type:\t\t$imgtype" @@ -203,13 +232,15 @@ writelog "\tGuest RAM:\t\t${mem} MB" writelog "\tMAC address:\t\t$macaddr" writelog "\tNetwork card:\t\t${vb_network_card}" writelog "\tNetwork kind:\t\t${network_kind}" +writelog "\tBooting from:\t\t${boot}" # TODO: server start activate via xml, etc... #writelog "\tGuest VRDP port:\t${vrdpport}" #writelog "\tCD-ROM1:\t${cdrom0}" #writelog "\tCD-ROM2:\t${cdrom1}" #writelog "\tFloppy_A:\t${floppy0}" #writelog "\tFloppy_B:\t${floppy1}" -writelog "\tShared Folders 'home':\t/home/${USER}" +# defined in run-virt.sh and run-vmgrid.sh +writelog "\tShared Folders '${sharename}':\t${sharepath}" ################################################################################ ### Pepare and configure virtual machine and disk image @@ -217,20 +248,33 @@ writelog "\tShared Folders 'home':\t/home/${USER}" # TODO: date wichtig? #date="$(date +%Y-%m-%dT%H:%M:%SZ)" -. ${PLUGINCONFVIRTUALBOX}/virtualbox.include >"${VBOX_USER_HOME}/VirtualBox.xml" +. ${PLUGINCONFVIRTUALBOX}/virtualbox.include > "${confdir}/VirtualBox.xml" + +# remove disk and add rwimg if set +if echo "${imgmode}" | grep -q rw; then + if [ -e "${vmpath}.lock" ]; then + writelog "This rw image is already in use: ${vmpath}, exiting!" + writelog "Remove lock if you are shure that this is not the case" + exit 1 + fi + # add lock + touch "${vmpath}.lock" + # remove lock after VM stopped + RMDIRS="${RMDIRS} ${vmpath}.lock" + rwimghd="" + sed -i "/,${rwimghd}," \ + "${confdir}/VirtualBox.xml" + # replace image uuid in machine config + snapshotuuid=${diskuuid} +fi + +# TODO: add rawdisk if requested +#"raw.vmdk" format="VMDK" type="Writethrough"/> # shortened date YYYY-MM-DD #date=${date%T*} -. ${PLUGINCONFVIRTUALBOX}/machine.include >"${machconfig}" - -# add rw share to vm, if existing -if [ -n "${rwshare}" ]; then - sharedf='" - sed -i "s,, ${sharedf}\n ," \ - "${machconfig}" - writelog "\tShared Folders 'share':\t${rwshare}" -fi +. ${PLUGINCONFVIRTUALBOX}/machine.include > "${machconfig}" # add ssh port if linux and NAT if [ "${vmostype}" = "Linux26" ] && [ "${network_kind}" = "NAT" ]; then @@ -247,7 +291,7 @@ if [ "${vmostype}" = "Linux26" ] && [ "${network_kind}" = "NAT" ]; then writelog "\tGuest SSH port:\t\t${vmsshport}" fi -cat ${OPENSLX_DEFAULT_DIR}/plugin-repo/virtualbox/empty-diff.vdi.gz | \ +cat ${OPENSLX_DEFAULT_DIR}/plugin-repo/${self}/empty-diff.vdi.gz | \ gunzip > "${snapshotdir}/{${snapshotuuid}}.vdi" ################################################################################ diff --git a/os-plugins/plugins/virtualbox/files/rwimg.vdi.gz b/os-plugins/plugins/virtualbox/files/rwimg.vdi.gz new file mode 100644 index 00000000..e2133d6d Binary files /dev/null and b/os-plugins/plugins/virtualbox/files/rwimg.vdi.gz differ diff --git a/os-plugins/plugins/vmchooser/files/run-virt.sh b/os-plugins/plugins/vmchooser/files/run-virt.sh index 38dd5ac6..9bc31396 100644 --- a/os-plugins/plugins/vmchooser/files/run-virt.sh +++ b/os-plugins/plugins/vmchooser/files/run-virt.sh @@ -161,6 +161,10 @@ ide="TRUE" scsi="FALSE" hddrv="ide" +# add rw share +sharepath="${HOME}" +sharename="home" + # Display resolution within the host system hostres=$(xvidtune -show 2>/dev/null| grep -ve "^$") xres=$(echo "${hostres}" | awk '{print $3}') diff --git a/os-plugins/plugins/vmgrid/XX_vmgrid.sh b/os-plugins/plugins/vmgrid/XX_vmgrid.sh index bdbd4836..39b8501a 100644 --- a/os-plugins/plugins/vmgrid/XX_vmgrid.sh +++ b/os-plugins/plugins/vmgrid/XX_vmgrid.sh @@ -18,9 +18,6 @@ # include functions . /etc/functions -# hostname? -host_name=${host_name:=$clientip} - CONFFILE="/initramfs/plugin-conf/vmgrid.conf" PLUGINCONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/vmgrid VIRTUALIZATIONPLUGIN=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/virtualization @@ -30,7 +27,6 @@ RWSHAREMNT=/mnt/var/opt/openslx/mnt/vmgrid BINDIR=/mnt/${OPENSLX_DEFAULT_BINDIR} PLUGINDIR=${OPENSLX_DEFAULT_DIR}/plugin-repo/vmgrid VIRTDIR=/mnt/${OPENSLX_DEFAULT_VIRTDIR}/vmgrid -LOGDIR=/mnt/${OPENSLX_DEFAULT_LOGDIR} if [ -f $CONFFILE ]; then @@ -67,15 +63,16 @@ if [ -f $CONFFILE ]; then fi # create rw share - testmkd ${RWSHARE} + testmkd 1777 ${RWSHARE}/rwdir # bind mount id 45 to ${RWSHARE} if strinstr "id45" "${vmgrid_rwshare}" ; then id45part=$(grep " 45 " /etc/disk.partition | awk '{print $1}' | \ cut -f 3,3 -d /) if [ -n "${id45part}" ]; then - testmkd /mnt/media/${id45part}/vmgrid - mount --bind -n /mnt/media/${id45part}/vmgrid ${RWSHARE} \ - >>${LOGDIR}/vmgrid.log 2>&1 + # use rwdir because we want to use rwimg.vdi as well + testmkd /mnt/media/${id45part}/vmgrid/rwdir + mount --bind -n /mnt/media/${id45part}/vmgrid/rwdir ${RWSHARE}/rwdir \ + >>/tmp/vmgrid.log 2>&1 fi # mount nfs rw share elif strinstr "nfs://" "${vmgrid_rwshare}" ; then @@ -89,16 +86,22 @@ if [ -f $CONFFILE ]; then rwtarget=${RWSHAREMNT} # mount the vmgrid source rw fsmount ${rwshareprot} ${rwshareserv} ${rwsharepath} ${rwtarget} rw - testmkd ${RWSHAREMNT}/${host_name} - mount --bind ${RWSHAREMNT}/${host_name} ${RWSHARE} \ - >>${LOGDIR}/vmgrid.log 2>&1 + # hostname? + host_name=${host_name:=$clientip} + # use rwdir because we want to use rwimg.vdi as well + testmkd ${RWSHAREMNT}/${host_name}/rwdir + mount --bind ${RWSHAREMNT}/${host_name}/rwdir ${RWSHARE}/rwdir \ + >>/tmp/vmgrid.log 2>&1 fi else - testmkd /mnt/tmp/vmgrid - mount --bind -n /mnt/tmp/vmgrid ${RWSHARE} >>${LOGDIR}/vmgrid.log 2>&1 + # use rwdir because we want to use rwimg.vdi as well + testmkd 1777 /mnt/tmp/vmgrid/rwdir + mount --bind -n /mnt/tmp/vmgrid/rwdir ${RWSHARE}/rwdir \ + >>/tmp/vmgrid.log 2>&1 fi # chmod so that everybody can write - chmod 1777 ${RWSHARE} + chmod -R 1777 ${RWSHARE} + echo "vmgrid_rwdir=${RWSHARE#/mnt}" >> ${PLUGINCONFDIR}/vmgrid.conf # TODO: virtual virtualization plugin diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index ce707830..ac1dd8fd 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -130,8 +130,8 @@ EOL writelog "Starting configuration..." writelog "\tVM-ID:\t\t\t${VM_ID}" writelog "\tLogfile:\t\t${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log" -writelog "\t$(df -h | grep " /tmp$" | awk '{print $2}') \c" -writelog "\t/tmp info:\t\t$(grep "/tmp " /proc/mounts) $(df -h | \ +writelog "\t/tmp info:\t\t$(df -h | grep " /tmp$" | awk '{print $2}') \c" +writelog " $(grep "/tmp " /proc/mounts) $(df -h | \ grep " /tmp$" | awk '{print $2}')" writelog "\tVM XML dir:\t\t${vmgrid_xmlpath}" writelog "\tVM Image dir:\t\t${vmgrid_imgpath}" @@ -148,7 +148,17 @@ writelog "VM config:" # name of the virt image or dir imgname=$(grep -io '/dev/null | grep '/' >/dev/null 2>&1; then + +# image mode +imgmode=$(grep -io '/dev/null | grep '/' >/dev/null 2>&1; then imgpath=$(dirname ${imgname}) imgname=$(basename ${imgname}) else @@ -157,8 +167,8 @@ fi # set default v path vmpath=${imgpath}/${imgname} -# check if virtual machine container file exists -if ! [ -e $vmpath ]; then +# check if virtual machine container file exists, only if not rwimg +if ! [ -e $vmpath ] && ! [ "${imgmode}" = "rwimg" ]; then writelog "\tVirtual machine image or directory ${vmpath} not found!" exit 1 fi @@ -236,6 +246,9 @@ network_kind=$(grep -io 'network param=.*"' ${xmlfile} | \ network_card=$(grep -io 'netcard param=.*"' ${xmlfile} | \ awk -F '"' '{ print $2 }') +# get boot attr +boot=$(grep -io 'boot param=.*"' ${xmlfile} | awk -F '"' '{ print $2 }') + writelog "\tVirtualization:\t\t$xmlvirt" writelog "\tVM name:\t\t$vm_name" writelog "\tVM short name:\t\t$vm_shortname" @@ -276,7 +289,8 @@ scsi="FALSE" hddrv="ide" # add rw share -rwshare="/var/opt/openslx/plugins/vmgrid/share" +sharepath="${vmgrid_rwdir}/rwdir" +sharename="share" # set hostname: using original hostname and adding string hostname="vmgrid${VM_ID}-$(hostname)" diff --git a/os-plugins/plugins/vmware/files/run-virt.include b/os-plugins/plugins/vmware/files/run-virt.include index e6866673..dfd07a89 100644 --- a/os-plugins/plugins/vmware/files/run-virt.include +++ b/os-plugins/plugins/vmware/files/run-virt.include @@ -140,8 +140,8 @@ usb.generic.autoconnect = \"TRUE\" sharedFolder0.present = \"TRUE\" sharedFolder0.enabled = \"${shared_folder}\" sharedFolder0.expiration = \"never\" -sharedFolder0.guestName = \"Home\" -sharedFolder0.hostPath = \"${HOME}\" +sharedFolder0.guestName = \"${sharename}\" +sharedFolder0.hostPath = \"${sharepath}\" sharedFolder0.readAccess = \"TRUE\" sharedFolder0.writeAccess = \"TRUE\" sharedFolder.maxNum = \"1\" diff --git a/os-plugins/plugins/xen/files/xen.examples/README b/os-plugins/plugins/xen/files/xen.examples/README new file mode 100644 index 00000000..e2e8f434 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/README @@ -0,0 +1,51 @@ +Xen Control Tools - Examples +=================================== + +This directory contains example scripts and configurations for Xen. +For many operations you will either be able to use these scripts directly, or +incorporate code from them into your own scripts. + +If you write a useful script and would like to share it, please do +send it (preferably with a little summary to go in this file) to + so we can add it to this directory. + +block - called by xen-backend.agent to bind/unbind dev +block-common.sh - sourced by block, block-* +block-enbd - binds/unbinds network block devices +block-nbd - binds/unbinds network block devices +external-device-migrate - called by xend for migrating external devices +locking.sh - locking functions to prevent concurrent access to + critical sections inside script files +logging.sh - logging function to log output using syslog +network-bridge - xen network start/stop script when using bridging +network-nat - xen network start/stop script when using NAT +network-route - xen network start/stop script when using routing +vif-bridge - virtual network start/stop script in bridged mode +vif-common.sh - sourced by vif-bridge +vif-nat - xen virtual network start/stop script in NAT mode +vif-route - xen virtual network start/stop script in routed mode +vtpm - called by xen-backend.agent to bind/unbind vTPM devices +vtpm-common.sh - common code for vTPM handling +vtpm-delete - remove an entry from the vTPM table given the + domain's name +vtpm-hotplug-common.sh - sourced by vtpm +vtpm-migration.sh - sourced by external-device-migrate +xen-backend.agent - calls block, vif-*, vtpm scripts to add, remove, hotplug + devices +xen-backend.rules - hotplug script rules +xend-config.sxp - default xend configuration file +xen-hotplug-common.sh - sourced by vif-common.sh +xen-network-common.sh - sourced by vif-common.sh +xen-script-common.sh - sourced by network-bridge, xen-hotplug-common.sh +xmexample1 - example configuration script for 'xm create' +xmexample2 - a more complex configuration script for 'xm create' +xmexample3 - an advanced configuration script for 'xm create' + that utilizes the vmid +xmexample.nbd - configuration script that uses NBD filesystems +xmexample.hvm - a configuration script for creating a hvm domain with + 'xm create' +xmexample.hvm-stubdom - a configuration script for creating a hvm domain with + 'xm create' that utilizes a stubdomain for device model +xmexample.pv-grub - a configuration script for creating a domain with 'xm create' + which boots PV-GRUB. +xmexample.vti - a configuration script for creating a domain on vti diff --git a/os-plugins/plugins/xen/files/xen.examples/README.incompatibilities b/os-plugins/plugins/xen/files/xen.examples/README.incompatibilities new file mode 100644 index 00000000..bb067bd4 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/README.incompatibilities @@ -0,0 +1,38 @@ +Command Incompatibilities +========================= + +Known incompatibilities with various commands on various distributions, and +the workarounds we use. + + +brctl +----- + +brctl show fails on SLES9 SP2. Workaround is to use brctl show +without arguments, and grep, though this would be difficult were you to need +to check for a specific bridge-interface pair, since brctl does not show the +bridge name on every line. + + +ifup / ifdown +------------- + +SuSE requires an extra parameter to ifup, which is created by calling getcfg +appropriately. See xen-network-common.sh for details. + +Gentoo doesn't have ifup/ifdown; appropriate alternatives are defined in +xen-network-common.sh. + + +ip +-- + +Newer ip commands (from iproute2) do not accept the abbreviated syntax "ip r a +..." etc. "ip route add ..." must be used instead. + + +sed +--- + +\s is not supported in regexps on Debian etch (sed 4.1.2), Ubuntu 4.10. We +hand-craft character classes instead. diff --git a/os-plugins/plugins/xen/files/xen.examples/examples/xmexample.disks b/os-plugins/plugins/xen/files/xen.examples/examples/xmexample.disks new file mode 100644 index 00000000..7743fc30 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/examples/xmexample.disks @@ -0,0 +1,32 @@ +# A VM's disks can be stored in a variety of ways. +# Here are some examples: +disk = [ + # Block device + 'phy:/dev/hdb,xvda,w', + # Raw format, accessed via loopback + 'file:/var/lib/xen/images/disk-example/disk0,xvdb,w', + # Raw format, accessed via blocktap + 'tap:aio:/var/lib/xen/images/disk-example/disk0,xvdc,w', + # QCOW format, accessed via blocktap + 'tap:qcow:/var/lib/xen/images/disk-example/disk0.qcow,xvdd,w', + # NBD (network block device): IP and port are separated by space + 'nbd:192.168.0.1 20004,xvde,w', + # iSCSI: The usual colon is replaced with '@' + 'iscsi:iqn.2006-09.de.suse@0ac47ee2-216e-452a-a341-a12624cd0225,xvdf,w', + # Fibre Channel N_Port ID Virtualization + 'npiv:210400e08b80c40f,xvdg,w' ] + + +# Remaining settings for the example VM: +name="disk-example" +memory=512 +vcpus=1 +on_crash="destroy" +on_poweroff="destroy" +on_reboot="restart" +localtime=0 +builder="linux" +bootloader="/usr/lib/xen/boot/domUloader.py" +bootargs="--entry=xvda2:/boot/vmlinuz-xen,/boot/initrd-xen" +vif=[ 'mac=00:16:3e:00:01:02,bridge=xenbr0' ] +vfb=['type=vnc,vncunused=1'] diff --git a/os-plugins/plugins/xen/files/xen.examples/examples/xmexample.domUloader b/os-plugins/plugins/xen/files/xen.examples/examples/xmexample.domUloader new file mode 100644 index 00000000..6edfdbc2 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/examples/xmexample.domUloader @@ -0,0 +1,28 @@ +# This is a bootloader used to boot paravirtualized domains. You can optionally +# plug in a different boot loader here, e.g., pygrub. There is usually no +# reason to change this. Don't explicitly specify kernel and ramdisk if you use +# a bootloader. +bootloader="/usr/lib/xen/boot/domUloader.py" + +# The domUloader will pull the specified kernel and initrd out of the domU's +# disk, and use that to boot. This is easier to manage, compared to manually +# keeping a copy of the kernel and initrd in sync in dom0's filesystem and +# pointing to them with the "kernel" and "ramdisk" parameters. Syntax is +# "VDEV:KERNEL,INITRD", where VDEV is the block device (from domU's point of +# view) within which KERNEL and INITRD can be found. +bootentry = "hda1:/boot/vmlinuz-xen,/boot/initrd-xen" + + +# Remaining settings for the example VM: +name="domUloader-example" +memory=512 +vcpus=1 +on_crash="destroy" +on_poweroff="destroy" +on_reboot="restart" +localtime=0 +builder="linux" +bootargs="--entry=xvda2:/boot/vmlinuz-xen,/boot/initrd-xen" +disk=[ 'file:/var/lib/xen/images/domUloader-example/disk0,xvda,w' ] +vif=[ 'mac=00:16:3e:00:01:02,bridge=xenbr0' ] +vfb=['type=vnc,vncunused=1'] diff --git a/os-plugins/plugins/xen/files/xen.examples/examples/xmexample.hvm b/os-plugins/plugins/xen/files/xen.examples/examples/xmexample.hvm new file mode 100644 index 00000000..d0686f5d --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/examples/xmexample.hvm @@ -0,0 +1,358 @@ +# -*- mode: python; -*- +#============================================================================ +# Python configuration setup for 'xm create'. +# This script sets the parameters used when a domain is created using 'xm create'. +# You use a separate script for each domain you want to create, or +# you can set the parameters for the domain on the xm command line. +#============================================================================ + +import os, re + +arch_libdir = 'lib' +arch = os.uname()[4] +if os.uname()[0] == 'Linux' and re.search('64', arch): + arch_libdir = 'lib64' + +#---------------------------------------------------------------------------- +# Kernel image file. +kernel = "/usr/lib/xen/boot/hvmloader" + +# The domain build function. HVM domain uses 'hvm'. +builder='hvm' + +# Initial memory allocation (in megabytes) for the new domain. +# +# WARNING: Creating a domain with insufficient memory may cause out of +# memory errors. The domain needs enough memory to boot kernel +# and modules. Allocating less than 32MBs is not recommended. +memory = 128 + +# Shadow pagetable memory for the domain, in MB. +# If not explicictly set, xend will pick an appropriate value. +# Should be at least 2KB per MB of domain memory, plus a few MB per vcpu. +# shadow_memory = 8 + +# A name for your domain. All domains must have different names. +name = "ExampleHVMDomain" + +# 128-bit UUID for the domain. The default behavior is to generate a new UUID +# on each call to 'xm create'. +#uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9" + +#----------------------------------------------------------------------------- +# The number of cpus guest platform has, default=1 +#vcpus=1 + +# Enable/disable HVM guest PAE, default=1 (enabled) +#pae=1 + +# Enable/disable HVM guest ACPI, default=1 (enabled) +#acpi=1 + +# Enable/disable HVM APIC mode, default=1 (enabled) +# Note that this option is ignored if vcpus > 1 +#apic=1 + +# Enable/disable extended power management support within HVM guest, i.e., beyond +# S3, S4, S5 within guest like exposing battery meter. +# 0 (default option, extended power management support disabled) +# 1 (pass-through mode; uses pass-through as needed; efficient but limited in scope) +# 2 (non pass-through mode; extended scope, likely to work on all applicable environment +# but comparitively less efficient than pass-through mode) +# xen_extended_power_mgmt=0 + +# List of which CPUS this domain is allowed to use, default Xen picks +#cpus = "" # leave to Xen to pick +#cpus = "0" # all vcpus run on CPU0 +#cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5 +#cpus = ["2", "3"] # VCPU0 runs on CPU2, VCPU1 runs on CPU3 + +# Optionally define mac and/or bridge for the network interfaces. +# Random MACs are assigned if not given. +#vif = [ 'type=ioemu, mac=00:16:3e:00:00:11, bridge=xenbr0, model=ne2k_pci' ] +# type=ioemu specify the NIC is an ioemu device not netfront +vif = [ 'type=ioemu, bridge=xenbr0' ] + +#---------------------------------------------------------------------------- +# Define the disk devices you want the domain to have access to, and +# what you want them accessible as. +# Each disk entry is of the form phy:UNAME,DEV,MODE +# where UNAME is the device, DEV is the device name the domain will see, +# and MODE is r for read-only, w for read-write. + +#disk = [ 'phy:hda1,hda1,r' ] +disk = [ 'file:/var/lib/xen/images/disk.img,ioemu:hda,w', ',hdc:cdrom,r' ] + +#---------------------------------------------------------------------------- +# Configure the behaviour when a domain exits. There are three 'reasons' +# for a domain to stop: poweroff, reboot, and crash. For each of these you +# may specify: +# +# "destroy", meaning that the domain is cleaned up as normal; +# "restart", meaning that a new domain is started in place of the old +# one; +# "preserve", meaning that no clean-up is done until the domain is +# manually destroyed (using xm destroy, for example); or +# "rename-restart", meaning that the old domain is not cleaned up, but is +# renamed and a new domain started in its place. +# +# In the event a domain stops due to a crash, you have the additional options: +# +# "coredump-destroy", meaning dump the crashed domain's core and then destroy; +# "coredump-restart', meaning dump the crashed domain's core and the restart. +# +# The default is +# +# on_poweroff = 'destroy' +# on_reboot = 'restart' +# on_crash = 'restart' +# +# For backwards compatibility we also support the deprecated option restart +# +# restart = 'onreboot' means on_poweroff = 'destroy' +# on_reboot = 'restart' +# on_crash = 'destroy' +# +# restart = 'always' means on_poweroff = 'restart' +# on_reboot = 'restart' +# on_crash = 'restart' +# +# restart = 'never' means on_poweroff = 'destroy' +# on_reboot = 'destroy' +# on_crash = 'destroy' + +#on_poweroff = 'destroy' +#on_reboot = 'restart' +#on_crash = 'restart' + +#============================================================================ + +# Device Model to be used +device_model = '/usr/' + arch_libdir + '/xen/bin/qemu-dm' + +#----------------------------------------------------------------------------- +# boot on floppy (a), hard disk (c), Network (n) or CD-ROM (d) +# default: hard disk, cd-rom, floppy +#boot="cda" + +#----------------------------------------------------------------------------- +# write to temporary files instead of disk image files +#snapshot=1 + +#---------------------------------------------------------------------------- +# enable SDL library for graphics, default = 0 +sdl=0 + +#---------------------------------------------------------------------------- +# enable OpenGL for texture rendering inside the SDL window, default = 1 +# valid only if sdl is enabled. +opengl=1 + +#---------------------------------------------------------------------------- +# enable VNC library for graphics, default = 1 +vnc=1 + +#---------------------------------------------------------------------------- +# address that should be listened on for the VNC server if vnc is set. +# default is to use 'vnc-listen' setting from /etc/xen/xend-config.sxp +#vnclisten="127.0.0.1" + +#---------------------------------------------------------------------------- +# set VNC display number, default = domid +#vncdisplay=1 + +#---------------------------------------------------------------------------- +# try to find an unused port for the VNC server, default = 1 +#vncunused=1 + +#---------------------------------------------------------------------------- +# set password for domain's VNC console +# default is depents on vncpasswd in xend-config.sxp +vncpasswd='' + +#---------------------------------------------------------------------------- +# no graphics, use serial port +#nographic=0 + +#---------------------------------------------------------------------------- +# enable stdvga, default = 0 (use cirrus logic device model) +stdvga=0 + +#----------------------------------------------------------------------------- +# serial port re-direct to pty deivce, /dev/pts/n +# then xm console or minicom can connect +serial='pty' + + +#----------------------------------------------------------------------------- +# Qemu Monitor, default is disable +# Use ctrl-alt-2 to connect +#monitor=1 + + +#----------------------------------------------------------------------------- +# enable sound card support, [sb16|es1370|all|..,..], default none +#soundhw='sb16' + + +#----------------------------------------------------------------------------- +# set the real time clock to local time [default=0 i.e. set to utc] +#localtime=1 + + +#----------------------------------------------------------------------------- +# set the real time clock offset in seconds [default=0 i.e. same as dom0] +#rtc_timeoffset=3600 + +#----------------------------------------------------------------------------- +# start in full screen +#full-screen=1 + + +#----------------------------------------------------------------------------- +# Enable USB support (specific devices specified at runtime through the +# monitor window) +#usb=1 + +# Enable USB mouse support (only enable one of the following, `mouse' for +# PS/2 protocol relative mouse, `tablet' for +# absolute mouse) +#usbdevice='mouse' +#usbdevice='tablet' + +#----------------------------------------------------------------------------- +# Set keyboard layout, default is en-us keyboard. +#keymap='ja' + +#----------------------------------------------------------------------------- +# Enable/disable xen platform PCI device, default=1 (enabled) +#xen_platform_pci=1 + +#----------------------------------------------------------------------------- +# Configure guest CPUID responses: +# +#cpuid=[ '1:ecx=xxxxxxxxxxx00xxxxxxxxxxxxxxxxxxx, +# eax=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ] +# - Unset the SSE4 features (CPUID.1[ECX][20-19]) +# - Default behaviour for all other bits in ECX And EAX registers. +# +# Each successive character represent a lesser-significant bit: +# '1' -> force the corresponding bit to 1 +# '0' -> force to 0 +# 'x' -> Get a safe value (pass through and mask with the default policy) +# 'k' -> pass through the host bit value +# 's' -> as 'k' but preserve across save/restore and migration +# +# Expose to the guest multi-core cpu instead of multiple processors +# Example for intel, expose a 8-core processor : +#cpuid=['1:edx=xxx1xxxxxxxxxxxxxxxxxxxxxxxxxxxx, +# ebx=xxxxxxxx00010000xxxxxxxxxxxxxxxx', +# '4,0:eax=001111xxxxxxxxxxxxxxxxxxxxxxxxxx'] +# - CPUID.1[EDX][HT] : Enable HT +# - CPUID.1[EBX] : Number of vcpus * 2 +# - CPUID.4,0[EAX] : Number of vcpus * 2 - 1 +#vcpus=8 +# +# Example for amd, expose a 5-core processor : +# cpuid = ['1:ebx=xxxxxxxx00001010xxxxxxxxxxxxxxxx, +# edx=xxx1xxxxxxxxxxxxxxxxxxxxxxxxxxxx', +# '0x80000001:ecx=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1x', +# '0x80000008:ecx=xxxxxxxxxxxxxxxxxxxxxxxxxx001001'] +# - CPUID.1[EBX] : Threads per Core * Cores per Socket (2 * #vcpus) +# - CPUID.1[EDX][HT] : Enable HT +# - CPUID.0x80000001[CmpLegacy] : Use legacy method +# - CPUID.0x80000008[ECX] : #vcpus * 2 - 1 +#vcpus=5 +# +# Downgrade the cpuid to make a better compatibility for migration : +# Look like a generic 686 : +# cpuid = [ '0:eax=0x3,ebx=0x0,ecx=0x0,edx=0x0', +# '1:eax=0x06b1, +# ecx=xxxxxxxxxxx0000xx00xxx0000000xx0, +# edx=xxx00000xxxxxxx0xxxxxxxxx0xxxxxx', +# '4:eax=0x3,ebx=0x0,ecx=0x0,edx=0x0', +# '0x80000000:eax=0x3,ebx=0x0,ecx=0x0,edx=0x0'] +# with the highest leaf +# - CPUID.0[EAX] : Set the highest leaf +# - CPUID.1[EAX] : 686 +# - CPUID.1[ECX] : Mask some features +# - CPUID.1[EDX] : Mask some features +# - CPUID.4 : Reply like the highest leaf, in our case CPUID.3 +# - CPUID.0x80000000 : No extension we are on a Pentium III, reply like the +# highest leaf (CPUID.3). +# +# Configure host CPUID consistency checks, which must be satisfied for this +# VM to be allowed to run on this host's processor type: +#cpuid_check=[ '1:ecx=xxxxxxxxxxxxxxxxxxxxxxxxxx1xxxxx' ] +# - Host must have VMX feature flag set +# +# The format is similar to the above for 'cpuid': +# '1' -> the bit must be '1' +# '0' -> the bit must be '0' +# 'x' -> we don't care (do not check) +# 's' -> the bit must be the same as on the host that started this VM + +#----------------------------------------------------------------------------- +# Configure passthrough PCI{,-X,e} devices: +# +# pci=[ '[SSSS:]BB:DD.F[,option1[,option2[...]]]', ... ] +# +# [SSSS]:BB:DD.F "bus segment:bus:device.function"(1) of the device to +# be assigned, bus segment is optional. All fields are +# in hexadecimal and no field should be longer than that +# as shown in the pattern. Successful assignment may need +# certain hardware support and additional configurations +# (e.g. VT-d, see docs/misc/vtd.txt for more details). +# +# (1) bus segment is sometimes also referred to as the PCI "domain", +# not to be confused with Xen domain. +# +# +# optionN per-device options in "key=val" format. Current +# available options are: +# - msitranslate=0|1 +# per-device overriden of pci_msitranslate, see below +# - power_mgmt=0|1 +# per-device overriden of pci_power_mgmt, see below +# +#pci=[ '07:00.0', '07:00.1' ] + +# MSI-INTx translation for MSI capable devices: +# +# If it's set, Xen will enable MSI for the device that supports it even +# if the guest don't use MSI. In the case, an IO-APIC type interrupt will +# be injected to the guest every time a corresponding MSI message is +# received. +# If the guest enables MSI or MSI-X, the translation is automatically +# turned off. +# +#pci_msitranslate=1 + +# PCI Power Management: +# +# If it's set, the guest OS will be able to program D0-D3hot states of the +# PCI device for the purpose of low power consumption. +# +#pci_power_mgmt=0 + +#----------------------------------------------------------------------------- +# Configure PVSCSI devices: +# +#vscsi=[ 'PDEV, VDEV' ] +# +# PDEV gives physical SCSI device to be attached to specified guest +# domain by one of the following identifier format. +# - XX:XX:XX:XX (4-tuples with decimal notation which shows +# "host:channel:target:lun") +# - /dev/sdxx or sdx +# - /dev/stxx or stx +# - /dev/sgxx or sgx +# - result of 'scsi_id -gu -s'. +# ex. # scsi_id -gu -s /block/sdb +# 36000b5d0006a0000006a0257004c0000 +# +# VDEV gives virtual SCSI device by 4-tuples (XX:XX:XX:XX) as +# which the specified guest domain recognize. +# + +#vscsi = [ '/dev/sdx, 0:0:0:0' ] diff --git a/os-plugins/plugins/xen/files/xen.examples/examples/xmexample.hvm-stubdom b/os-plugins/plugins/xen/files/xen.examples/examples/xmexample.hvm-stubdom new file mode 100644 index 00000000..acc250eb --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/examples/xmexample.hvm-stubdom @@ -0,0 +1,314 @@ +# -*- mode: python; -*- +#============================================================================ +# Python configuration setup for 'xm create'. +# This script sets the parameters used when a domain is created using 'xm create'. +# You use a separate script for each domain you want to create, or +# you can set the parameters for the domain on the xm command line. +#============================================================================ +# +# This is a version using a stubdomain for device model +# The differences with xmexample.hvm are marked with "STUBDOM" + +#---------------------------------------------------------------------------- +# Kernel image file. +kernel = "/usr/lib/xen/boot/hvmloader" + +# The domain build function. HVM domain uses 'hvm'. +builder='hvm' + +# Initial memory allocation (in megabytes) for the new domain. +# +# WARNING: Creating a domain with insufficient memory may cause out of +# memory errors. The domain needs enough memory to boot kernel +# and modules. Allocating less than 32MBs is not recommended. +memory = 128 + +# Shadow pagetable memory for the domain, in MB. +# If not explicictly set, xend will pick an appropriate value. +# Should be at least 2KB per MB of domain memory, plus a few MB per vcpu. +# shadow_memory = 8 + +# A name for your domain. All domains must have different names. +name = "xmexample.hvm" + +# 128-bit UUID for the domain. The default behavior is to generate a new UUID +# on each call to 'xm create'. +#uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9" + +#----------------------------------------------------------------------------- +# The number of cpus guest platform has, default=1 +#vcpus=1 + +# Enable/disable HVM guest PAE, default=1 (enabled) +#pae=1 + +# Enable/disable HVM guest ACPI, default=1 (enabled) +#acpi=1 + +# Enable/disable HVM APIC mode, default=1 (enabled) +# Note that this option is ignored if vcpus > 1 +#apic=1 + +# List of which CPUS this domain is allowed to use, default Xen picks +#cpus = "" # leave to Xen to pick +#cpus = "0" # all vcpus run on CPU0 +#cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5 +#cpus = ["2", "3"] # VCPU0 runs on CPU2, VCPU1 runs on CPU3 + +# Optionally define mac and/or bridge for the network interfaces. +# Random MACs are assigned if not given. +#vif = [ 'type=ioemu, mac=00:16:3e:00:00:11, bridge=xenbr0, model=ne2k_pci' ] +# type=ioemu specify the NIC is an ioemu device not netfront +vif = [ 'type=ioemu, bridge=xenbr0' ] + +#---------------------------------------------------------------------------- +# Define the disk devices you want the domain to have access to, and +# what you want them accessible as. +# Each disk entry is of the form phy:UNAME,DEV,MODE +# where UNAME is the device, DEV is the device name the domain will see, +# and MODE is r for read-only, w for read-write. + +disk = [ 'file:/var/images/min-el3-i386.img,hda,w', 'phy:/dev/cdrom,hdc:cdrom,r' ] + +#---------------------------------------------------------------------------- +# Configure the behaviour when a domain exits. There are three 'reasons' +# for a domain to stop: poweroff, reboot, and crash. For each of these you +# may specify: +# +# "destroy", meaning that the domain is cleaned up as normal; +# "restart", meaning that a new domain is started in place of the old +# one; +# "preserve", meaning that no clean-up is done until the domain is +# manually destroyed (using xm destroy, for example); or +# "rename-restart", meaning that the old domain is not cleaned up, but is +# renamed and a new domain started in its place. +# +# In the event a domain stops due to a crash, you have the additional options: +# +# "coredump-destroy", meaning dump the crashed domain's core and then destroy; +# "coredump-restart', meaning dump the crashed domain's core and the restart. +# +# The default is +# +# on_poweroff = 'destroy' +# on_reboot = 'restart' +# on_crash = 'restart' +# +# For backwards compatibility we also support the deprecated option restart +# +# restart = 'onreboot' means on_poweroff = 'destroy' +# on_reboot = 'restart' +# on_crash = 'destroy' +# +# restart = 'always' means on_poweroff = 'restart' +# on_reboot = 'restart' +# on_crash = 'restart' +# +# restart = 'never' means on_poweroff = 'destroy' +# on_reboot = 'destroy' +# on_crash = 'destroy' + +#on_poweroff = 'destroy' +#on_reboot = 'restart' +#on_crash = 'restart' + +#============================================================================ + +# Device Model to be used +# +# STUBDOM: this is a script that creates the stub domain running the device +# model +device_model = '/usr/lib/xen/bin/stubdom-dm' + +#----------------------------------------------------------------------------- +# boot on floppy (a), hard disk (c), Network (n) or CD-ROM (d) +# default: hard disk, cd-rom, floppy +boot="cda" + +#----------------------------------------------------------------------------- +# write to temporary files instead of disk image files +#snapshot=1 + +#---------------------------------------------------------------------------- +# enable SDL library for graphics, default = 0 +# +sdl=0 + +#---------------------------------------------------------------------------- +# enable OpenGL for texture rendering inside the SDL window, default = 1 +# valid only if sdl is enabled. +# +opengl=1 + +#---------------------------------------------------------------------------- +# enable VNC library for graphics, default = 1 +vnc=1 + +#---------------------------------------------------------------------------- +# address that should be listened on for the VNC server if vnc is set. +# default is to use 'vnc-listen' setting from /etc/xen/xend-config.sxp +#vnclisten="127.0.0.1" + +#---------------------------------------------------------------------------- +# set VNC display number, default = domid +#vncdisplay=1 + +#---------------------------------------------------------------------------- +# try to find an unused port for the VNC server, default = 1 +#vncunused=1 + +#---------------------------------------------------------------------------- +# enable spawning vncviewer for domain's console +# (only valid when vnc=1), default = 0 +#vncconsole=0 + +#---------------------------------------------------------------------------- +# set password for domain's VNC console +# default is depents on vncpasswd in xend-config.sxp +vncpasswd='' + +#---------------------------------------------------------------------------- +# no graphics, use serial port +#nographic=0 + +#---------------------------------------------------------------------------- +# enable stdvga, default = 0 (use cirrus logic device model) +stdvga=0 + +#----------------------------------------------------------------------------- +# serial port re-direct to pty deivce, /dev/pts/n +# then xm console or minicom can connect +# +# STUBDOM: always disable as the stub domain doesn't have access to dom0's +# ptys +#serial='pty' + + +#----------------------------------------------------------------------------- +# Qemu Monitor, default is disable +# Use ctrl-alt-2 to connect +#monitor=1 + + +#----------------------------------------------------------------------------- +# enable sound card support, [sb16|es1370|all|..,..], default none +# +# STUBDOM: not supported +#soundhw='sb16' + + +#----------------------------------------------------------------------------- +# set the real time clock to local time [default=0 i.e. set to utc] +#localtime=1 + + +#----------------------------------------------------------------------------- +# set the real time clock offset in seconds [default=0 i.e. same as dom0] +#rtc_timeoffset=3600 + +#----------------------------------------------------------------------------- +# start in full screen +#full-screen=1 + + +#----------------------------------------------------------------------------- +# Enable USB support (specific devices specified at runtime through the +# monitor window) +#usb=1 + +# Enable USB mouse support (only enable one of the following, `mouse' for +# PS/2 protocol relative mouse, `tablet' for +# absolute mouse) +#usbdevice='mouse' +#usbdevice='tablet' + +#----------------------------------------------------------------------------- +# Set keyboard layout, default is en-us keyboard. +#keymap='ja' + +#----------------------------------------------------------------------------- +# Configure guest CPUID responses: +# +#cpuid=[ '1:ecx=xxxxxxxxxxx00xxxxxxxxxxxxxxxxxxx, +# eax=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' ] +# - Unset the SSE4 features (CPUID.1[ECX][20-19]) +# - Default behaviour for all other bits in ECX And EAX registers. +# +# Each successive character represent a lesser-significant bit: +# '1' -> force the corresponding bit to 1 +# '0' -> force to 0 +# 'x' -> Get a safe value (pass through and mask with the default policy) +# 'k' -> pass through the host bit value +# 's' -> as 'k' but preserve across save/restore and migration +# +# Expose to the guest multi-core cpu instead of multiple processors +# Example for intel, expose a 8-core processor : +#cpuid=['1:edx=xxx1xxxxxxxxxxxxxxxxxxxxxxxxxxxx, +# ebx=xxxxxxxx00010000xxxxxxxxxxxxxxxx', +# '4,0:eax=001111xxxxxxxxxxxxxxxxxxxxxxxxxx'] +# - CPUID.1[EDX][HT] : Enable HT +# - CPUID.1[EBX] : Number of vcpus * 2 +# - CPUID.4,0[EAX] : Number of vcpus * 2 - 1 +#vcpus=8 +# +# Example for amd, expose a 5-core processor : +# cpuid = ['1:ebx=xxxxxxxx00001010xxxxxxxxxxxxxxxx, +# edx=xxx1xxxxxxxxxxxxxxxxxxxxxxxxxxxx', +# '0x80000001:ecx=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx1x', +# '0x80000008:ecx=xxxxxxxxxxxxxxxxxxxxxxxxxx001001'] +# - CPUID.1[EBX] : Threads per Core * Cores per Socket (2 * #vcpus) +# - CPUID.1[EDX][HT] : Enable HT +# - CPUID.0x80000001[CmpLegacy] : Use legacy method +# - CPUID.0x80000008[ECX] : #vcpus * 2 - 1 +#vcpus=5 +# +# Downgrade the cpuid to make a better compatibility for migration : +# Look like a generic 686 : +# cpuid = [ '0:eax=0x3,ebx=0x0,ecx=0x0,edx=0x0', +# '1:eax=0x06b1, +# ecx=xxxxxxxxxx0000xx00xxx0000000xx0, +# edx=xx00000xxxxxxx0xxxxxxxxx0xxxxxx', +# '4:eax=0x3,ebx=0x0,ecx=0x0,edx=0x0', +# '0x80000000:eax=0x3,ebx=0x0,ecx=0x0,edx=0x0'] +# with the highest leaf +# - CPUID.0[EAX] : Set the highest leaf +# - CPUID.1[EAX] : 686 +# - CPUID.1[ECX] : Mask some features +# - CPUID.1[EDX] : Mask some features +# - CPUID.4 : Reply like the highest leaf, in our case CPUID.3 +# - CPUID.0x80000000 : No extension we are on a Pentium III, reply like the +# highest leaf (CPUID.3). +# +# Configure host CPUID consistency checks, which must be satisfied for this +# VM to be allowed to run on this host's processor type: +#cpuid_check=[ '1:ecx=xxxxxxxxxxxxxxxxxxxxxxxxxx1xxxxx' ] +# - Host must have VMX feature flag set +# +# The format is similar to the above for 'cpuid': +# '1' -> the bit must be '1' +# '0' -> the bit must be '0' +# 'x' -> we don't care (do not check) +# 's' -> the bit must be the same as on the host that started this VM + + +#----------------------------------------------------------------------------- +# Configure PVSCSI devices: +# +#vscsi=[ 'PDEV, VDEV' ] +# +# PDEV gives physical SCSI device to be attached to specified guest +# domain by one of the following identifier format. +# - XX:XX:XX:XX (4-tuples with decimal notation which shows +# "host:channel:target:lun") +# - /dev/sdxx or sdx +# - /dev/stxx or stx +# - /dev/sgxx or sgx +# - result of 'scsi_id -gu -s'. +# ex. # scsi_id -gu -s /block/sdb +# 36000b5d0006a0000006a0257004c0000 +# +# VDEV gives virtual SCSI device by 4-tuples (XX:XX:XX:XX) as +# which the specified guest domain recognize. +# + +#vscsi = [ '/dev/sdx, 0:0:0:0' ] diff --git a/os-plugins/plugins/xen/files/xen.examples/examples/xmexample.pv-grub b/os-plugins/plugins/xen/files/xen.examples/examples/xmexample.pv-grub new file mode 100644 index 00000000..1b687151 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/examples/xmexample.pv-grub @@ -0,0 +1,186 @@ +# -*- mode: python; -*- +#============================================================================ +# Python configuration setup for 'xm create'. +# This script sets the parameters used when a domain is created using 'xm create'. +# You use a separate script for each domain you want to create, or +# you can set the parameters for the domain on the xm command line. +#============================================================================ + +#---------------------------------------------------------------------------- +# PV GRUB image file. +kernel = "/usr/lib/xen/boot/pv-grub.gz" + +# Optional provided menu.lst. +#ramdisk = "/boot/guests/menu.lst" + +# Sets path to menu.lst +extra = "(hd0,0)/boot/grub/menu.lst" +# can be a TFTP-served path (DHCP will automatically be run) +# extra = "(nd)/netboot/menu.lst" +# can be configured automatically by GRUB's DHCP option 150 (see grub manual) +# extra = "" + +# Initial memory allocation (in megabytes) for the new domain. +# +# WARNING: Creating a domain with insufficient memory may cause out of +# memory errors. The domain needs enough memory to boot kernel +# and modules. Allocating less than 32MBs is not recommended. +memory = 128 + +# A name for your domain. All domains must have different names. +name = "ExampleDomain" + +# 128-bit UUID for the domain. The default behavior is to generate a new UUID +# on each call to 'xm create'. +#uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9" + +# List of which CPUS this domain is allowed to use, default Xen picks +#cpus = "" # leave to Xen to pick +#cpus = "0" # all vcpus run on CPU0 +#cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5 +#cpus = ["2", "3"] # VCPU0 runs on CPU2, VCPU1 runs on CPU3 + +# Number of Virtual CPUS to use, default is 1 +#vcpus = 1 + +#---------------------------------------------------------------------------- +# Define network interfaces. + +# By default, no network interfaces are configured. You may have one created +# with sensible defaults using an empty vif clause: +# +# vif = [ '' ] +# +# or optionally override backend, bridge, ip, mac, script, type, or vifname: +# +# vif = [ 'mac=00:16:3e:00:00:11, bridge=xenbr0' ] +# +# or more than one interface may be configured: +# +# vif = [ '', 'bridge=xenbr1' ] + +vif = [ '' ] + +#---------------------------------------------------------------------------- +# Define the disk devices you want the domain to have access to, and +# what you want them accessible as. +# Each disk entry is of the form phy:UNAME,DEV,MODE +# where UNAME is the device, DEV is the device name the domain will see, +# and MODE is r for read-only, w for read-write. + +disk = [ 'phy:hda1,hda1,w' ] + +#---------------------------------------------------------------------------- +# Define frame buffer device. +# +# By default, no frame buffer device is configured. +# +# To create one using the SDL backend and sensible defaults: +# +# vfb = [ 'sdl=1' ] +# +# This uses environment variables XAUTHORITY and DISPLAY. You +# can override that: +# +# vfb = [ 'sdl=1,xauthority=/home/bozo/.Xauthority,display=:1' ] +# +# To create one using the VNC backend and sensible defaults: +# +# vfb = [ 'vnc=1' ] +# +# The backend listens on 127.0.0.1 port 5900+N by default, where N is +# the domain ID. You can override both address and N: +# +# vfb = [ 'vnc=1,vnclisten=127.0.0.1,vncdisplay=1' ] +# +# Or you can bind the first unused port above 5900: +# +# vfb = [ 'vnc=1,vnclisten=0.0.0.0,vncunused=1' ] +# +# You can override the password: +# +# vfb = [ 'vnc=1,vncpasswd=MYPASSWD' ] +# +# Empty password disables authentication. Defaults to the vncpasswd +# configured in xend-config.sxp. + +#---------------------------------------------------------------------------- +# Define to which TPM instance the user domain should communicate. +# The vtpm entry is of the form 'instance=INSTANCE,backend=DOM' +# where INSTANCE indicates the instance number of the TPM the VM +# should be talking to and DOM provides the domain where the backend +# is located. +# Note that no two virtual machines should try to connect to the same +# TPM instance. The handling of all TPM instances does require +# some management effort in so far that VM configration files (and thus +# a VM) should be associated with a TPM instance throughout the lifetime +# of the VM / VM configuration file. The instance number must be +# greater or equal to 1. +#vtpm = [ 'instance=1,backend=0' ] + +#---------------------------------------------------------------------------- +# Configure the behaviour when a domain exits. There are three 'reasons' +# for a domain to stop: poweroff, reboot, and crash. For each of these you +# may specify: +# +# "destroy", meaning that the domain is cleaned up as normal; +# "restart", meaning that a new domain is started in place of the old +# one; +# "preserve", meaning that no clean-up is done until the domain is +# manually destroyed (using xm destroy, for example); or +# "rename-restart", meaning that the old domain is not cleaned up, but is +# renamed and a new domain started in its place. +# +# In the event a domain stops due to a crash, you have the additional options: +# +# "coredump-destroy", meaning dump the crashed domain's core and then destroy; +# "coredump-restart', meaning dump the crashed domain's core and the restart. +# +# The default is +# +# on_poweroff = 'destroy' +# on_reboot = 'restart' +# on_crash = 'restart' +# +# For backwards compatibility we also support the deprecated option restart +# +# restart = 'onreboot' means on_poweroff = 'destroy' +# on_reboot = 'restart' +# on_crash = 'destroy' +# +# restart = 'always' means on_poweroff = 'restart' +# on_reboot = 'restart' +# on_crash = 'restart' +# +# restart = 'never' means on_poweroff = 'destroy' +# on_reboot = 'destroy' +# on_crash = 'destroy' + +#on_poweroff = 'destroy' +#on_reboot = 'restart' +#on_crash = 'restart' + +#----------------------------------------------------------------------------- +# Configure PVSCSI devices: +# +#vscsi=[ 'PDEV, VDEV' ] +# +# PDEV gives physical SCSI device to be attached to specified guest +# domain by one of the following identifier format. +# - XX:XX:XX:XX (4-tuples with decimal notation which shows +# "host:channel:target:lun") +# - /dev/sdxx or sdx +# - /dev/stxx or stx +# - /dev/sgxx or sgx +# - result of 'scsi_id -gu -s'. +# ex. # scsi_id -gu -s /block/sdb +# 36000b5d0006a0000006a0257004c0000 +# +# VDEV gives virtual SCSI device by 4-tuples (XX:XX:XX:XX) as +# which the specified guest domain recognize. +# + +#vscsi = [ '/dev/sdx, 0:0:0:0' ] + +#============================================================================ + diff --git a/os-plugins/plugins/xen/files/xen.examples/examples/xmexample1 b/os-plugins/plugins/xen/files/xen.examples/examples/xmexample1 new file mode 100644 index 00000000..08167bdb --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/examples/xmexample1 @@ -0,0 +1,213 @@ +# -*- mode: python; -*- +#============================================================================ +# Python configuration setup for 'xm create'. +# This script sets the parameters used when a domain is created using 'xm create'. +# You use a separate script for each domain you want to create, or +# you can set the parameters for the domain on the xm command line. +#============================================================================ + +#---------------------------------------------------------------------------- +# Kernel image file and (optional) ramdisk (initrd). +kernel = "/boot/vmlinuz-xen" +ramdisk = "/boot/initrd-xen" + +# Or use domUloader instead of kernel/ramdisk to get kernel from domU FS +#bootloader = "/usr/lib/xen/boot/domUloader.py" +#bootentry = "hda2:/vmlinuz-xen,/initrd-xen" + +# The domain build function. Default is 'linux'. +#builder='linux' + +# Initial memory allocation (in megabytes) for the new domain. +# +# WARNING: Creating a domain with insufficient memory may cause out of +# memory errors. The domain needs enough memory to boot kernel +# and modules. Allocating less than 32MBs is not recommended. +memory = 64 + +# A name for your domain. All domains must have different names. +name = "ExampleDomain" + +# 128-bit UUID for the domain. The default behavior is to generate a new UUID +# on each call to 'xm create'. +#uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9" + +# List of which CPUS this domain is allowed to use, default Xen picks +#cpus = "" # leave to Xen to pick +#cpus = "0" # all vcpus run on CPU0 +#cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5 +#cpus = ["2", "3"] # VCPU0 runs on CPU2, VCPU1 runs on CPU3 + +# Number of Virtual CPUS to use, default is 1 +#vcpus = 1 + +#---------------------------------------------------------------------------- +# Define network interfaces. + +# By default, no network interfaces are configured. You may have one created +# with sensible defaults using an empty vif clause: +# +# vif = [ '' ] +# +# or optionally override backend, bridge, ip, mac, script, type, or vifname: +# +# vif = [ 'mac=00:16:3e:00:00:11, bridge=xenbr0' ] +# +# or more than one interface may be configured: +# +# vif = [ '', 'bridge=xenbr1' ] + +vif = [ '' ] + +#---------------------------------------------------------------------------- +# Define the disk devices you want the domain to have access to, and +# what you want them accessible as. +# Each disk entry is of the form phy:UNAME,DEV,MODE +# where UNAME is the device, DEV is the device name the domain will see, +# and MODE is r for read-only, w for read-write. + +disk = [ 'phy:hda1,hda1,w' ] + +#---------------------------------------------------------------------------- +# Define frame buffer device. +# +# By default, no frame buffer device is configured. +# +# To create one using the SDL backend and sensible defaults: +# +# vfb = [ 'sdl=1' ] +# +# This uses environment variables XAUTHORITY and DISPLAY. You +# can override that: +# +# vfb = [ 'sdl=1,xauthority=/home/bozo/.Xauthority,display=:1' ] +# +# To create one using the VNC backend and sensible defaults: +# +# vfb = [ 'vnc=1' ] +# +# The backend listens on 127.0.0.1 port 5900+N by default, where N is +# the domain ID. You can override both address and N: +# +# vfb = [ 'vnc=1,vnclisten=127.0.0.1,vncdisplay=1' ] +# +# Or you can bind the first unused port above 5900: +# +# vfb = [ 'vnc=1,vnclisten=0.0.0.0,vncunused=1' ] +# +# You can override the password: +# +# vfb = [ 'vnc=1,vncpasswd=MYPASSWD' ] +# +# Empty password disables authentication. Defaults to the vncpasswd +# configured in xend-config.sxp. + +#---------------------------------------------------------------------------- +# Define to which TPM instance the user domain should communicate. +# The vtpm entry is of the form 'instance=INSTANCE,backend=DOM' +# where INSTANCE indicates the instance number of the TPM the VM +# should be talking to and DOM provides the domain where the backend +# is located. +# Note that no two virtual machines should try to connect to the same +# TPM instance. The handling of all TPM instances does require +# some management effort in so far that VM configration files (and thus +# a VM) should be associated with a TPM instance throughout the lifetime +# of the VM / VM configuration file. The instance number must be +# greater or equal to 1. +#vtpm = [ 'instance=1,backend=0' ] + +#---------------------------------------------------------------------------- +# Set the kernel command line for the new domain. +# You only need to define the IP parameters and hostname if the domain's +# IP config doesn't, e.g. in ifcfg-eth0 or via DHCP. +# You can use 'extra' to set the runlevel and custom environment +# variables used by custom rc scripts (e.g. VMID=, usr= ). + +# Set if you want dhcp to allocate the IP address. +#dhcp="dhcp" +# Set netmask. +#netmask= +# Set default gateway. +#gateway= +# Set the hostname. +#hostname= "vm%d" % vmid + +# Set root device. +root = "/dev/hda1" + +# Root device for nfs. +#root = "/dev/nfs" +# The nfs server. +#nfs_server = '192.0.2.1' +# Root directory on the nfs server. +#nfs_root = '/full/path/to/root/directory' + +# Extra arguments to pass to the kernel. +extra = "" + +#---------------------------------------------------------------------------- +# Configure the behaviour when a domain exits. There are three 'reasons' +# for a domain to stop: poweroff, reboot, and crash. For each of these you +# may specify: +# +# "destroy", meaning that the domain is cleaned up as normal; +# "restart", meaning that a new domain is started in place of the old +# one; +# "preserve", meaning that no clean-up is done until the domain is +# manually destroyed (using xm destroy, for example); or +# "rename-restart", meaning that the old domain is not cleaned up, but is +# renamed and a new domain started in its place. +# +# In the event a domain stops due to a crash, you have the additional options: +# +# "coredump-destroy", meaning dump the crashed domain's core and then destroy; +# "coredump-restart', meaning dump the crashed domain's core and the restart. +# +# The default is +# +# on_poweroff = 'destroy' +# on_reboot = 'restart' +# on_crash = 'restart' +# +# For backwards compatibility we also support the deprecated option restart +# +# restart = 'onreboot' means on_poweroff = 'destroy' +# on_reboot = 'restart' +# on_crash = 'destroy' +# +# restart = 'always' means on_poweroff = 'restart' +# on_reboot = 'restart' +# on_crash = 'restart' +# +# restart = 'never' means on_poweroff = 'destroy' +# on_reboot = 'destroy' +# on_crash = 'destroy' + +#on_poweroff = 'destroy' +#on_reboot = 'restart' +#on_crash = 'restart' + +#----------------------------------------------------------------------------- +# Configure PVSCSI devices: +# +#vscsi=[ 'PDEV, VDEV' ] +# +# PDEV gives physical SCSI device to be attached to specified guest +# domain by one of the following identifier format. +# - XX:XX:XX:XX (4-tuples with decimal notation which shows +# "host:channel:target:lun") +# - /dev/sdxx or sdx +# - /dev/stxx or stx +# - /dev/sgxx or sgx +# - result of 'scsi_id -gu -s'. +# ex. # scsi_id -gu -s /block/sdb +# 36000b5d0006a0000006a0257004c0000 +# +# VDEV gives virtual SCSI device by 4-tuples (XX:XX:XX:XX) as +# which the specified guest domain recognize. +# + +#vscsi = [ '/dev/sdx, 0:0:0:0' ] + +#============================================================================ + diff --git a/os-plugins/plugins/xen/files/xen.examples/examples/xmexample2 b/os-plugins/plugins/xen/files/xen.examples/examples/xmexample2 new file mode 100644 index 00000000..189687a8 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/examples/xmexample2 @@ -0,0 +1,248 @@ +# -*- mode: python; -*- +#============================================================================ +# Example Python setup script for 'xm create'. +# This script sets the parameters used when a domain is created using 'xm create'. +# +# This is a relatively advanced script that uses a parameter, vmid, to control +# the settings. So this script can be used to start a set of domains by +# setting the vmid parameter on the 'xm create' command line. For example: +# +# xm create vmid=1 +# xm create vmid=2 +# xm create vmid=3 +# +# The vmid is purely a script variable, and has no effect on the the domain +# id assigned to the new domain. +#============================================================================ + +# Define script variables here. +# xm_vars is defined automatically, use xm_vars.var() to define a variable. + +# This function checks that 'vmid' has been given a valid value. +# It is called automatically by 'xm create'. +def vmid_check(var, val): + val = int(val) + if val <= 0: + raise ValueError + return val + +# Define the 'vmid' variable so that 'xm create' knows about it. +xm_vars.var('vmid', + use="Virtual machine id. Integer greater than 0.", + check=vmid_check) + +# Check the defined variables have valid values.. +xm_vars.check() + +#---------------------------------------------------------------------------- +# Kernel image file and (optional) ramdisk (initrd). +kernel = "/boot/vmlinuz-xen" +ramdisk = "/boot/initrd-xen" + +# Or use domUloader instead of kernel/ramdisk to get kernel from domU FS +#bootloader = "/usr/lib/xen/boot/domUloader.py" +#bootentry = "hda2:/vmlinuz-xen,/initrd-xen" + +# The domain build function. Default is 'linux'. +#builder='linux' + +# Initial memory allocation (in megabytes) for the new domain. +# +# WARNING: Creating a domain with insufficient memory may cause out of +# memory errors. The domain needs enough memory to boot kernel +# and modules. Allocating less than 32MBs is not recommended. +memory = 64 + +# A name for the new domain. All domains have to have different names, +# so we use the vmid to create a name. +name = "VM%d" % vmid + +# 128-bit UUID for the domain. The default behavior is to generate a new UUID +# on each call to 'xm create'. +#uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9" + +# List of which CPUS this domain is allowed to use, default Xen picks +#cpus = "" # leave to Xen to pick +#cpus = "0" # all vcpus run on CPU0 +#cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5 +#cpus = ["2", "3"] # VCPU0 runs on CPU2, VCPU1 runs on CPU3 +#cpus = "%s" % vmid # set based on vmid (mod number of CPUs) + +# Number of Virtual CPUS to use, default is 1 +#vcpus = 1 +vcpus = 4 # make your domain a 4-way + +#---------------------------------------------------------------------------- +# Define network interfaces. + +# By default, no network interfaces are configured. You may have one created +# with sensible defaults using an empty vif clause: +# +# vif = [ '' ] +# +# or optionally override backend, bridge, ip, mac, script, type, or vifname: +# +# vif = [ 'mac=00:16:3e:00:00:11, bridge=xenbr0' ] +# +# or more than one interface may be configured: +# +# vif = [ '', 'bridge=xenbr1' ] + +vif = [ '' ] + +#---------------------------------------------------------------------------- +# Define the disk devices you want the domain to have access to, and +# what you want them accessible as. +# Each disk entry is of the form phy:UNAME,DEV,MODE +# where UNAME is the device, DEV is the device name the domain will see, +# and MODE is r for read-only, w for read-write. + +# This makes the disk device depend on the vmid - assuming +# that devices sda7, sda8 etc. exist. The device is exported +# to all domains as sda1. +# All domains get sda6 read-only (to use for /usr, see below). +disk = [ 'phy:sda%d,sda1,w' % (7+vmid), + 'phy:sda6,sda6,r' ] + +#---------------------------------------------------------------------------- +# Define frame buffer device. +# +# By default, no frame buffer device is configured. +# +# To create one using the SDL backend and sensible defaults: +# +# vfb = [ 'sdl=1' ] +# +# This uses environment variables XAUTHORITY and DISPLAY. You +# can override that: +# +# vfb = [ 'sdl=1,xauthority=/home/bozo/.Xauthority,display=:1' ] +# +# To create one using the VNC backend and sensible defaults: +# +# vfb = [ 'vnc=1' ] +# +# The backend listens on 127.0.0.1 port 5900+N by default, where N is +# the domain ID. You can override both address and N: +# +# vfb = [ 'vnc=1,vnclisten=127.0.0.1,vncdisplay=%d' % vmid ] +# +# Or you can bind the first unused port above 5900: +# +# vfb = [ 'vnc=1,vnclisten=0.0.0.0,vncunused=1' ] +# +# You can override the password: +# +# vfb = [ 'vnc=1,vncpasswd=MYPASSWD' ] +# +# Empty password disables authentication. Defaults to the vncpasswd +# configured in xend-config.sxp. + +#---------------------------------------------------------------------------- +# Define to which TPM instance the user domain should communicate. +# The vtpm entry is of the form 'instance=INSTANCE,backend=DOM' +# where INSTANCE indicates the instance number of the TPM the VM +# should be talking to and DOM provides the domain where the backend +# is located. +# Note that no two virtual machines should try to connect to the same +# TPM instance. The handling of all TPM instances does require +# some management effort in so far that VM configration files (and thus +# a VM) should be associated with a TPM instance throughout the lifetime +# of the VM / VM configuration file. The instance number must be +# greater or equal to 1. +#vtpm = ['instance=%d,backend=0' % (vmid) ] + +#---------------------------------------------------------------------------- +# Set the kernel command line for the new domain. +# You only need to define the IP parameters and hostname if the domain's +# IP config doesn't, e.g. in ifcfg-eth0 or via DHCP. +# You can use 'extra' to set the runlevel and custom environment +# variables used by custom rc scripts (e.g. VMID=, usr= ). + +# Set if you want dhcp to allocate the IP address. +#dhcp="dhcp" +# Set netmask. +#netmask= +# Set default gateway. +#gateway= +# Set the hostname. +#hostname= "vm%d" % vmid + +# Set root device. +root = "/dev/sda1" + +# Root device for nfs. +#root = "/dev/nfs" +# The nfs server. +#nfs_server = '192.0.2.1' +# Root directory on the nfs server. +#nfs_root = '/full/path/to/root/directory' + +# Sets the device for /usr. +extra = "VMID=%d usr=/dev/sda6" % vmid + +#---------------------------------------------------------------------------- +# Configure the behaviour when a domain exits. There are three 'reasons' +# for a domain to stop: poweroff, reboot, and crash. For each of these you +# may specify: +# +# "destroy", meaning that the domain is cleaned up as normal; +# "restart", meaning that a new domain is started in place of the old +# one; +# "preserve", meaning that no clean-up is done until the domain is +# manually destroyed (using xm destroy, for example); or +# "rename-restart", meaning that the old domain is not cleaned up, but is +# renamed and a new domain started in its place. +# +# In the event a domain stops due to a crash, you have the additional options: +# +# "coredump-destroy", meaning dump the crashed domain's core and then destroy; +# "coredump-restart', meaning dump the crashed domain's core and the restart. +# +# The default is +# +# on_poweroff = 'destroy' +# on_reboot = 'restart' +# on_crash = 'restart' +# +# For backwards compatibility we also support the deprecated option restart +# +# restart = 'onreboot' means on_poweroff = 'destroy' +# on_reboot = 'restart' +# on_crash = 'destroy' +# +# restart = 'always' means on_poweroff = 'restart' +# on_reboot = 'restart' +# on_crash = 'restart' +# +# restart = 'never' means on_poweroff = 'destroy' +# on_reboot = 'destroy' +# on_crash = 'destroy' + +#on_poweroff = 'destroy' +#on_reboot = 'restart' +#on_crash = 'restart' + +#----------------------------------------------------------------------------- +# Configure PVSCSI devices: +# +#vscsi=[ 'PDEV, VDEV' ] +# +# PDEV gives physical SCSI device to be attached to specified guest +# domain by one of the following identifier format. +# - XX:XX:XX:XX (4-tuples with decimal notation which shows +# "host:channel:target:lun") +# - /dev/sdxx or sdx +# - /dev/stxx or stx +# - /dev/sgxx or sgx +# - result of 'scsi_id -gu -s'. +# ex. # scsi_id -gu -s /block/sdb +# 36000b5d0006a0000006a0257004c0000 +# +# VDEV gives virtual SCSI device by 4-tuples (XX:XX:XX:XX) as +# which the specified guest domain recognize. +# + +#vscsi = [ '/dev/sdx, 0:0:0:0' ] + +#============================================================================ diff --git a/os-plugins/plugins/xen/files/xen.examples/examples/xmexample3 b/os-plugins/plugins/xen/files/xen.examples/examples/xmexample3 new file mode 100644 index 00000000..e82424e7 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/examples/xmexample3 @@ -0,0 +1,234 @@ +# -*- mode: python; -*- +#============================================================================ +# Example Python setup script for 'xm create'. +# This script sets the parameters used when a domain is created using 'xm create'. +# +# This is a relatively advanced script that uses a parameter, vmid, to control +# the settings. So this script can be used to start a set of domains by +# setting the vmid parameter on the 'xm create' command line. For example: +# +# xm create vmid=1 +# xm create vmid=2 +# xm create vmid=3 +# +# The vmid is purely a script variable, and has no effect on the the domain +# id assigned to the new domain. +#============================================================================ + +# Define script variables here. +# xm_vars is defined automatically, use xm_vars.var() to define a variable. + +# This function checks that 'vmid' has been given a valid value. +# It is called automatically by 'xm create'. +def vmid_check(var, val): + val = int(val) + if val <= 0: + raise ValueError + return val + +# Define the 'vmid' variable so that 'xm create' knows about it. +xm_vars.var('vmid', + use="Virtual machine id. Integer greater than 0.", + check=vmid_check) + +# Check the defined variables have valid values.. +xm_vars.check() + +#---------------------------------------------------------------------------- +# Kernel image file and (optional) ramdisk (initrd). +kernel = "/boot/vmlinuz-xen" +ramdisk = "/boot/initrd-xen" + +# Or use domUloader instead of kernel/ramdisk to get kernel from domU FS +#bootloader = "/usr/lib/xen/boot/domUloader.py" +#bootentry = "hda2:/vmlinuz-xen,/initrd-xen" + +# The domain build function. Default is 'linux'. +#builder='linux' + +# Initial memory allocation (in megabytes) for the new domain. +# +# WARNING: Creating a domain with insufficient memory may cause out of +# memory errors. The domain needs enough memory to boot kernel +# and modules. Allocating less than 32MBs is not recommended. +memory = 64 + +# A name for the new domain. All domains have to have different names, +# so we use the vmid to create a name. +name = "VM%d" % vmid + +# 128-bit UUID for the domain. The default behavior is to generate a new UUID +# on each call to 'xm create'. +#uuid = "06ed00fe-1162-4fc4-b5d8-11993ee4a8b9" + +# List of which CPUS this domain is allowed to use, default Xen picks +#cpus = "" # leave to Xen to pick +#cpus = "0" # all vcpus run on CPU0 +#cpus = "0-3,5,^1" # all vcpus run on cpus 0,2,3,5 +#cpus = ["2", "3"] # VCPU0 runs on CPU2, VCPU1 runs on CPU3 +cpus = "%s" % vmid # set based on vmid (mod number of CPUs) + +#---------------------------------------------------------------------------- +# Define network interfaces. + +# Optionally define mac and/or bridge for the network interfaces. +# Random MACs are assigned if not given. + +vif = [ 'ip=192.168.%d.1/24' % (vmid)] + +#---------------------------------------------------------------------------- +# Define the disk devices you want the domain to have access to, and +# what you want them accessible as. +# Each disk entry is of the form phy:UNAME,DEV,MODE +# where UNAME is the device, DEV is the device name the domain will see, +# and MODE is r for read-only, w for read-write. + +# This makes the disk device depend on the vmid - assuming +# tHat devices sda7, sda8 etc. exist. The device is exported +# to all domains as sda1. +# All domains get sda6 read-only (to use for /usr, see below). +disk = [ 'phy:hda%d,hda1,w' % (vmid)] + +#---------------------------------------------------------------------------- +# Define frame buffer device. +# +# By default, no frame buffer device is configured. +# +# To create one using the SDL backend and sensible defaults: +# +# vfb = [ 'sdl=1' ] +# +# This uses environment variables XAUTHORITY and DISPLAY. You +# can override that: +# +# vfb = [ 'sdl=1,xauthority=/home/bozo/.Xauthority,display=:1' ] +# +# To create one using the VNC backend and sensible defaults: +# +# vfb = [ 'vnc=1' ] +# +# The backend listens on 127.0.0.1 port 5900+N by default, where N is +# the domain ID. You can override both address and N: +# +# vfb = [ 'vnc=1,vnclisten=127.0.0.1,vncdisplay=%d' % vmid ] +# +# Or you can bind the first unused port above 5900: +# +# vfb = [ 'vnc=1,vnclisten=0.0.0.0,vncunused=1' ] +# +# You can override the password: +# +# vfb = [ 'vnc=1,vncpasswd=MYPASSWD' ] +# +# Empty password disables authentication. Defaults to the vncpasswd +# configured in xend-config.sxp. + +#---------------------------------------------------------------------------- +# Define to which TPM instance the user domain should communicate. +# The vtpm entry is of the form 'instance=INSTANCE,backend=DOM' +# where INSTANCE indicates the instance number of the TPM the VM +# should be talking to and DOM provides the domain where the backend +# is located. +# Note that no two virtual machines should try to connect to the same +# TPM instance. The handling of all TPM instances does require +# some management effort in so far that VM configration files (and thus +# a VM) should be associated with a TPM instance throughout the lifetime +# of the VM / VM configuration file. The instance number must be +# greater or equal to 1. +#vtpm = ['instance=%d,backend=0' % (vmid) ] + +#---------------------------------------------------------------------------- +# Set the kernel command line for the new domain. +# You only need to define the IP parameters and hostname if the domain's +# IP config doesn't, e.g. in ifcfg-eth0 or via DHCP. +# You can use 'extra' to set the runlevel and custom environment +# variables used by custom rc scripts (e.g. VMID=, usr= ). + +# Set if you want dhcp to allocate the IP address. +dhcp="off" +ip="192.168.%d.2" % (vmid) +# Set netmask. +netmask="255.255.255.0" +# Set default gateway. +gateway="192.168.%d.1" % (vmid) +# Set the hostname. +hostname= "domain-%d.xeno" % vmid + +# Set root device. +root = "/dev/hda1 ro" + +# Root device for nfs. +#root = "/dev/nfs" +# The nfs server. +#nfs_server = "10.212.4.103" +# Root directory on the nfs server. +#nfs_root = "/path/to/root/filesystem" + +# Sets runlevel 4 and the device for /usr. +extra = "4 VMID=%d" % vmid + +#---------------------------------------------------------------------------- +# Configure the behaviour when a domain exits. There are three 'reasons' +# for a domain to stop: poweroff, reboot, and crash. For each of these you +# may specify: +# +# "destroy", meaning that the domain is cleaned up as normal; +# "restart", meaning that a new domain is started in place of the old +# one; +# "preserve", meaning that no clean-up is done until the domain is +# manually destroyed (using xm destroy, for example); or +# "rename-restart", meaning that the old domain is not cleaned up, but is +# renamed and a new domain started in its place. +# +# In the event a domain stops due to a crash, you have the additional options: +# +# "coredump-destroy", meaning dump the crashed domain's core and then destroy; +# "coredump-restart', meaning dump the crashed domain's core and the restart. +# +# The default is +# +# on_poweroff = 'destroy' +# on_reboot = 'restart' +# on_crash = 'restart' +# +# For backwards compatibility we also support the deprecated option restart +# +# restart = 'onreboot' means on_poweroff = 'destroy' +# on_reboot = 'restart' +# on_crash = 'destroy' +# +# restart = 'always' means on_poweroff = 'restart' +# on_reboot = 'restart' +# on_crash = 'restart' +# +# restart = 'never' means on_poweroff = 'destroy' +# on_reboot = 'destroy' +# on_crash = 'destroy' + +#on_poweroff = 'destroy' +#on_reboot = 'restart' +#on_crash = 'restart' + +#----------------------------------------------------------------------------- +# Configure PVSCSI devices: +# +#vscsi=[ 'PDEV, VDEV' ] +# +# PDEV gives physical SCSI device to be attached to specified guest +# domain by one of the following identifier format. +# - XX:XX:XX:XX (4-tuples with decimal notation which shows +# "host:channel:target:lun") +# - /dev/sdxx or sdx +# - /dev/stxx or stx +# - /dev/sgxx or sgx +# - result of 'scsi_id -gu -s'. +# ex. # scsi_id -gu -s /block/sdb +# 36000b5d0006a0000006a0257004c0000 +# +# VDEV gives virtual SCSI device by 4-tuples (XX:XX:XX:XX) as +# which the specified guest domain recognize. +# + +#vscsi = [ '/dev/sdx, 0:0:0:0' ] + +#============================================================================ diff --git a/os-plugins/plugins/xen/files/xen.examples/images b/os-plugins/plugins/xen/files/xen.examples/images new file mode 120000 index 00000000..0fb07d14 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/images @@ -0,0 +1 @@ +/var/lib/xen/images \ No newline at end of file diff --git a/os-plugins/plugins/xen/files/xen.examples/qemu-ifup b/os-plugins/plugins/xen/files/xen.examples/qemu-ifup new file mode 100755 index 00000000..ad46c9f9 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/qemu-ifup @@ -0,0 +1,23 @@ +#!/bin/sh + +echo 'config qemu network with xen bridge for ' $* + +# If bridge is not specified, try device with default route. +bridge=$2 +if [ -z "$bridge" ]; then + bridge=$(ip route list | awk '/^default / { print $NF }') +fi + +# Exit if $bridge is not a bridge. Exit with 0 status +# so qemu-dm process is not terminated. No networking in +# vm is bad but not catastrophic. The vm could still run +# cpu and disk IO workloads. +# Include an useful error message in qemu-dm log file. +if [ ! -e "/sys/class/net/${bridge}/bridge" ] +then + echo "WARNING! ${bridge} is not a bridge. qemu-ifup exiting. VM may not have a functioning networking stack." + exit 0 +fi + +ifconfig $1 0.0.0.0 up +brctl addif $bridge $1 || true diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/blktap b/os-plugins/plugins/xen/files/xen.examples/scripts/blktap new file mode 100755 index 00000000..01a0f6c6 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/blktap @@ -0,0 +1,93 @@ +#!/bin/bash + +# Copyright (c) 2005, XenSource Ltd. + +dir=$(dirname "$0") +. "$dir/xen-hotplug-common.sh" +. "$dir/block-common.sh" + +findCommand "$@" + +## +# check_blktap_sharing file mode +# +# Perform the sharing check for the given blktap and mode. +# +check_blktap_sharing() +{ + local file="$1" + local mode="$2" + + local base_path="$XENBUS_BASE_PATH/$XENBUS_TYPE" + for dom in $(xenstore-list "$base_path") + do + for dev in $(xenstore-list "$base_path/$dom") + do + params=$(xenstore_read "$base_path/$dom/$dev/params" | cut -d: -f2) + if [ "$file" = "$params" ] + then + + if [ "$mode" = 'w' ] + then + if ! same_vm "$dom" + then + echo 'guest' + return + fi + else + local m=$(xenstore_read "$base_path/$dom/$dev/mode") + m=$(canonicalise_mode "$m") + + if [ "$m" = 'w' ] + then + if ! same_vm "$dom" + then + echo 'guest' + return + fi + fi + fi + fi + done + done + + echo 'ok' +} + + +t=$(xenstore_read_default "$XENBUS_PATH/type" 'MISSING') +if [ -n "$t" ] +then + p=$(xenstore_read "$XENBUS_PATH/params") + # if we have a ':', chew from head including : + if echo $p | grep -q \: + then + p=${p#*:} + fi +fi +# some versions of readlink cannot be passed a regular file +if [ -L "$p" ]; then + file=$(readlink -f "$p") || fatal "$p link does not exist." +else + file="$p" +fi + +if [ "$command" = 'add' ] +then + [ -e "$file" ] || { fatal $file does not exist; } + + FRONTEND_ID=$(xenstore_read "$XENBUS_PATH/frontend-id") + FRONTEND_UUID=$(xenstore_read "/local/domain/$FRONTEND_ID/vm") + mode=$(xenstore_read "$XENBUS_PATH/mode") + mode=$(canonicalise_mode "$mode") + + if [ "$mode" != '!' ] + then + result=$(check_blktap_sharing "$file" "$mode") + [ "$result" = 'ok' ] || ebusy "$file already in use by other domain" + fi + + success +fi + +exit 0 diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/block b/os-plugins/plugins/xen/files/xen.examples/scripts/block new file mode 100755 index 00000000..cf579ed4 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/block @@ -0,0 +1,398 @@ +#!/bin/bash + +dir=$(dirname "$0") +. "$dir/block-common.sh" + +expand_dev() { + local dev + case $1 in + /*) + dev=$1 + ;; + *) + dev=/dev/$1 + ;; + esac + echo -n $dev +} + + +## +# check_sharing device mode +# +# Check whether the device requested is already in use. To use the device in +# read-only mode, it may be in use in read-only mode, but may not be in use in +# read-write anywhere at all. To use the device in read-write mode, it must +# not be in use anywhere at all. +# +# Prints one of +# +# 'local': the device may not be used because it is mounted in the current +# (i.e. the privileged domain) in a way incompatible with the +# requested mode; +# 'guest': the device may not be used because it already mounted by a guest +# in a way incompatible with the requested mode; or +# 'ok': the device may be used. +# +check_sharing() +{ + local dev="$1" + local mode="$2" + + local devmm=$(device_major_minor "$dev") + local file + + if [ "$mode" = 'w' ] + then + toskip="^$" + else + toskip="^[^ ]* [^ ]* [^ ]* ro[, ]" + fi + + for file in $(cat /proc/mounts | grep -v "$toskip" | cut -f 1 -d ' ') + do + if [ -e "$file" ] + then + local d=$(device_major_minor "$file") + + if [ "$d" = "$devmm" ] + then + echo 'local' + return + fi + fi + done + + local base_path="$XENBUS_BASE_PATH/$XENBUS_TYPE" + for dom in $(xenstore-list "$base_path") + do + for dev in $(xenstore-list "$base_path/$dom") + do + d=$(xenstore_read_default "$base_path/$dom/$dev/physical-device" "") + + if [ "$d" = "$devmm" ] + then + if [ "$mode" = 'w' ] + then + if ! same_vm $dom + then + echo 'guest' + return + fi + else + local m=$(xenstore_read "$base_path/$dom/$dev/mode") + m=$(canonicalise_mode "$m") + + if [ "$m" = 'w' ] + then + if ! same_vm $dom + then + echo 'guest' + return + fi + fi + fi + fi + done + done + + echo 'ok' +} + + +## +# check_device_sharing dev mode +# +# Perform the sharing check for the given physical device and mode. +# +check_device_sharing() +{ + local dev="$1" + local mode=$(canonicalise_mode "$2") + local result + + if [ "x$mode" = 'x!' ] + then + return 0 + fi + + result=$(check_sharing "$dev" "$mode") + + if [ "$result" != 'ok' ] + then + do_ebusy "Device $dev is mounted " "$mode" "$result" + fi +} + + +## +# check_device_sharing file dev mode +# +# Perform the sharing check for the given file mounted through the given +# loopback interface, in the given mode. +# +check_file_sharing() +{ + local file="$1" + local dev="$2" + local mode="$3" + + result=$(check_sharing "$dev" "$mode") + + if [ "$result" != 'ok' ] + then + do_ebusy "File $file is loopback-mounted through $dev, +which is mounted " "$mode" "$result" + fi +} + + +## +# do_ebusy prefix mode result +# +# Helper function for check_device_sharing check_file_sharing, calling ebusy +# with an error message constructed from the given prefix, mode, and result +# from a call to check_sharing. +# +do_ebusy() +{ + local prefix="$1" + local mode="$2" + local result="$3" + + if [ "$result" = 'guest' ] + then + dom='a guest ' + when='now' + else + dom='the privileged ' + when='by a guest' + fi + + if [ "$mode" = 'w' ] + then + m1='' + m2='' + else + m1='read-write ' + m2='read-only ' + fi + + release_lock "block" + ebusy \ +"${prefix}${m1}in ${dom}domain, +and so cannot be mounted ${m2}${when}." +} + + +t=$(xenstore_read_default "$XENBUS_PATH/type" 'MISSING') + +case "$command" in + add) + phys=$(xenstore_read_default "$XENBUS_PATH/physical-device" 'MISSING') + if [ "$phys" != 'MISSING' ] + then + # Depending upon the hotplug configuration, it is possible for this + # script to be called twice, so just bail. + exit 0 + fi + + if [ -n "$t" ] + then + p=$(xenstore_read "$XENBUS_PATH/params") + mode=$(xenstore_read "$XENBUS_PATH/mode") + fi + FRONTEND_ID=$(xenstore_read "$XENBUS_PATH/frontend-id") + FRONTEND_UUID=$(xenstore_read_default \ + "/local/domain/$FRONTEND_ID/vm" 'unknown') + + case $t in + phy) + dev=$(expand_dev $p) + + if [ -L "$dev" ] + then + dev=$(readlink -f "$dev") || fatal "$dev link does not exist." + fi + test -e "$dev" || fatal "$dev does not exist." + test -b "$dev" || fatal "$dev is not a block device." + + claim_lock "block" + check_device_sharing "$dev" "$mode" + write_dev "$dev" + release_lock "block" + exit 0 + ;; + + file) + lo_flags="" + [ "${mode/S}" = "$mode" ] || lo_flags="-y" + # Canonicalise the file, for sharing check comparison, and the mode + # for ease of use here. + file=$(readlink -f "$p") || fatal "$p does not exist." + test -f "$file" || fatal "$file does not exist." + mode=$(canonicalise_mode "$mode") + [ "$mode" = "r" ] && lo_flags="$lo_flags -r" + + claim_lock "block" + + if [ "$mode" = 'w' ] && ! stat "$file" -c %A | grep -q w + then + release_lock "block" + ebusy \ +"File $file is read-only, and so I will not +mount it read-write in a guest domain." + fi + + losetup_failure=1 + for do_losetup in 1 2 3 + do + loopdev='' + for dev in /dev/loop* + do + if [ ! -b "$dev" ] + then + continue + fi + + f=$(losetup "$dev" 2>/dev/null) || f='' + + if [ "$f" ] + then + # $dev is in use. Check sharing. + if [ "x$mode" = 'x!' ] + then + continue + fi + + f=$(echo "$f" | sed -e 's/.*(\(.*\)).*/\1/g') + + # $f is the filename, as read from losetup, but the loopback + # driver truncates filenames at 64 characters, so we need to go + # trawling through the store if it's longer than that. Truncation + # is indicated by an asterisk at the end of the filename. + if expr index "$f" '*' >/dev/null + then + found="" + for dom in $(xenstore-list "$XENBUS_BASE_PATH") + do + for domdev in $(xenstore-list "$XENBUS_BASE_PATH/$dom") + do + d=$(xenstore_read_default \ + "$XENBUS_BASE_PATH/$dom/$domdev/node" "") + if [ "$d" = "$dev" ] + then + f=$(xenstore_read "$XENBUS_BASE_PATH/$dom/$domdev/params") + found=1 + break 2 + fi + done + done + + if [ ! "$found" ] + then + # This loopback device is in use by someone else, so skip it. + log debug "Loopback sharing check skips device $dev." + continue + fi + fi + + # Canonicalise the filename for the comparison. + + # I have seen this readlink fails because the filename given by + # losetup is only the basename. This cannot happen when the loop + # device is set up through this script, because file is + # canonicalised above, but it may happen when loop devices are set + # up some other way. This readlink may also conceivably fail if + # the file backing this loop device has been removed. + + # For maximum safety, in the case that $f does not resolve, we + # assume that $file and $f are in the same directory. + + # If you create a loopback filesystem, remove it and continue to + # run on it, and then create another file with the same name, then + # this check will block that -- don't do that. + + # If you create loop devices through some other mechanism, use + # relative filenames, and then use the same filename through this + # script, then this check will block that -- don't do that either. + + f=$(readlink -f "$f" || echo $(dirname "$file")/$(basename "$f")) + + + if [ "$f" = "$file" ] + then + check_file_sharing "$file" "$dev" "$mode" + fi + else + # $dev is not in use, so we'll remember it for use later; we want + # to finish the sharing check first. + + if [ "$loopdev" = '' ] + then + loopdev="$dev" + fi + fi + done + + if [ "$loopdev" = '' ] + then + release_lock "block" + fatal 'Failed to find an unused loop device' + fi + + losetup $lo_flags "$loopdev" "$file" && losetup_failure="" && break + done + + if [ "$losetup_failure" ] + then + fatal 'losetup $lo_flags $loopdev $file' + fi + + xenstore_write "$XENBUS_PATH/node" "$loopdev" + write_dev "$loopdev" + release_lock "block" + exit 0 + ;; + + "") + claim_lock "block" + success + release_lock "block" + ;; + esac + ;; + + remove) + case $t in + phy) + exit 0 + ;; + + file) + node=$(xenstore_read "$XENBUS_PATH/node") + + #In case the loopback is temporarily blocked, retry the losetup -d. + for i in 1 2 3 4 5 + do + if losetup -d "$node" + then + exit 0 + fi + sleep 1 + done + log err "losetup -d $node failed." + exit 1 + ;; + + "") + exit 0 + ;; + esac + ;; + +esac + +# If we've reached here, $t is neither phy nor file, so fire a helper script. +[ -x /etc/xen/scripts/block-"$t" ] && \ + /etc/xen/scripts/block-"$t" "$command" $node diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/block-common.sh b/os-plugins/plugins/xen/files/xen.examples/scripts/block-common.sh new file mode 100644 index 00000000..efedbf50 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/block-common.sh @@ -0,0 +1,117 @@ +# +# Copyright (c) 2005 XenSource Ltd. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of version 2.1 of the GNU Lesser General Public +# License as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + + +dir=$(dirname "$0") +. "$dir/xen-hotplug-common.sh" + +findCommand "$@" + +if [ "$command" != "add" ] && + [ "$command" != "remove" ] +then + log err "Invalid command: $command" + exit 1 +fi + + +XENBUS_PATH="${XENBUS_PATH:?}" + + +ebusy() +{ + xenstore_write "$XENBUS_PATH/hotplug-error" "$*" \ + "$XENBUS_PATH/hotplug-status" busy + log err "$@" + exit 1 +} + + +## +# Print the given device's major and minor numbers, written in hex and +# separated by a colon. +device_major_minor() +{ + stat -L -c %t:%T "$1" +} + + +## +# Write physical-device = MM,mm to the store, where MM and mm are the major +# and minor numbers of device respectively. +# +# @param device The device from which major and minor numbers are read, which +# will be written into the store. +# +write_dev() { + local mm + + mm=$(device_major_minor "$1") + + if [ -z $mm ] + then + fatal "Backend device does not exist" + fi + + xenstore_write "$XENBUS_PATH/physical-device" "$mm" + + success +} + + +## +# canonicalise_mode mode +# +# Takes the given mode, which may be r, w, ro, rw, w!, or rw!, or variations +# thereof, and canonicalises them to one of +# +# 'r': perform checks for a new read-only mount; +# 'w': perform checks for a read-write mount; or +# '!': perform no checks at all. +# +canonicalise_mode() +{ + local mode="$1" + + if ! expr index "$mode" 'w' >/dev/null + then + echo 'r' + elif ! expr index "$mode" '!' >/dev/null + then + echo 'w' + else + echo '!' + fi +} + + +same_vm() +{ + local otherdom="$1" + # Note that othervm can be MISSING here, because Xend will be racing with + # the hotplug scripts -- the entries in /local/domain can be removed by + # Xend before the hotplug scripts have removed the entry in + # /local/domain/0/backend/. In this case, we want to pretend that the + # VM is the same as FRONTEND_UUID, because that way the 'sharing' will be + # allowed. + local othervm=$(xenstore_read_default "/local/domain/$otherdom/vm" \ + "$FRONTEND_UUID") + local target=$(xenstore_read_default "/local/domain/$FRONTEND_ID/target" \ + "-1") + [ "$FRONTEND_UUID" = "$othervm" -o "$target" = "$otherdom" ] +} + diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/block-iscsi b/os-plugins/plugins/xen/files/xen.examples/scripts/block-iscsi new file mode 100755 index 00000000..f473a0a9 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/block-iscsi @@ -0,0 +1,78 @@ +#!/bin/bash + +# Usage: block-iscsi [add tgtname | remove dev] +# +# This assumes you're running a correctly configured +# iscsi target (server) at the other end! +# Note that we assume that the passwords for discovery (if needed) +# are in /etc/iscsid.conf +# and the node session passwords (if required) in the +# open-iscsi database below /var/lib/open-iscsi/node.db +# +# (c) Kurt Garloff , 2006-09-04, GNU GPL +# Contributors: Jim Fehlig +# Stefan de Konink + +dir=$(dirname "$0") +. "$dir/block-common.sh" + +# echo "DBG:xen/scripts/block-iscsi $1 $2 XENBUS_PATH=$XENBUS_PATH $par $node" + +find_sdev() +{ + unset dev + for session in /sys/class/iscsi_session/session*; do + if [ "$1" = "`cat $session/targetname`" ]; then + dev=`basename $session/device/target*/*:0:*/block*/*` + return + fi + done +} + +find_sdev_rev() +{ + unset tgt + for session in /sys/class/iscsi_session/session*; do + dev=`basename $session/device/target*/*:0:*/block*/*` + if [ "$dev" = "$1" ]; then + tgt=`cat $session/targetname` + return + fi + done +} + +case "$command" in + add) + # load modules and start iscsid + /etc/init.d/open-iscsi status >/dev/null 2>&1 || + { /etc/init.d/open-iscsi start >/dev/null 2>&1; sleep 1; } + # list of targets on node + /sbin/iscsiadm -m discovery | sed "s/ .*//g" | while read line; do /sbin/iscsiadm -m discovery -t sendtargets -p $line; done >/dev/null + par=`xenstore-read $XENBUS_PATH/params` || true + TGTID=`echo $par | sed "s/\/\///g"` + while read rec uuid; do + if [ "$uuid" = "$TGTID" ]; then + find_sdev $TGTID + if [ -z "$dev" ]; then + /sbin/iscsiadm -m node -T $uuid -p $rec --login || exit 2 + sleep 4 + find_sdev $TGTID + fi + xenstore-write $XENBUS_PATH/node /dev/$dev + write_dev /dev/$dev + exit 0 + fi + done < <(/sbin/iscsiadm -m node) + exit 1 + ;; + + remove) + node=`xenstore-read $XENBUS_PATH/node` || true + dev=$node; dev=${dev#/dev/} + find_sdev_rev $dev + if [ -x /sbin/blockdev -a -n "$node" ]; then blockdev --flushbufs "$node"; fi + test -z "$tgt" && exit 2 + /sbin/iscsiadm -m node -T $tgt --logout + exit 1 + ;; +esac diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/block-nbd b/os-plugins/plugins/xen/files/xen.examples/scripts/block-nbd new file mode 100755 index 00000000..d4571152 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/block-nbd @@ -0,0 +1,34 @@ +#!/bin/sh + +# Usage: block-nbd [bind server ctl_port |unbind node] +# +# The node argument to unbind is the name of the device node we are to +# unbind. +# +# This assumes you're running a correctly configured server at the other end! + +dir=$(dirname "$0") +. "$dir/block-common.sh" + +#set -x +par=`xenstore-read $XENBUS_PATH/params` || true +#echo $par + +case "$command" in + add) + modprobe nbd + for dev in /dev/nbd*; do + if nbd-client $par $dev; then + xenstore-write $XENBUS_PATH/node $dev + write_dev $dev + exit 0 + fi + done + exit 1 + ;; + remove) + node=`xenstore-read $XENBUS_PATH/node` || true + nbd-client -d $node + exit 0 + ;; +esac diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/block-npiv b/os-plugins/plugins/xen/files/xen.examples/scripts/block-npiv new file mode 100755 index 00000000..19719dab --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/block-npiv @@ -0,0 +1,77 @@ +#!/bin/bash + +# Usage: block-npiv [add npiv | remove dev] + +dir=$(dirname "$0") +. "$dir/block-npiv-common.sh" +. "$dir/block-common.sh" + +#set -x +#command=$1 + +case "$command" in + add) + # Params is one big arg, with fields separated by hyphens: + # FABRIC-VPWWPN-VPWWNN-TGTWWPN-LUN# + # arg 2 - Fabric Name + # arg 3 - VPORT's WWPN + # arg 4 - VPORT's WWNN + # arg 5 - Target's WWPN + # arg 6 - LUN # on Target + # no wwn contains a leading 0x - it is a 16 character hex value + # You may want to optionally pick a specific adapter ? + par=`xenstore-read $XENBUS_PATH/params` || true + #par=$2 + NPIVARGS=$par; + LUN=${NPIVARGS##*-*-*-*-}; NPIVARGS=${NPIVARGS%-*} + if test $LUN = $NPIVARGS ; then exit 1; fi + TGTWWPN=${NPIVARGS##*-*-*-}; NPIVARGS=${NPIVARGS%-*} + if test $TGTWWPN = $NPIVARGS ; then exit 1; fi + VPORTWWNN=${NPIVARGS##*-*-}; NPIVARGS=${NPIVARGS%-*} + if test $VPORTWWNN = $NPIVARGS ; then exit 1; fi + VPORTWWPN=${NPIVARGS##*-}; NPIVARGS=${NPIVARGS%-*} + if test $VPORTWWPN = $NPIVARGS ; then exit 1; fi + FABRICNM=$NPIVARGS + + # Ensure we compare everything using lower-case hex characters + TGTWWPN=`echo $TGTWWPN | tr A-Z a-z` + VPORTWWPN=`echo $VPORTWWPN | tr A-Z a-z` + VPORTWWNN=`echo $VPORTWWNN | tr A-Z a-z` + FABRICNM=`echo $FABRICNM | tr A-Z a-z` + + find_vhost $VPORTWWPN + if test -z "$vhost" ; then + create_vport $FABRICNM $VPORTWWPN $VPORTWWNN + if [ $? -ne 0 ] ; then exit 2; fi + sleep 8 + find_vhost $VPORTWWPN + if test -z "$vhost" ; then exit 3; fi + fi + find_sdev $vhost $TGTWWPN $LUN + if test -z "$dev"; then + echo "- - -" > /sys/class/scsi_host/$vhost/scan + sleep 2 + find_sdev $vhost $TGTWWPN $LUN + fi + if test ! -z "$dev"; then + xenstore-write $XENBUS_PATH/node /dev/$dev + write_dev /dev/$dev + exit 0 + fi + + exit 4 + ;; + + remove) + node=`xenstore-read $XENBUS_PATH/node` || true + #node=$2 + dev=$node; dev=${dev#/dev/} + # this is really screwy. the first delete of a lun will + # terminate the entire vport (all luns) + find_vhost_from_dev $dev + if test -z "$vhost" ; then exit 5; fi + flush_nodes_on_vhost $vhost + delete_vhost $vhost + exit 0 + ;; +esac diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/block-npiv-common.sh b/os-plugins/plugins/xen/files/xen.examples/scripts/block-npiv-common.sh new file mode 100755 index 00000000..dcf71036 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/block-npiv-common.sh @@ -0,0 +1,238 @@ + + +# Look for the NPIV vport with the WWPN +# $1 contains the WWPN (assumes it does not contain a leading "0x") +find_vhost() +{ + unset vhost + + # look in upstream locations + for fchost in /sys/class/fc_vports/* ; do + if test -e $fchost/port_name ; then + wwpn=`cat $fchost/port_name | sed -e s/^0x//` + if test $wwpn = $1 ; then + # Note: makes the assumption the vport will always have an scsi_host child + vhost=`ls -d $fchost/device/host*` + vhost=`basename $vhost` + return + fi + fi + done + + # look in vendor-specific locations + + # Emulex - just looks like another scsi_host - so look at fc_hosts... + for fchost in /sys/class/fc_host/* ; do + if test -e $fchost/port_name ; then + wwpn=`cat $fchost/port_name | sed -e s/^0x//` + if test $wwpn = $1 ; then + # Note: makes the assumption the vport will always have an scsi_host child + vhost=`basename $fchost` + return + fi + fi + done +} + + +# Create a NPIV vport on the fabric w/ FABRICNM, with WWPN,WWNN +# $1 contains FABRICNM +# $2 contains the VPORT WWPN +# $3 contains the VPORT WWNN +# (assumes no name contains a leading "0x") +create_vport() +{ + # find a base adapter with npiv support that is on the right fabric + + # Look via upstream interfaces + for fchost in /sys/class/fc_host/* ; do + if test -e $fchost/vport_create ; then + # is the link up, w/ NPIV support ? + pstate=`cat $fchost/port_state` + ptype=`cat $fchost/port_type | cut -c 1-5` + fname=`cat $fchost/fabric_name | sed -e s/^0x//` + if [ $pstate = "Online" -a $ptype = "NPort" -a $fname = $1 ] ; then + vmax=`cat $fchost/max_npiv_vports` + vinuse=`cat $fchost/npiv_vports_inuse` + avail=`expr $vmax - $vinuse` + if [ $avail -gt 0 ] ; then + # create the vport + echo $2":"$3 > $fchost/vport_create + if [ $? -eq 0 ] ; then + return 0 + fi + # failed - so we'll just look for the next adapter + fi + fi + fi + done + + # Look in vendor-specific locations + + # Emulex: interfaces mirror upstream, but are under adapter scsi_host + for shost in /sys/class/scsi_host/* ; do + if [ -e $shost/vport_create ] ; then + fchost=`ls -d $shost/device/fc_host*` + # is the link up, w/ NPIV support ? + pstate=`cat $fchost/port_state` + ptype=`cat $fchost/port_type | cut -c 1-5` + fname=`cat $fchost/fabric_name | sed -e s/^0x//` + if [ $pstate = "Online" -a $ptype = "NPort" -a $fname = $1 ] ; then + vmax=`cat $shost/max_npiv_vports` + vinuse=`cat $shost/npiv_vports_inuse` + avail=`expr $vmax - $vinuse` + if [ $avail -gt 0 ] ; then + # create the vport + echo $2":"$3 > $shost/vport_create + if [ $? -eq 0 ] ; then + return 0 + fi + # failed - so we'll just look for the next adapter + fi + fi + fi + done + + return 1 +} + + +# Look for the LUN on the indicated scsi_host (which is an NPIV vport) +# $1 is the scsi_host name (normalized to simply the hostX name) +# $2 is the WWPN of the tgt port the lun is on +# Note: this implies we don't support a multipath'd lun, or we +# are explicitly identifying a "path" +# $3 is the LUN number of the scsi device +find_sdev() +{ + unset dev + hostno=${1/*host/} + for sdev in /sys/class/scsi_device/${hostno}:*:$3 ; do + if test -e $sdev/device/../fc_trans*/target${hostno}*/port_name ; then + tgtwwpn=`cat $sdev/device/../fc_trans*/target${hostno}*/port_name | sed -e s/^0x//` + if test $tgtwwpn = $2 ; then + if test -e $sdev/device/block* ; then + dev=`ls $sdev/device/block*` + dev=${dev##*/} + return + fi + fi + fi + done +} + + +# Look for the NPIV vhost based on a scsi "sdX" name +# $1 is the "sdX" name +find_vhost_from_dev() +{ + unset vhost + hostno=`readlink /sys/block/$1/device` + hostno=${hostno##*/} + hostno=${hostno%%:*} + if test -z "$hostno" ; then return; fi + vhost="host"$hostno +} + + +# We're about to terminate a vhost based on a scsi device +# Flush all nodes on that vhost as they are about to go away +# $1 is the vhost +flush_nodes_on_vhost() +{ + if test ! -x /sbin/blockdev ; then return; fi + hostno=${1/*host/} + for sdev in /sys/class/scsi_device/${hostno}:* ; do + if test -e $sdev/device/block* ; then + dev=`ls $sdev/device/block*` + dev="/dev/"$dev + if test -n "$dev"; then + blockdev --flushbufs $dev + fi + fi + done +} + + +# Terminate a NPIV vhost +# $1 is vhost +delete_vhost() +{ + # use upstream interface + for vport in /sys/class/fc_vports/* ; do + if test -e $vport/device/$1 ; then + if test -e $vport/vport_delete ; then + echo "1" > $vport/vport_delete + if test $? -ne 0 ; then exit 6; fi + sleep 4 + return + fi + fi + done + + # use vendor specific interface + + # Emulex + if test -e /sys/class/fc_host/$1/device/../scsi_host*/lpfc_drvr_version ; then + shost=`ls -1d /sys/class/fc_host/$1/device/../scsi_host* | sed s/.*scsi_host://` + vportwwpn=`cat /sys/class/fc_host/$1/port_name | sed s/^0x//` + vportwwnn=`cat /sys/class/fc_host/$1/node_name | sed s/^0x//` + echo "$vportwwpn:$vportwwnn" > /sys/class/scsi_host/$shost/vport_delete + if test $? -ne 0 ; then exit 6; fi + sleep 4 + return + fi + + # Qlogic + if test -e /sys/class/fc_host/$1/device/../scsi_host*/driver_version ; then + shost=`ls -1d /sys/class/fc_host/$1/device/../scsi_host* | sed s/.*scsi_host://` + vportwwpn=`cat /sys/class/fc_host/$1/port_name | sed s/^0x//` + vportwwnn=`cat /sys/class/fc_host/$1/node_name | sed s/^0x//` + echo "$vportwwpn:$vportwwnn" > /sys/class/scsi_host/$shost/vport_delete + if test $? -ne 0 ; then exit 6; fi + sleep 4 + return + fi + + exit 6 +} + + +vport_status() +{ + # Look via upstream interfaces + for fchost in /sys/class/fc_host/* ; do + if test -e $fchost/vport_create ; then + vport_status_display $fchost $fchost + fi + done + + # Look in vendor-specific locations + + # Emulex: interfaces mirror upstream, but are under adapter scsi_host + for shost in /sys/class/scsi_host/* ; do + if [ -e $shost/vport_create ] ; then + fchost=`ls -d $shost/device/fc_host*` + vport_status_display $fchost $shost + fi + done + + return 0 +} + + +vport_status_display() +{ + echo + echo "fc_host: " $2 + echo "port_state: " `cat $1/port_state` + echo "port_type: " `cat $1/port_type` + echo "fabric_name: " `cat $1/fabric_name` + echo "max_npiv_vports: " `cat $2/max_npiv_vports` + echo "npiv_vports_inuse: " `cat $2/npiv_vports_inuse` + echo "modeldesc: " `cat $2/modeldesc` + echo "speed: " `cat $1/speed` + + return 0 +} + diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/block-npiv-vport b/os-plugins/plugins/xen/files/xen.examples/scripts/block-npiv-vport new file mode 100755 index 00000000..91185f74 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/block-npiv-vport @@ -0,0 +1,79 @@ +#!/bin/bash + +# Usage: block-npiv-vport [create npivargs | delete vportwwpn | status] + +dir=$(dirname "$0") +. "$dir/block-npiv-common.sh" + +#set -x +command=$1 +params=$2 + +case "$command" in + create) + # Params is one big arg, with fields separated by hyphens: + # FABRIC-VPWWPN-VPWWNN-TGTWWPN-LUN# + # arg 2 - Fabric Name + # arg 3 - VPORT's WWPN + # arg 4 - VPORT's WWNN + # arg 5 - Target's WWPN + # arg 6 - LUN # on Target + # no wwn contains a leading 0x - it is a 16 character hex value + # You may want to optionally pick a specific adapter ? + NPIVARGS=$params; + LUN=${NPIVARGS##*-*-*-*-}; NPIVARGS=${NPIVARGS%-*} + if test $LUN = $NPIVARGS ; then exit 1; fi + TGTWWPN=${NPIVARGS##*-*-*-}; NPIVARGS=${NPIVARGS%-*} + if test $TGTWWPN = $NPIVARGS ; then exit 1; fi + VPORTWWNN=${NPIVARGS##*-*-}; NPIVARGS=${NPIVARGS%-*} + if test $VPORTWWNN = $NPIVARGS ; then exit 1; fi + VPORTWWPN=${NPIVARGS##*-}; NPIVARGS=${NPIVARGS%-*} + if test $VPORTWWPN = $NPIVARGS ; then exit 1; fi + FABRICNM=$NPIVARGS + + # Ensure we compare everything using lower-case hex characters + TGTWWPN=`echo $TGTWWPN | tr A-Z a-z` + VPORTWWPN=`echo $VPORTWWPN | tr A-Z a-z` + VPORTWWNN=`echo $VPORTWWNN | tr A-Z a-z` + FABRICNM=`echo $FABRICNM | tr A-Z a-z` + + find_vhost $VPORTWWPN + if test -z "$vhost" ; then + create_vport $FABRICNM $VPORTWWPN $VPORTWWNN + if [ $? -ne 0 ] ; then exit 2; fi + sleep 8 + find_vhost $VPORTWWPN + if test -z "$vhost" ; then exit 3; fi + fi + + exit 0 + ;; + + delete) + # Params is VPORT's WWPN + # no wwn contains a leading 0x - it is a 16 character hex value + VPORTWWPN=$params + + # Ensure we compare everything using lower-case hex characters + VPORTWWPN=`echo $VPORTWWPN | tr A-Z a-z` + + find_vhost $VPORTWWPN + if test -z "$vhost" ; then exit 4; fi + delete_vhost $vhost + + exit 0 + ;; + + status) + vport_status + + exit 0 + ;; + + *) + echo "Usage: block-npiv-vport [create npivargs | delete vportwwpn | status]" + + exit 1 + ;; +esac + diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/domain-lock b/os-plugins/plugins/xen/files/xen.examples/scripts/domain-lock new file mode 100755 index 00000000..268d0058 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/domain-lock @@ -0,0 +1,83 @@ +#!/bin/bash + +basedir=$(dirname "$0") + +usage() { + echo "usage: domain-lock [-l|-u] -n -i -p path" + echo "usage: domain-lock [-s] path" + echo "" + echo "-l lock" + echo "-u unlock" + echo "-s status (default)" + echo "-n Virtual Machine name" + echo "-i Virtual Machine Id or UUID" + echo "-p Virtual Machine Server (physical host) name" + echo "path A per-VM, unique location where external lock will be managed" + exit 1 +} + +remove_lock(){ + local path=$1/lock + local name=$2 + + pid=`ps -efwww | grep vm-monitor | grep $name | awk '{print $2}'` + if [ -n "$pid" ]; then + kill $pid + rm -f $path + fi +} + +get_status(){ + local path=$1/lock + [ -f $path ] || exit 1 + + rc=`flock -xn $path /bin/true` + cat $path + exit $rc +} + +mode="status" + +while getopts ":lusn:i:p:" opt; do + case $opt in + l ) + mode="lock" + ;; + u ) + mode="unlock" + ;; + s ) + mode="status" + ;; + p ) + vm_host=$OPTARG + ;; + n ) + vm_name=$OPTARG + ;; + i ) + vm_uuid=$OPTARG + ;; + \? ) + usage + ;; + esac +done + +shift $(($OPTIND - 1)) +vm_path=$1 + +case $mode in + lock ) + [ -z "$vm_path" ] || [ -z "$vm_name" ] || [ -z "$vm_uuid" ] || [ -z "$vm_host" ] && usage + $basedir/set-lock $vm_path $vm_name $vm_uuid $vm_host + ;; + unlock ) + [ -z "$vm_path" ] || [ -z "$vm_name" ] || [ -z "$vm_uuid" ] || [ -z "$vm_host" ] && usage + remove_lock $vm_path $vm_name $vm_uuid $vm_host + ;; + status ) + [ -z "$vm_path" ] && usage + get_status $vm_path + ;; +esac diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/external-device-migrate b/os-plugins/plugins/xen/files/xen.examples/scripts/external-device-migrate new file mode 100755 index 00000000..a4113483 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/external-device-migrate @@ -0,0 +1,98 @@ +#!/bin/bash + +# Copyright (c) 2005 IBM Corporation +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of version 2.1 of the GNU Lesser General Public +# License as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +set -x + +# This script is called by XenD for migration of external devices +# It does not handle the migration of those devices itself, but +# passes the requests on to further applications +# It handles the low-level command line parsing and some of the +# synchronization + +dir=$(dirname "$0") +. "$dir/logging.sh" + + +function ext_dev_migrate_usage() { +cat < : n-th migration step +-host : the destination host +-domname : name of the domain that is migrating +-type : the type of device that is migrating +-subtype : the subtype of the device +-recover : indicates recovery request; an error + occurred during migration +-help : display this help screen +EOF +} + +# Parse the command line paramters. The following parameters must be +# passed as the first ones in the sequence: +# -step [required] +# -host [required] +# -domname [required] +# -type [required] +# -subtype [optional] +# -recover [optional] +# The remaining ones will be passed to the called function. +function evaluate_params() +{ + local step host domname typ recover filename func stype + stype="" + while [ $# -ge 1 ]; do + case "$1" in + -step) step=$2; shift; shift;; + -host) host=$2; shift; shift;; + -domname) domname=$2; shift; shift;; + -type) typ=$2; shift; shift;; + -subtype) stype=$2; shift; shift;; + -recover) recover=1; shift;; + -help) ext_dev_migrate_usage; exit 0;; + *) break;; + esac + done + + if [ "$step" = "" -o \ + "$host" = "" -o \ + "$typ" = "" -o \ + "$domname" = "" ]; then + echo "Error: Parameter(s) missing (-step/-host/-type/-domname)" 1>&2 + echo "" 1>&2 + echo "$0 -help for usage." 1>&2 + exit 1 + fi + + filename="$dir/$typ$stype-migration.sh" + if [ ! -r $filename ]; then + echo "Error: Could not find script '$filename'" + return + fi + . "$filename" + + if [ "$recover" = "1" ]; then + func="$typ"_recover + eval $func $host $domname $step $* + else + func="$typ"_migration_step + eval $func $host $domname $step $* + fi +} + +evaluate_params "$@" diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/locking.sh b/os-plugins/plugins/xen/files/xen.examples/scripts/locking.sh new file mode 100644 index 00000000..6ff58e7e --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/locking.sh @@ -0,0 +1,98 @@ +# +# Copyright (c) 2005 XenSource Ltd. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of version 2.1 of the GNU Lesser General Public +# License as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# +# Serialisation +# + +LOCK_SLEEPTIME=1 +LOCK_SPINNING_RETRIES=5 +LOCK_RETRIES=100 +LOCK_BASEDIR=/var/run/xen-hotplug + + +claim_lock() +{ + local lockdir="$LOCK_BASEDIR/$1" + mkdir -p "$LOCK_BASEDIR" + _claim_lock "$lockdir" +} + + +release_lock() +{ + _release_lock "$LOCK_BASEDIR/$1" +} + + +_claim_lock() +{ + local lockdir="$1" + local owner=$(_lock_owner "$lockdir") + local retries=0 + + while [ $retries -lt $LOCK_RETRIES ] + do + mkdir "$lockdir" 2>/dev/null && trap "release_lock $1; sigerr" ERR && + _update_lock_info "$lockdir" && return + + local new_owner=$(_lock_owner "$lockdir") + if [ "$new_owner" != "$owner" ] + then + owner="$new_owner" + retries=0 + fi + + if [ $retries -gt $LOCK_SPINNING_RETRIES ] + then + sleep $LOCK_SLEEPTIME + else + sleep 0 + fi + retries=$(($retries + 1)) + done + _steal_lock "$lockdir" +} + + +_release_lock() +{ + trap sigerr ERR + rm -rf "$1" 2>/dev/null || true +} + + +_steal_lock() +{ + local lockdir="$1" + local owner=$(cat "$lockdir/owner" 2>/dev/null || echo "unknown") + log err "Forced to steal lock on $lockdir from $owner!" + _release_lock "$lockdir" + _claim_lock "$lockdir" +} + + +_lock_owner() +{ + cat "$1/owner" 2>/dev/null || echo "unknown" +} + + +_update_lock_info() +{ + echo "$$: $0" >"$1/owner" +} diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/logging.sh b/os-plugins/plugins/xen/files/xen.examples/scripts/logging.sh new file mode 100644 index 00000000..c1bc699c --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/logging.sh @@ -0,0 +1,22 @@ +# +# Copyright (c) 2005 XenSource Ltd. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of version 2.1 of the GNU Lesser General Public +# License as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +log() { + local level="$1" + shift + logger -p "daemon.$level" -- "$0:" "$@" || echo "$0 $@" >&2 +} diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/network-bridge b/os-plugins/plugins/xen/files/xen.examples/scripts/network-bridge new file mode 100755 index 00000000..ade0ce33 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/network-bridge @@ -0,0 +1,380 @@ +#!/bin/bash +#============================================================================ +# Default Xen network start/stop script. +# Xend calls a network script when it starts. +# The script name to use is defined in /etc/xen/xend-config.sxp +# in the network-script field. +# +# This script creates a bridge (default ${netdev}), adds a device +# (defaults to the device on the default gateway route) to it, copies +# the IP addresses from the device to the bridge and adjusts the routes +# accordingly. +# +# If all goes well, this should ensure that networking stays up. +# However, some configurations are upset by this, especially +# NFS roots. If the bridged setup does not meet your needs, +# configure a different script, for example using routing instead. +# +# Usage: +# +# network-bridge (start|stop|status) {VAR=VAL}* +# +# Vars: +# +# bridge The bridge to use (default ${netdev}). +# netdev The interface to add to the bridge (default gateway device). +# antispoof Whether to use iptables to prevent spoofing (default no). +# +# Internal Vars: +# pdev="p${netdev}" +# tdev=tmpbridge +# +# start: +# Creates the bridge as tdev +# Copies the IP and MAC addresses from pdev to bridge +# Renames netdev to be pdev +# Renames tdev to bridge +# Enslaves pdev to bridge +# +# stop: +# Removes pdev from the bridge +# Transfers addresses, routes from bridge to pdev +# Renames bridge to tdev +# Renames pdev to netdev +# Deletes tdev +# +# status: +# Print addresses, interfaces, routes +# +#============================================================================ + + +dir=$(dirname "$0") +. "$dir/xen-script-common.sh" +. "$dir/xen-network-common.sh" + +findCommand "$@" +evalVariables "$@" + +is_network_root () { + local rootfs=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $3; }}' /etc/mtab) + local rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' /etc/mtab) + + [[ "$rootfs" =~ "^nfs" ]] || [[ "$rootopts" =~ "_netdev" ]] && has_nfsroot=1 || has_nfsroot=0 + if [ $has_nfsroot -eq 1 ]; then + local bparms=$(cat /proc/cmdline) + for p in $bparms; do + local ipaddr=$(echo $p | awk /nfsroot=/'{ print substr($1,9,index($1,":")-9) }') + if [ "$ipaddr" != "" ]; then + local nfsdev=$(ip route get $ipaddr | awk /$ipaddr/'{ print $3 }') + [[ "$nfsdev" == "$netdev" ]] && return 0 || return 1 + fi + done + fi + return 1 +} + +find_alt_device () { + local interf=$1 + local prefix=${interf%[[:digit:]]} + local ifs=$(ip link show | grep " $prefix" |\ + gawk '{ printf ("%s",substr($2,1,length($2)-1)) }' |\ + sed s/$interf//) + echo "$ifs" +} + +netdev=${netdev:-$(ip route list 0.0.0.0/0 | \ + sed 's/.*dev \([a-z]\+[0-9]\+\).*$/\1/')} +if is_network_root ; then + altdevs=$(find_alt_device $netdev) + for netdev in $altdevs; do break; done + if [ -z "$netdev" ]; then + [ -x /usr/bin/logger ] && /usr/bin/logger "network-bridge: bridging not supported on network root; not starting" + exit + fi +fi +netdev=${netdev:-eth0} +bridge=${bridge:-${netdev}} +antispoof=${antispoof:-no} + +pdev="p${netdev}" +tdev=tmpbridge + +get_ip_info() { + addr_pfx=`ip addr show dev $1 | egrep '^ *inet' | sed -e 's/ *inet //' -e 's/ .*//'` + gateway=`ip route show dev $1 | fgrep default | sed 's/default via //'` +} + +do_ifup() { + if [ $1 != "${netdev}" ] || ! ifup $1 ; then + if [ -n "$addr_pfx" ] ; then + # use the info from get_ip_info() + ip addr flush $1 + ip addr add ${addr_pfx} dev $1 + ip link set dev $1 up + [ -n "$gateway" ] && ip route add default via ${gateway} + fi + fi +} + +# Usage: transfer_addrs src dst +# Copy all IP addresses (including aliases) from device $src to device $dst. +transfer_addrs () { + local src=$1 + local dst=$2 + # Don't bother if $dst already has IP addresses. + if ip addr show dev ${dst} | egrep -q '^ *inet ' ; then + return + fi + # Address lines start with 'inet' and have the device in them. + # Replace 'inet' with 'ip addr add' and change the device name $src + # to 'dev $src'. + ip addr show dev ${src} | egrep '^ *inet ' | sed -e " +s/inet/ip addr add/ +s@\([0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+/[0-9]\+\)@\1@ +s/${src}/dev ${dst} label ${dst}/ +s/secondary// +" | sh -e + # Remove automatic routes on destination device + ip route list | sed -ne " +/dev ${dst}\( \|$\)/ { + s/^/ip route del / + p +}" | sh -e +} + +# Usage: transfer_routes src dst +# Get all IP routes to device $src, delete them, and +# add the same routes to device $dst. +# The original routes have to be deleted, otherwise adding them +# for $dst fails (duplicate routes). +transfer_routes () { + local src=$1 + local dst=$2 + # List all routes and grep the ones with $src in. + # Stick 'ip route del' on the front to delete. + # Change $src to $dst and use 'ip route add' to add. + ip route list | sed -ne " +/dev ${src}\( \|$\)/ { + h + s/^/ip route del / + P + g + s/${src}/${dst}/ + s/^/ip route add / + P + d +}" | sh -e +} + + +## +# link_exists interface +# +# Returns 0 if the interface named exists (whether up or down), 1 otherwise. +# +link_exists() +{ + if ip link show "$1" >/dev/null 2>/dev/null + then + return 0 + else + return 1 + fi +} + +# Set the default forwarding policy for $dev to drop. +# Allow forwarding to the bridge. +antispoofing () { + iptables -P FORWARD DROP + iptables -F FORWARD + iptables -A FORWARD -m physdev --physdev-in ${pdev} -j ACCEPT +} + +find_active_vlans() { + local netdev=$1 + local vlan + local vlans + vlans="" + for vifcfg in /etc/sysconfig/network/ifcfg-vlan* ; do + vlan=${vifcfg/*\/ifcfg-} + if [ "$vlan" = "vlan*" ]; then + continue + fi + . $vifcfg + etherdevice="$ETHERDEVICE" + if [ -x /sbin/getcfg-interface ]; then + etherdevice=$(/sbin/getcfg-interface "$ETHERDEVICE") + fi + if [ "$ETHERDEVICE" = "$netdev" ] || [ "$etherdevice" = "$netdev" ] ; then + link_exists "$vlan" && vlans="$vlans $vlan" + fi + done + echo "$vlans" +} + +# Usage: show_status dev bridge +# Print ifconfig and routes. +show_status () { + local dev=$1 + local bridge=$2 + + echo '============================================================' + ip addr show ${dev} + ip addr show ${bridge} + echo ' ' + brctl show ${bridge} + echo ' ' + ip route list + echo ' ' + route -n + echo '============================================================' +} + +op_start () { + if [ "${bridge}" = "null" ] ; then + return + fi + + if link_exists "$pdev"; then + # The device is already up. + return + fi + + local bonded="" + [ -e /sys/class/net/${netdev}/bonding ] && bonded="yes" + + vlans=$(find_active_vlans "${netdev}") + for vlan in $vlans ; do ifdown $vlan ; done + + create_bridge ${tdev} + + # Record creation of bridge in /dev/shm/sysconfig/xenbridges so other + # tools, e.g. yast2 lan, know that Xen bridging is active. + [ -d /dev/shm/sysconfig/xenbridges ] || mkdir /dev/shm/sysconfig/xenbridges + touch /dev/shm/sysconfig/xenbridges/${bridge} + + preiftransfer ${netdev} + transfer_addrs ${netdev} ${tdev} + # Remember slaves for bonding interface. + if [ -e /sys/class/net/${netdev}/bonding/slaves ]; then + slaves=`cat /sys/class/net/${netdev}/bonding/slaves` + fi + # Remember the IP details for do_ifup. + get_ip_info ${netdev} + if ! ifdown ${netdev}; then + ip link set ${netdev} down + ip addr flush ${netdev} + fi + + if [ "x${bonded}" = "xyes" ] + then + ip link set ${tdev} name ${bridge} + ln -sf /etc/sysconfig/network/ifcfg-${netdev} /etc/sysconfig/network/ifcfg-${pdev} + ifup ${pdev} + local gw=`ip route show dev ${pdev} | fgrep default | sed 's/default via //'` + ip addr flush ${pdev} + rm -f /etc/sysconfig/network/ifcfg-${pdev} + brctl addif ${bridge} ${pdev} + ip link set ${bridge} up + [ -n "$gw" ] && ip route add default via ${gw} + else + ip link set ${netdev} name ${pdev} + ip link set ${tdev} name ${bridge} + + setup_bridge_port ${pdev} + + # Restore slaves + if [ -n "${slaves}" ]; then + ip link set ${pdev} up + ifenslave ${pdev} ${slaves} + fi + add_to_bridge2 ${bridge} ${pdev} + do_ifup ${bridge} + fi + + for vlan in $vlans ; do ifup $vlan ; done + + if [ ${antispoof} = 'yes' ] ; then + antispoofing + fi +} + +op_stop () { + if [ "${bridge}" = "null" ]; then + return + fi + if ! link_exists "$bridge"; then + return + fi + + vlans=$(find_active_vlans "${netdev}") + for vlan in $vlans ; do ifdown $vlan ; done + + transfer_addrs ${bridge} ${pdev} + if ! ifdown ${bridge}; then + get_ip_info ${bridge} + ip link set ${pdev} down + ip addr flush ${bridge} + + brctl delif ${bridge} ${pdev} + ip link set ${bridge} down + + ip link set ${bridge} name ${tdev} + brctl delbr ${tdev} + fi + ip link set ${pdev} down + ip link set ${pdev} name ${netdev} + do_ifup ${netdev} + + # Remove record of bridge from /dev/shm/sysconfig/xenbridges ... + rm -f /dev/shm/sysconfig/xenbridges/${bridge} + # ... and directory itself if empty + if [ -z "$(ls -A /dev/shm/sysconfig/xenbridges 2>/dev/null)" ]; then + rmdir /dev/shm/sysconfig/xenbridges + fi + + for vlan in $vlans ; do ifup $vlan ; done +} + +# adds $dev to $bridge but waits for $dev to be in running state first +add_to_bridge2() { + local bridge=$1 + local dev=$2 + local maxtries=10 + + echo -n "Waiting for ${dev} to negotiate link." + ip link set ${dev} up + for i in `seq ${maxtries}` ; do + if ifconfig ${dev} | grep -q RUNNING ; then + break + else + echo -n '.' + sleep 1 + fi + done + + if [ ${i} -eq ${maxtries} ] ; then echo -n '(link isnt in running state)' ; fi + echo + + add_to_bridge ${bridge} ${dev} +} + +case "$command" in + start) + op_start + ;; + + stop) + op_stop + ;; + + status) + show_status ${netdev} ${bridge} + ;; + + *) + echo "Unknown command: $command" >&2 + echo 'Valid commands are: start, stop, status' >&2 + exit 1 +esac diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/network-nat b/os-plugins/plugins/xen/files/xen.examples/scripts/network-nat new file mode 100755 index 00000000..e20c0d03 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/network-nat @@ -0,0 +1,125 @@ +#!/bin/bash +#============================================================================ +# Default Xen network start/stop script when using NAT. +# Xend calls a network script when it starts. +# The script name to use is defined in /etc/xen/xend-config.sxp +# in the network-script field. +# +# Usage: +# +# network-nat (start|stop|status) {VAR=VAL}* +# +# Vars: +# +# netdev The gateway interface (default eth0). +# antispoof Whether to use iptables to prevent spoofing (default no). +# dhcp Whether to alter the local DHCP configuration (default no). +# +#============================================================================ + +dir=$(dirname "$0") +. "$dir/xen-script-common.sh" +. "$dir/xen-network-common.sh" + +findCommand "$@" +evalVariables "$@" + +netdev=${netdev:-eth0} +# antispoofing not yet implemented +antispoof=${antispoof:-no} + +# turn on dhcp feature by default if dhcpd is installed +if [ -f /etc/dhcpd.conf ] +then + dhcp=${dhcp:-yes} +else + dhcp=${dhcp:-no} +fi + + +if [ "$dhcp" != 'no' ] +then + dhcpd_conf_file=$(find_dhcpd_conf_file) + dhcpd_init_file=$(find_dhcpd_init_file) + if [ -z "$dhcpd_conf_file" ] || [ -z "$dhcpd_init_file" ] + then + echo 'Failed to find dhcpd configuration or init file.' >&2 + exit 1 + fi +fi + +domain_name=`cat /etc/resolv.conf | grep -v "#" | grep -E 'search|domain' -i | tail -n 1 | awk '{ print $2 }'` +nameserver=`cat /etc/resolv.conf | grep -v "#" | grep "nameserver" -i -m 1 | awk '{ print $2 }'` + +function dhcp_start() +{ + if ! grep -q "subnet 10.0.0.0" "$dhcpd_conf_file" + then + echo >>"$dhcpd_conf_file" "subnet 10.0.0.0 netmask 255.255.0.0 {\ + option domain-name \"$domain_name\";\ + option domain-name-servers $nameserver; }" + fi + + "$dhcpd_init_file" restart +} + + +function dhcp_stop() +{ + local tmpfile=$(mktemp) + grep -v "subnet 10.0.0.0" "$dhcpd_conf_file" >"$tmpfile" + if diff "$tmpfile" "$dhcpd_conf_file" >&/dev/null + then + rm "$tmpfile" + else + mv "$tmpfile" "$dhcpd_conf_file" + fi + + "$dhcpd_init_file" restart +} + + +op_start() { + echo 1 >/proc/sys/net/ipv4/ip_forward + iptables -t nat -A POSTROUTING -o ${netdev} -j MASQUERADE + iptables -P FORWARD ACCEPT + [ "$dhcp" != 'no' ] && dhcp_start +} + + +op_stop() { + [ "$dhcp" != 'no' ] && dhcp_stop + iptables -t nat -D POSTROUTING -o ${netdev} -j MASQUERADE + iptables -P FORWARD DROP +} + + +show_status() { + echo '============================================================' + ifconfig + echo ' ' + ip route list + echo ' ' + route -n + echo '============================================================' + +} + +case "$command" in + start) + op_start + ;; + + stop) + op_stop + ;; + + status) + show_status + ;; + + *) + echo "Unknown command: $command" >&2 + echo 'Valid commands are: start, stop, status' >&2 + exit 1 +esac diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/network-route b/os-plugins/plugins/xen/files/xen.examples/scripts/network-route new file mode 100755 index 00000000..4416316e --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/network-route @@ -0,0 +1,27 @@ +#!/bin/bash +#============================================================================ +# Default Xen network start/stop script. +# Xend calls a network script when it starts. +# The script name to use is defined in /etc/xen/xend-config.sxp +# in the network-script field. +# +# Usage: +# +# network-route (start|stop|status) {VAR=VAL}* +# +# Vars: +# +# netdev The gateway interface (default eth0). +# antispoof Whether to use iptables to prevent spoofing (default yes). +# +#============================================================================ + +dir=$(dirname "$0") +. "$dir/xen-script-common.sh" + +evalVariables "$@" + +netdev=${netdev:-eth0} + +echo 1 >/proc/sys/net/ipv4/ip_forward +echo 1 >/proc/sys/net/ipv4/conf/${netdev}/proxy_arp diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/set-lock b/os-plugins/plugins/xen/files/xen.examples/scripts/set-lock new file mode 120000 index 00000000..8bd35731 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/set-lock @@ -0,0 +1 @@ +vm-monitor \ No newline at end of file diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/vif-bridge b/os-plugins/plugins/xen/files/xen.examples/scripts/vif-bridge new file mode 100755 index 00000000..1b698d70 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/vif-bridge @@ -0,0 +1,100 @@ +#!/bin/bash +#============================================================================ +# /etc/xen/vif-bridge +# +# Script for configuring a vif in bridged mode. +# The hotplugging system will call this script if it is specified either in +# the device configuration given to Xend, or the default Xend configuration +# in /etc/xen/xend-config.sxp. If the script is specified in neither of those +# places, then this script is the default. +# +# Usage: +# vif-bridge (add|remove|online|offline) +# +# Environment vars: +# vif vif interface name (required). +# XENBUS_PATH path to this device's details in the XenStore (required). +# +# Read from the store: +# bridge bridge to add the vif to (optional). Defaults to searching for the +# bridge itself. +# ip list of IP networks for the vif, space-separated (optional). +# +# up: +# Enslaves the vif interface to the bridge and adds iptables rules +# for its ip addresses (if any). +# +# down: +# Removes the vif interface from the bridge and removes the iptables +# rules for its ip addresses (if any). +#============================================================================ + +dir=$(dirname "$0") +. "$dir/vif-common.sh" + +bridge=${bridge:-} +bridge=$(xenstore_read_default "$XENBUS_PATH/bridge" "$bridge") + +if [ -z "$bridge" ] +then + bridge=$(brctl show | cut -d " +" -f 2 | cut -f 1) + + if [ -z "$bridge" ] + then + fatal "Could not find bridge, and none was specified" + fi +else + # + # Old style bridge setup with netloop, used to have a bridge name + # of xenbrX, enslaving pethX and vif0.X, and then configuring + # eth0. + # + # New style bridge setup does not use netloop, so the bridge name + # is ethX and the physical device is enslaved pethX + # + # So if... + # + # - User asks for xenbrX + # - AND xenbrX doesn't exist + # - AND there is a ethX device which is a bridge + # + # ..then we translate xenbrX to ethX + # + # This lets old config files work without modification + # + if [ ! -e "/sys/class/net/$bridge" ] && [ -z "${bridge##xenbr*}" ] + then + if [ -e "/sys/class/net/eth${bridge#xenbr}/bridge" ] + then + bridge="eth${bridge#xenbr}" + fi + fi +fi + +RET=0 +ip link show $bridge 1>/dev/null 2>&1 || RET=1 +if [ "$RET" -eq 1 ] +then + fatal "Could not find bridge device $bridge" +fi + +case "$command" in + online) + setup_bridge_port "$vif" + add_to_bridge "$bridge" "$vif" + ;; + + offline) + do_without_error brctl delif "$bridge" "$vif" + do_without_error ifconfig "$vif" down + ;; +esac + +handle_iptable + +log debug "Successful vif-bridge $command for $vif, bridge $bridge." +if [ "$command" == "online" ] +then + success +fi diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/vif-common.sh b/os-plugins/plugins/xen/files/xen.examples/scripts/vif-common.sh new file mode 100644 index 00000000..fe483f9d --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/vif-common.sh @@ -0,0 +1,158 @@ +# +# Copyright (c) 2005 XenSource Ltd. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of version 2.1 of the GNU Lesser General Public +# License as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + + +dir=$(dirname "$0") +. "$dir/xen-hotplug-common.sh" +. "$dir/xen-network-common.sh" + +findCommand "$@" + +if [ "$command" != "online" ] && + [ "$command" != "offline" ] && + [ "$command" != "add" ] && + [ "$command" != "remove" ] +then + log err "Invalid command: $command" + exit 1 +fi + +case "$command" in + add | remove) + exit 0 + ;; +esac + + +# Parameters may be read from the environment, the command line arguments, and +# the store, with overriding in that order. The environment is given by the +# driver, the command line is given by the Xend global configuration, and +# store details are given by the per-domain or per-device configuration. + +evalVariables "$@" + +ip=${ip:-} +ip=$(xenstore_read_default "$XENBUS_PATH/ip" "$ip") + +# Check presence of compulsory args. +XENBUS_PATH="${XENBUS_PATH:?}" +vif="${vif:?}" + + +vifname=$(xenstore_read_default "$XENBUS_PATH/vifname" "") +if [ "$vifname" ] +then + if [ "$command" == "online" ] && ! ip link show "$vifname" >&/dev/null + then + do_or_die ip link set "$vif" name "$vifname" + fi + vif="$vifname" +fi + + +frob_iptable() +{ + if [ "$command" == "online" ] + then + local c="-I" + else + local c="-D" + fi + + iptables "$c" FORWARD -m physdev --physdev-in "$vif" "$@" -j ACCEPT \ + 2>/dev/null && + iptables "$c" FORWARD -m state --state RELATED,ESTABLISHED -m physdev \ + --physdev-out "$vif" -j ACCEPT 2>/dev/null + + if [ "$command" == "online" ] && [ $? ] + then + log err "iptables setup failed. This may affect guest networking." + fi +} + + +## +# Add or remove the appropriate entries in the iptables. With antispoofing +# turned on, we have to explicitly allow packets to the interface, regardless +# of the ip setting. If ip is set, then we additionally restrict the packets +# to those coming from the specified networks, though we allow DHCP requests +# as well. +# +handle_iptable() +{ + # Check for a working iptables installation. Checking for the iptables + # binary is not sufficient, because the user may not have the appropriate + # modules installed. If iptables is not working, then there's no need to do + # anything with it, so we can just return. + if ! iptables -L -n >&/dev/null + then + return + fi + + claim_lock "iptables" + + if [ "$ip" != "" ] + then + local addr + for addr in $ip + do + frob_iptable -s "$addr" + done + + # Always allow the domain to talk to a DHCP server. + frob_iptable -p udp --sport 68 --dport 67 + else + # No IP addresses have been specified, so allow anything. + frob_iptable + fi + + release_lock "iptables" +} + + +## +# ip_of interface +# +# Print the IP address currently in use at the given interface, or nothing if +# the interface is not up. +# +ip_of() +{ + ip addr show "$1" | awk "/^.*inet.*$1\$/{print \$2}" | sed -n '1 s,/.*,,p' +} + + +## +# dom0_ip +# +# Print the IP address of the interface in dom0 through which we are routing. +# This is the IP address on the interface specified as "netdev" as a parameter +# to these scripts, or eth0 by default. This function will call fatal if no +# such interface could be found. +# +dom0_ip() +{ + local nd=${netdev:-eth0} + local result=$(ip_of "$nd") + if [ -z "$result" ] + then + fatal +"$netdev is not up. Bring it up or specify another interface with " \ +"netdev= as a parameter to $0." + fi + echo "$result" +} diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/vif-nat b/os-plugins/plugins/xen/files/xen.examples/scripts/vif-nat new file mode 100755 index 00000000..75bdf5c4 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/vif-nat @@ -0,0 +1,192 @@ +#!/bin/bash +#============================================================================ +# /etc/xen/vif-nat +# +# Script for configuring a vif in routed-nat mode. +# The hotplugging system will call this script if it is specified either in +# the device configuration given to Xend, or the default Xend configuration +# in /etc/xen/xend-config.sxp. If the script is specified in neither of those +# places, then vif-bridge is the default. +# +# Usage: +# vif-nat (add|remove|online|offline) +# +# Environment vars: +# vif vif interface name (required). +# XENBUS_PATH path to this device's details in the XenStore (required). +# +# Parameters: +# dhcp Whether to alter the local DHCP configuration to include this +# new host (default no). +# +# Read from the store: +# ip list of IP networks for the vif, space-separated (default given in +# this script). +#============================================================================ + + +dir=$(dirname "$0") +. "$dir/vif-common.sh" + +# turn on dhcp feature by default if dhcpd is installed +if [ -f /etc/dhcpd.conf ] +then + dhcp=${dhcp:-yes} +else + dhcp=${dhcp:-no} +fi + +if [ "$dhcp" != 'no' ] +then + dhcpd_conf_file=$(find_dhcpd_conf_file) + dhcpd_init_file=$(find_dhcpd_init_file) + dhcpd_arg_file=$(find_dhcpd_arg_file) + if [ -z "$dhcpd_conf_file" ] || [ -z "$dhcpd_init_file" ] || [ -z "$dhcpd_arg_file" ] + then + echo 'Failed to find dhcpd configuration or init or args file.' >&2 + exit 1 + fi +fi + + +domid=$(xenstore_read "$XENBUS_PATH/frontend-id") +vifid=$(xenstore_read "$XENBUS_PATH/handle") +vifid=$(( $vifid + 1 )) + + +ip_from_dom() +{ + local domid1=$(( $domid / 256 )) + local domid2=$(( $domid % 256 )) + + echo "10.$domid1.$domid2.$vifid/16" +} + + +routing_ip() +{ + echo $(echo $1 | awk -F. '{print $1"."$2"."$3"."$4 + 127}') +} + + +dotted_quad() +{ + echo\ + $(( ($1 & 0xFF000000) >> 24))\ +.$(( ($1 & 0x00FF0000) >> 16))\ +.$(( ($1 & 0x0000FF00) >> 8 ))\ +.$(( $1 & 0x000000FF )) +} + + +if [ "$ip" = "" ] +then + ip=$(ip_from_dom) +fi + +router_ip=$(routing_ip "$ip") + +# Split the given IP/bits pair. +vif_ip=`echo ${ip} | awk -F/ '{print $1}'` + +hostname=$(xenstore_read "$XENBUS_PATH/domain" | tr -- '_.:/+' '-----') +if [ "$vifid" != "1" ] +then + hostname="$hostname-$vifid" +fi + +dhcparg_remove_entry() +{ + local tmpfile=$(mktemp) + sed -e "s/$vif //" "$dhcpd_arg_file" >"$tmpfile" + if diff "$tmpfile" "$dhcpd_arg_file" >/dev/null + then + rm "$tmpfile" + else + mv "$tmpfile" "$dhcpd_arg_file" + fi +} + +dhcparg_add_entry() +{ + dhcparg_remove_entry + local tmpfile=$(mktemp) + # handle Red Hat, SUSE, and Debian styles, with or without quotes + sed -e 's/^DHCPDARGS="*\([^"]*\)"*/DHCPDARGS="\1'"$vif "'"/' \ + "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file" + sed -e 's/^DHCPD_INTERFACE="*\([^"]*\)"*/DHCPD_INTERFACE="\1'"$vif "'"/' \ + "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file" + sed -e 's/^INTERFACES="*\([^"]*\)"*/INTERFACES="\1'"$vif "'"/' \ + "$dhcpd_arg_file" >"$tmpfile" && mv "$tmpfile" "$dhcpd_arg_file" + rm -f "$tmpfile" +} + +dhcp_remove_entry() +{ + local tmpfile=$(mktemp) + grep -v "host $hostname" "$dhcpd_conf_file" >"$tmpfile" + if diff "$tmpfile" "$dhcpd_conf_file" >/dev/null + then + rm "$tmpfile" + else + mv "$tmpfile" "$dhcpd_conf_file" + fi + dhcparg_remove_entry +} + + +dhcp_up() +{ + claim_lock "vif-nat-dhcp" + dhcp_remove_entry + mac=$(xenstore_read "$XENBUS_PATH/mac") + echo >>"$dhcpd_conf_file" \ +"host $hostname { hardware ethernet $mac; fixed-address $vif_ip; option routers $router_ip; option host-name \"$hostname\"; }" + dhcparg_add_entry + release_lock "vif-nat-dhcp" + "$dhcpd_init_file" restart || true +} + + +dhcp_down() +{ + claim_lock "vif-nat-dhcp" + dhcp_remove_entry + release_lock "vif-nat-dhcp" + "$dhcpd_init_file" restart || true # We need to ignore failure because + # ISC dhcpd 3 borks if there is nothing + # for it to do, which is the case if + # the outgoing interface is not + # configured to offer leases and there + # are no vifs. +} + + +case "$command" in + online) + if ip route | grep -q "dev $vif" + then + log debug "$vif already up" + exit 0 + fi + + do_or_die ip link set "$vif" up arp on + do_or_die ip addr add "$router_ip" dev "$vif" + do_or_die ip route add "$vif_ip" dev "$vif" src "$router_ip" + echo 1 >/proc/sys/net/ipv4/conf/${vif}/proxy_arp + [ "$dhcp" != 'no' ] && dhcp_up + ;; + offline) + [ "$dhcp" != 'no' ] && dhcp_down + do_without_error ifconfig "$vif" down + ;; +esac + + +handle_iptable + +log debug "Successful vif-nat $command for $vif." +if [ "$command" = "online" ] +then + success +fi diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/vif-route b/os-plugins/plugins/xen/files/xen.examples/scripts/vif-route new file mode 100755 index 00000000..f5fd88ed --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/vif-route @@ -0,0 +1,56 @@ +#!/bin/bash +#============================================================================ +# /etc/xen/vif-route +# +# Script for configuring a vif in routed mode. +# The hotplugging system will call this script if it is specified either in +# the device configuration given to Xend, or the default Xend configuration +# in /etc/xen/xend-config.sxp. If the script is specified in neither of those +# places, then vif-bridge is the default. +# +# Usage: +# vif-route (add|remove|online|offline) +# +# Environment vars: +# vif vif interface name (required). +# XENBUS_PATH path to this device's details in the XenStore (required). +# +# Read from the store: +# ip list of IP networks for the vif, space-separated (default given in +# this script). +#============================================================================ + +dir=$(dirname "$0") +. "$dir/vif-common.sh" + +main_ip=$(dom0_ip) + +case "$command" in + online) + ifconfig ${vif} ${main_ip} netmask 255.255.255.255 up + echo 1 >/proc/sys/net/ipv4/conf/${vif}/proxy_arp + ipcmd='add' + cmdprefix='' + ;; + offline) + do_without_error ifdown ${vif} + ipcmd='del' + cmdprefix='do_without_error' + ;; +esac + +if [ "${ip}" ] ; then + # If we've been given a list of IP addresses, then add routes from dom0 to + # the guest using those addresses. + for addr in ${ip} ; do + ${cmdprefix} ip route ${ipcmd} ${addr} dev ${vif} src ${main_ip} + done +fi + +handle_iptable + +log debug "Successful vif-route $command for $vif." +if [ "$command" = "online" ] +then + success +fi diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/vm-monitor b/os-plugins/plugins/xen/files/xen.examples/scripts/vm-monitor new file mode 100755 index 00000000..1c9a1791 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/vm-monitor @@ -0,0 +1,41 @@ +#!/bin/bash + +basedir=$(dirname "$0") +HA_TICK=2 + +monitor() { + local path=$1 + local name=$2 + local uuid=$3 + local host=$4 + local count=0 + path=$path/lock + + while : + do + echo "name=$name uuid=$uuid host=$host count=$count" > $path + count=$(($count+1)) + sleep $HA_TICK + done& +} + +create_lock() { + local path=$1/lock + local rc=0 + + [ -f $path ] || touch $path + flock -x -w $HA_TICK $path $basedir/vm-monitor $* + rc=$? + if [ $rc -eq 1 ]; then + echo `cat $path` + exit 1 + else + exit $rc + fi +} + +if [ $0 = "$basedir/set-lock" ]; then + create_lock $* +elif [ $0 = "$basedir/vm-monitor" ]; then + monitor $* +fi diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/vscsi b/os-plugins/plugins/xen/files/xen.examples/scripts/vscsi new file mode 100755 index 00000000..5ac26147 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/vscsi @@ -0,0 +1,22 @@ +#!/bin/sh +# +# Copyright (c) 2007, FUJITSU Limited +# Based on the block scripts code. +# + +dir=$(dirname "$0") +. "$dir/xen-hotplug-common.sh" + +findCommand "$@" + +case "$command" in + add) + success + ;; + remove) + # TODO + exit 0 + ;; +esac + +exit 0 diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/vtpm b/os-plugins/plugins/xen/files/xen.examples/scripts/vtpm new file mode 100755 index 00000000..38a4532f --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/vtpm @@ -0,0 +1,22 @@ +#!/bin/bash + +dir=$(dirname "$0") +. "$dir/vtpm-hotplug-common.sh" + +vtpm_fatal_error=0 + +case "$command" in + add) + vtpm_create_instance + ;; + remove) + vtpm_remove_instance + ;; +esac + +if [ $vtpm_fatal_error -eq 0 ]; then + log debug "Successful vTPM operation '$command'." + success +else + fatal "Error while executing vTPM operation '$command'." +fi diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-common.sh b/os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-common.sh new file mode 100644 index 00000000..a45868ee --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-common.sh @@ -0,0 +1,448 @@ +# +# Copyright (c) 2005 IBM Corporation +# Copyright (c) 2005 XenSource Ltd. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of version 2.1 of the GNU Lesser General Public +# License as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +dir=$(dirname "$0") +. "$dir/logging.sh" +. "$dir/locking.sh" + +VTPMDB="/var/vtpm/vtpm.db" + +#In the vtpm-impl file some commands should be defined: +# vtpm_create, vtpm_setup, vtpm_start, etc. (see below) +if [ -r "$dir/vtpm-impl.alt" ]; then + . "$dir/vtpm-impl.alt" +elif [ -r "$dir/vtpm-impl" ]; then + . "$dir/vtpm-impl" +else + function vtpm_create () { + true + } + function vtpm_setup() { + true + } + function vtpm_start() { + true + } + function vtpm_suspend() { + true + } + function vtpm_resume() { + true + } + function vtpm_delete() { + true + } + function vtpm_migrate() { + echo "Error: vTPM migration accross machines not implemented." + } + function vtpm_migrate_local() { + echo "Error: local vTPM migration not supported" + } + function vtpm_migrate_recover() { + true + } +fi + + +#Find the instance number for the vtpm given the name of the domain +# Parameters +# - vmname : the name of the vm +# Return value +# Returns '0' if instance number could not be found, otherwise +# it returns the instance number in the variable 'instance' +function vtpmdb_find_instance () { + local vmname ret instance + vmname=$1 + ret=0 + + instance=$(cat $VTPMDB | \ + awk -vvmname=$vmname \ + '{ \ + if ( 1 != index($1,"#")) { \ + if ( $1 == vmname ) { \ + print $2; \ + exit; \ + } \ + } \ + }') + if [ "$instance" != "" ]; then + ret=$instance + fi + echo "$ret" +} + + +# Check whether a particular instance number is still available +# returns "0" if it is not available, "1" otherwise. +function vtpmdb_is_free_instancenum () { + local instance instances avail i + instance=$1 + avail=1 + #Allowed instance number range: 1-255 + if [ $instance -eq 0 -o $instance -gt 255 ]; then + avail=0 + else + instances=$(cat $VTPMDB | \ + gawk \ + '{ \ + if (1 != index($1,"#")) { \ + printf("%s ",$2); \ + } \ + }') + for i in $instances; do + if [ $i -eq $instance ]; then + avail=0 + break + fi + done + fi + echo "$avail" +} + + +# Get an available instance number given the database +# Returns an unused instance number +function vtpmdb_get_free_instancenum () { + local ctr instances don found + instances=$(cat $VTPMDB | \ + gawk \ + '{ \ + if (1 != index($1,"#")) { \ + printf("%s ",$2); \ + } \ + }') + ctr=1 + don=0 + while [ $don -eq 0 ]; do + found=0 + for i in $instances; do + if [ $i -eq $ctr ]; then + found=1; + break; + fi + done + + if [ $found -eq 0 ]; then + don=1 + break + fi + let ctr=ctr+1 + done + echo "$ctr" +} + + +# Add a domain name and instance number to the DB file +function vtpmdb_add_instance () { + local res vmname inst + vmname=$1 + inst=$2 + + if [ ! -f $VTPMDB ]; then + echo "#Database for VM to vTPM association" > $VTPMDB + echo "#1st column: domain name" >> $VTPMDB + echo "#2nd column: TPM instance number" >> $VTPMDB + fi + res=$(vtpmdb_validate_entry $vmname $inst) + if [ $res -eq 0 ]; then + echo "$vmname $inst" >> $VTPMDB + fi +} + + +#Validate whether an entry is the same as passed to this +#function +function vtpmdb_validate_entry () { + local res rc vmname inst + rc=0 + vmname=$1 + inst=$2 + + res=$(cat $VTPMDB | \ + gawk -vvmname=$vmname \ + -vinst=$inst \ + '{ \ + if ( 1 == index($1,"#")) {\ + } else \ + if ( $1 == vmname && \ + $2 == inst) { \ + printf("1"); \ + exit; \ + } else \ + if ( $1 == vmname || \ + $2 == inst) { \ + printf("2"); \ + exit; \ + } \ + }') + + if [ "$res" == "1" ]; then + rc=1 + elif [ "$res" == "2" ]; then + rc=2 + fi + echo "$rc" +} + + +#Remove an entry from the vTPM database given its domain name +#and instance number +function vtpmdb_remove_entry () { + local vmname instance VTPMDB_TMP + vmname=$1 + instance=$2 + VTPMDB_TMP="$VTPMDB".tmp + + $(cat $VTPMDB | \ + gawk -vvmname=$vmname \ + '{ \ + if ( $1 != vmname ) { \ + print $0; \ + } \ + '} > $VTPMDB_TMP) + if [ -e $VTPMDB_TMP ]; then + mv -f $VTPMDB_TMP $VTPMDB + vtpm_delete $instance + else + log err "Error creating temporary file '$VTPMDB_TMP'." + fi +} + + +# Find the reason for the creation of this device: +# Returns 'resume' or 'create' +function vtpm_get_create_reason () { + local resume + resume=$(xenstore_read $XENBUS_PATH/resume) + if [ "$resume" == "True" ]; then + echo "resume" + else + echo "create" + fi +} + + +#Create a vTPM instance +# If no entry in the TPM database is found, the instance is +# created and an entry added to the database. +function vtpm_create_instance () { + local res instance domname reason uuid + uuid=$(xenstore_read "$XENBUS_PATH"/uuid) + reason=$(vtpm_get_create_reason) + + claim_lock vtpmdb + + instance="0" + + if [ "$uuid" != "" ]; then + instance=$(vtpmdb_find_instance $uuid) + fi + if [ "$instance" == "0" ]; then + domname=$(xenstore_read "$XENBUS_PATH"/domain) + instance=$(vtpmdb_find_instance $domname) + fi + + if [ "$instance" == "0" -a "$reason" != "create" ]; then + release_lock vtpmdb + return + fi + + if [ "$instance" == "0" ]; then + #Try to give the preferred instance to the domain + instance=$(xenstore_read "$XENBUS_PATH"/pref_instance) + if [ "$instance" != "" ]; then + res=$(vtpmdb_is_free_instancenum $instance) + if [ $res -eq 0 ]; then + instance=$(vtpmdb_get_free_instancenum) + fi + else + instance=$(vtpmdb_get_free_instancenum) + fi + + vtpm_create $instance + + if [ $vtpm_fatal_error -eq 0 ]; then + if [ "$uuid" != "" ]; then + vtpmdb_add_instance $uuid $instance + else + vtpmdb_add_instance $domname $instance + fi + fi + else + if [ "$reason" == "resume" ]; then + vtpm_resume $instance + else + vtpm_start $instance + fi + fi + + release_lock vtpmdb + + xenstore_write $XENBUS_PATH/instance $instance +} + + +#Remove an instance when a VM is terminating or suspending. +#Since it is assumed that the VM will appear again, the +#entry is kept in the VTPMDB file. +function vtpm_remove_instance () { + local instance reason domname uuid + #Stop script execution quietly if path does not exist (anymore) + xenstore-exists "$XENBUS_PATH"/domain + uuid=$(xenstore_read "$XENBUS_PATH"/uuid) + + claim_lock vtpmdb + + instance="0" + + if [ "$uuid" != "" ]; then + instance=$(vtpmdb_find_instance $uuid) + fi + + if [ "$instance" == "0" ]; then + domname=$(xenstore_read "$XENBUS_PATH"/domain) + instance=$(vtpmdb_find_instance $domname) + fi + + if [ "$instance" != "0" ]; then + vtpm_suspend $instance + fi + + release_lock vtpmdb +} + + +#Remove an entry in the VTPMDB file given the domain's name +#1st parameter: The name of the domain +function vtpm_delete_instance () { + local instance + + claim_lock vtpmdb + + instance=$(vtpmdb_find_instance $1) + if [ "$instance" != "0" ]; then + vtpmdb_remove_entry $1 $instance + fi + + release_lock vtpmdb +} + +# Determine whether the given address is local to this machine +# Return values: +# "-1" : the given machine name is invalid +# "0" : this is not an address of this machine +# "1" : this is an address local to this machine +function vtpm_isLocalAddress() { + local addr res + addr=$(ping $1 -c 1 | \ + gawk '{ print substr($3,2,length($3)-2); exit }') + if [ "$addr" == "" ]; then + echo "-1" + return + fi + res=$(ifconfig | grep "inet addr" | \ + gawk -vaddr=$addr \ + '{ \ + if ( addr == substr($2, 6)) {\ + print "1"; \ + } \ + }' \ + ) + if [ "$res" == "" ]; then + echo "0" + return + fi + echo "1" +} + +# Perform a migration step. This function differentiates between migration +# to the local host or to a remote machine. +# Parameters: +# 1st: destination host to migrate to +# 2nd: name of the domain to migrate +# 3rd: the migration step to perform +function vtpm_migration_step() { + local res=$(vtpm_isLocalAddress $1) + if [ "$res" == "0" ]; then + vtpm_migrate $1 $2 $3 + else + vtpm_migrate_local + fi +} + +# Recover from migration due to an error. This function differentiates +# between migration to the local host or to a remote machine. +# Parameters: +# 1st: destination host the migration was going to +# 2nd: name of the domain that was to be migrated +# 3rd: the last successful migration step that was done +function vtpm_recover() { + local res + res=$(vtpm_isLocalAddress $1) + if [ "$res" == "0" ]; then + vtpm_migrate_recover $1 $2 $3 + fi +} + + +#Determine the domain id given a domain's name. +#1st parameter: name of the domain +#return value: domain id or -1 if domain id could not be determined +function vtpm_domid_from_name () { + local id name ids + ids=$(xenstore-list /local/domain) + for id in $ids; do + name=$(xenstore-read /local/domain/$id/name) + if [ "$name" == "$1" ]; then + echo "$id" + return + fi + done + echo "-1" +} + +#Determine the virtual TPM's instance number using the domain ID. +#1st parm: domain ID +function vtpm_uuid_by_domid() { + echo $(xenstore-read /local/domain/0/backend/vtpm/$1/0/uuid) +} + + +# Determine the vTPM's UUID by the name of the VM +function vtpm_uuid_from_vmname() { + local domid=$(vtpm_domid_from_name $1) + if [ "$domid" != "-1" ]; then + echo $(vtpm_uuid_by_domid $domid) + return + fi + echo "" +} + +#Add a virtual TPM instance number and its associated domain name +#to the VTPMDB file and activate usage of this virtual TPM instance +#by writing the instance number into the xenstore +#1st parm: name of virtual machine +#2nd parm: instance of associated virtual TPM +function vtpm_add_and_activate() { + local domid=$(vtpm_domid_from_name $1) + local vtpm_uuid=$(vtpm_uuid_from_vmname $1) + if [ "$vtpm_uuid" != "" -a "$domid" != "-1" ]; then + vtpmdb_add_instance $vtpm_uuid $2 + xenstore-write backend/vtpm/$domid/0/instance $2 + fi +} diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-delete b/os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-delete new file mode 100755 index 00000000..b75b95bf --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-delete @@ -0,0 +1,18 @@ +#!/bin/bash + +# This scripts must be called the following way: +# vtpm-delete +# or +# vtpm-delete --vmname + +dir=$(dirname "$0") +. "$dir/vtpm-common.sh" + +if [ "$1" == "--vmname" ]; then + vtpm_uuid=$(vtpm_uuid_from_vmname $2) + if [ "$vtpm_uuid" != "" ];then + vtpm_delete_instance $vtpm_uuid + fi +else + vtpm_delete_instance $1 +fi diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-hotplug-common.sh b/os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-hotplug-common.sh new file mode 100644 index 00000000..9fd35e74 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-hotplug-common.sh @@ -0,0 +1,35 @@ +# +# Copyright (c) 2005 IBM Corporation +# Copyright (c) 2005 XenSource Ltd. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of version 2.1 of the GNU Lesser General Public +# License as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +dir=$(dirname "$0") +. "$dir/xen-hotplug-common.sh" + +findCommand "$@" +if [ "$command" != "online" ] && + [ "$command" != "offline" ] && + [ "$command" != "add" ] && + [ "$command" != "remove" ] +then + log err "Invalid command: $command" + exit 1 +fi + + +XENBUS_PATH="${XENBUS_PATH:?}" + +. "$dir/vtpm-common.sh" diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-impl b/os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-impl new file mode 100644 index 00000000..4f9a1fd8 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-impl @@ -0,0 +1,208 @@ +#!/bin/bash +# =================================================================== +# +# Copyright (c) 2005, Intel Corp. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following +# disclaimer in the documentation and/or other materials provided +# with the distribution. +# * Neither the name of Intel Corporation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +# OF THE POSSIBILITY OF SUCH DAMAGE. +# =================================================================== + +# | SRC | TAG | CMD SIZE | ORD |mtype|strt +TPM_CMD_OPEN=\\x00\\x00\\x00\\x00\\x01\\xc1\\x00\\x00\\x00\\x11\\x01\\x00\\x00\\x01\\x01\\x01 +TPM_CMD_RESM=\\x00\\x00\\x00\\x00\\x01\\xc1\\x00\\x00\\x00\\x11\\x01\\x00\\x00\\x01\\x01\\x02 +TPM_CMD_CLOS=\\x00\\x00\\x00\\x00\\x01\\xc1\\x00\\x00\\x00\\x0e\\x01\\x00\\x00\\x02 +TPM_CMD_DELE=\\x00\\x00\\x00\\x00\\x01\\xc1\\x00\\x00\\x00\\x0e\\x01\\x00\\x00\\x03 + +TPM_TYPE_PVM=\\x01 +TPM_TYPE_HVM=\\x02 + +TPM_SUCCESS=00000000 + +TX_VTPM_MANAGER=/var/vtpm/fifos/from_console.fifo +RX_VTPM_MANAGER=/var/vtpm/fifos/to_console.fifo + +VTPM_MIG=/usr/bin/vtpm_migrator + +# -------------------- Helpers for binary streams ----------- + +function str_to_hex32() { + printf "%0.8x" $1 +} + +function hex32_to_bin() { + local inst=$(str_to_hex32 $1); + + local n1=`echo $inst | sed 's/\(..\)....../\\\\x\1/'` + local n2=`echo $inst | sed 's/..\(..\)..../\\\\x\1/'` + local n3=`echo $inst | sed 's/....\(..\)../\\\\x\1/'` + local n4=`echo $inst | sed 's/......\(..\)/\\\\x\1/'` + + echo "$n1$n2$n3$n4" +} + +function vtpm_manager_cmd() { + local cmd=$1; + local inst=$2; + local inst_bin=$(hex32_to_bin $inst); + + claim_lock vtpm_mgr + + #send cmd to vtpm_manager + printf "$cmd$inst_bin" > $TX_VTPM_MANAGER + + #recv response + set +e + local resp_hex=`dd skip=10 bs=1 count=4 if=$RX_VTPM_MANAGER 2> /dev/null | xxd -ps` + set -e + + release_lock vtpm_mgr + + #return whether the command was successful + if [ $resp_hex -ne $TPM_SUCCESS ]; then + vtpm_fatal_error=1 + false + else + true + fi +} + +# Helper to get vm type to pass to vtpm_manager open/resume +function vtpm_get_type() { + local inst=$(xenstore_read $XENBUS_PATH/frontend-id) + local vm=$(xenstore_read /local/domain/$inst/vm) + if [ "$vm" != "" ]; then + local ostype=$(xenstore-read $vm/image/ostype) + if [ "$ostype" == "hvm" ]; then + echo $TPM_TYPE_HVM; + else + echo $TPM_TYPE_PVM; + fi + fi +} + +# ------------------ Command handlers ----------------- + +# Create new vtpm instance & set it up for use +function vtpm_create () { + # Creation is handled implicitly by the manager on first setup + # so just set it up for use + $(vtpm_start $1) +} + +# Setup vtpm instance for use. +function vtpm_start() { + local vmtype=$(vtpm_get_type); + $(vtpm_manager_cmd $TPM_CMD_OPEN$vmtype $1) +} + +function vtpm_resume() { + local vmtype=$(vtpm_get_type); + $(vtpm_manager_cmd $TPM_CMD_RESM$vmtype $1) +} + +# Reset the vtpm AKA clear PCRs +function vtpm_reset() { + #not used by current implemenation + true +} + +# Shutdown the vtpm while the vm is down +# This could be a suspend of shutdown +# we cannot distinquish, so save the state +# and decide on startup if we should keep is +function vtpm_suspend() { + $(vtpm_manager_cmd $TPM_CMD_CLOS $1) +} + + +function vtpm_delete() { + local inst=$1 + if $(vtpm_manager_cmd $TPM_CMD_DELE $inst); then + rm -f /var/vtpm/vtpm_dm_$1.data + true + else + vtpm_fatal_error=1 + false + fi +} + +# Perform a migration step. This function differentiates between migration +# to the local host or to a remote machine. +# Parameters: +# 1st: destination host to migrate to +# 2nd: name of the domain to migrate +# 3rd: the migration step to perform +function vtpm_migrate() { + local instance res + + instance=$(vtpmdb_find_instance $2) + if [ "$instance" == "" ]; then + log err "VTPM Migratoin failed. Unable to translation of domain name" + echo "Error: VTPM Migration failed while looking up instance number" + fi + + case "$3" in + 0) + #Incicate migration supported + echo "0" + ;; + + 1) + # Get Public Key from Destination + # Call vtpm_manager's migration part 1 + claim_lock vtpm_mgr + $VTPM_MIG $1 $2 $instance $3 + release_lock vtpm_mgr + ;; + + 2) + # Call manager's migration step 2 and send result to destination + # If successful remove from db + claim_lock vtpm_mgr + $VTPM_MIG $1 $2 $instance $3 + release_lock vtpm_mgr + ;; + + 3) + if `ps x | grep "$VTPM_MIG $1"`; then + log err "VTPM Migration failed to complete." + echo "Error: VTPM Migration failed to complete." + fi + ;; + esac + +} + + +function vtpm_migrate_recover() { + echo "Error: Recovery not supported yet" +} + +function vtpm_migrate_local() { + echo "Error: local vTPM migration not supported" +} diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-migration.sh b/os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-migration.sh new file mode 100644 index 00000000..7e38ae26 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/vtpm-migration.sh @@ -0,0 +1,19 @@ +# +# Copyright (c) 2005 IBM Corporation +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of version 2.1 of the GNU Lesser General Public +# License as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +dir=$(dirname "$0") +. "$dir/vtpm-common.sh" diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/xen-hotplug-cleanup b/os-plugins/plugins/xen/files/xen.examples/scripts/xen-hotplug-cleanup new file mode 100755 index 00000000..706359d0 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/xen-hotplug-cleanup @@ -0,0 +1,36 @@ +#! /bin/bash + +dir=$(dirname "$0") +. "$dir/xen-hotplug-common.sh" + +# Claim the lock protecting /etc/xen/scripts/block. This stops a race whereby +# paths in the store would disappear underneath that script as it attempted to +# read from the store checking for device sharing. +# Any other scripts that do similar things will have to have their lock +# claimed too. +# This is pretty horrible, but there's not really a nicer way of solving this. +claim_lock "block" + +# split backend/DEVCLASS/VMID/DEVID on slashes +path_array=( ${XENBUS_PATH//\// } ) +# get /vm/UUID path +vm=$(xenstore_read_default "/local/domain/${path_array[2]}/vm" "") +# construct /vm/UUID/device/DEVCLASS/DEVID +if [ "$vm" != "" ]; then + vm_dev="$vm/device/${path_array[1]}/${path_array[3]}" +else + vm_dev= +fi + +# remove device frontend store entries +xenstore-rm -t \ + $(xenstore-read "$XENBUS_PATH/frontend" 2>/dev/null) 2>/dev/null || true + +# remove device backend store entries +xenstore-rm -t "$XENBUS_PATH" 2>/dev/null || true +xenstore-rm -t "error/$XENBUS_PATH" 2>/dev/null || true + +# remove device path from /vm/UUID +[ "$vm_dev" != "" ] && xenstore-rm -t "$vm_dev" 2>/dev/null || true + +release_lock "block" diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/xen-hotplug-common.sh b/os-plugins/plugins/xen/files/xen.examples/scripts/xen-hotplug-common.sh new file mode 100644 index 00000000..980a6270 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/xen-hotplug-common.sh @@ -0,0 +1,93 @@ +# +# Copyright (c) 2005 XenSource Ltd. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of version 2.1 of the GNU Lesser General Public +# License as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + + +dir=$(dirname "$0") +. "$dir/logging.sh" +. "$dir/xen-script-common.sh" +. "$dir/locking.sh" + +exec 2>>/var/log/xen/xen-hotplug.log + +export PATH="/sbin:/bin:/usr/bin:/usr/sbin:$PATH" +export LANG="POSIX" +unset $(set | grep ^LC_ | cut -d= -f1) + +fatal() { + xenstore_write "$XENBUS_PATH/hotplug-error" "$*" \ + "$XENBUS_PATH/hotplug-status" error + log err "$@" + exit 1 +} + +success() { + # Tell DevController that backend is "connected" + xenstore_write "$XENBUS_PATH/hotplug-status" connected +} + +do_or_die() { + "$@" || fatal "$@ failed" +} + +do_without_error() { + "$@" 2>/dev/null || log debug "$@ failed" +} + +sigerr() { + fatal "$0 failed; error detected." +} + +trap sigerr ERR + + +## +# xenstore_read + +# +# Read each of the given paths, returning each result on a separate line, or +# exit this script if any of the paths is missing. +# +xenstore_read() { + local v=$(xenstore-read "$@" || true) + [ "$v" != "" ] || fatal "xenstore-read $@ failed." + echo "$v" +} + + +## +# xenstore_read_default +# +# Read the given path, returning the value there or the given default if the +# path is not present. +# +xenstore_read_default() { + xenstore-read "$1" 2>/dev/null || echo "$2" +} + + +## +# xenstore_write ( )+ +# +# Write each of the key/value pairs to the store, and exit this script if any +# such writing fails. +# +xenstore_write() { + log debug "Writing $@ to xenstore." + xenstore-write "$@" || fatal "Writing $@ to xenstore failed." +} + + +log debug "$@" "XENBUS_PATH=$XENBUS_PATH" diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/xen-network-common.sh b/os-plugins/plugins/xen/files/xen.examples/scripts/xen-network-common.sh new file mode 100644 index 00000000..7014333d --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/xen-network-common.sh @@ -0,0 +1,118 @@ +# +# Copyright (c) 2005 XenSource Ltd. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of version 2.1 of the GNU Lesser General Public +# License as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + + +# Gentoo doesn't have ifup/ifdown, so we define appropriate alternatives. + +# Other platforms just use ifup / ifdown directly. + +## +# preiftransfer +# +# @param $1 The current name for the physical device, which is also the name +# that the virtual device will take once the physical device has +# been renamed. + +if ! which ifup >/dev/null 2>/dev/null +then + preiftransfer() + { + true + } + ifup() + { + false + } + ifdown() + { + false + } +else + preiftransfer() + { + true + } +fi + + +first_file() +{ + t="$1" + shift + for file in $@ + do + if [ "$t" "$file" ] + then + echo "$file" + return + fi + done +} + +find_dhcpd_conf_file() +{ + first_file -f /etc/dhcp3/dhcpd.conf /etc/dhcpd.conf +} + + +find_dhcpd_init_file() +{ + first_file -x /etc/init.d/{dhcp3-server,dhcp,dhcpd} +} + +find_dhcpd_arg_file() +{ + first_file -f /etc/sysconfig/dhcpd /etc/defaults/dhcp /etc/default/dhcp3-server +} + +# configure interfaces which act as pure bridge ports: +setup_bridge_port() { + local dev="$1" + + # take interface down ... + ip link set ${dev} down + + # ... and configure it + ip addr flush ${dev} +} + +# Usage: create_bridge bridge +create_bridge () { + local bridge=$1 + + # Don't create the bridge if it already exists. + if [ ! -e "/sys/class/net/${bridge}/bridge" ]; then + brctl addbr ${bridge} + brctl stp ${bridge} off + brctl setfd ${bridge} 0 + fi +} + +# Usage: add_to_bridge bridge dev +add_to_bridge () { + local bridge=$1 + local dev=$2 + + # Don't add $dev to $bridge if it's already on a bridge. + if [ -e "/sys/class/net/${bridge}/brif/${dev}" ]; then + ip link set ${dev} up || true + return + fi + brctl addif ${bridge} ${dev} + ip link set ${dev} up +} + diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/xen-script-common.sh b/os-plugins/plugins/xen/files/xen.examples/scripts/xen-script-common.sh new file mode 100644 index 00000000..f6841acf --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/xen-script-common.sh @@ -0,0 +1,44 @@ +# +# Copyright (c) 2005 XenSource Ltd. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of version 2.1 of the GNU Lesser General Public +# License as published by the Free Software Foundation. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + + +set -e + + +evalVariables() +{ + for arg in "$@" + do + if expr 'index' "$arg" '=' '>' '1' >/dev/null + then + eval "$arg" + fi + done +} + + +findCommand() +{ + for arg in "$@" + do + if ! expr 'index' "$arg" '=' >/dev/null + then + command="$arg" + return + fi + done +} diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/xend-relocation.sh b/os-plugins/plugins/xen/files/xen.examples/scripts/xend-relocation.sh new file mode 100755 index 00000000..1f1cd061 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/xend-relocation.sh @@ -0,0 +1,159 @@ +#!/bin/bash +#============================================================================ +# xend-relocation +# +# Version = 1.0.3 +# Date = 2007-09-14 +# +# Maintainer(s) = Ron Terry - ron (at) pronetworkconsulting (dot) com +# +# The latest version can be found at: +# +# http://pronetworkconsulting.com/linux/scripts/xend-relocation.html +# +# Description: +# +# This script is used to enable or disable the VM relocation (migration) +# feature of xend. It can be used to manage the local instance of xend +# or both the local instance and instances of xend on the other machines +# to/from which VMs can be relocated. +# To manage the instances of xend on other machines this script communicates +# using ssh so it is recomended that if you use this feature you +# pre-distribute ssh keys between the servers. +# +# Depends on: +# +# Can use: /etc/sysconfig/xend +# +# Usage: xend-relocation (start|stop|status) +# or +# xend-relocation (on|off|status) +# +# Vars: +# +# XEN_CONFIG_FILE +# +# RELOCATION_NODELIST +# +# MANAGE_ALL_RELOCATION_NODES +# +# XEN_RELOCATION_PORT +# +#============================================================================ + +#### Read config files and set variables ################################## + +# If you source the /etc/sysconfig/xend file comment out the variables +# being set in this script. + +. /etc/sysconfig/xend + +XEN_CONFIG_FILE="/etc/xen/xend-config.sxp" + +#### Script Functions ##################################################### + +usage(){ + echo "" + echo "Usage: xend-relocation {start|stop|status}" + echo " or" + echo " xend-relocation {on|off|status}" + echo "" +} + +relocate_on() { + for NODE in $RELOCATION_NODELIST + do + case $NODE in + any) + SSHCMD="" + RELOCATION_NODELIST="" + ;; + *) + if [ "$MANAGE_ALL_RELOCATION_NODES" = "true" ] + then + SSHCMD="ssh root@$NODE " + else + SSHCMD="" + fi + ;; + esac + + $SSHCMD sed -i "s/^#(xend-relocation-server yes)/(xend-relocation-server yes)/g" $XEN_CONFIG_FILE + $SSHCMD sed -i "s/^#(xend-relocation-server no)/(xend-relocation-server yes)/g" $XEN_CONFIG_FILE + $SSHCMD sed -i "s/^#(xend-relocation-port [^)]*)/(xend-relocation-port $XEN_RELOCATION_PORT)/g" $XEN_CONFIG_FILE + $SSHCMD sed -i "s/^(xend-relocation-hosts-allow \(.*\)/###(xend-relocation-hosts-allow \1/g" $XEN_CONFIG_FILE + $SSHCMD sed -i "s/^#(xend-relocation-hosts-allow .*/(xend-relocation-hosts-allow \'$RELOCATION_NODELIST')/g" $XEN_CONFIG_FILE + $SSHCMD rcxend restart + + if [ "$NODE" = "any" ] || [ "$MANAGE_ALL_RELOCATION_NODES" = "false" ] + then + exit 0 + fi + done +} + +relocate_off() { + for NODE in $RELOCATION_NODELIST + do + case $NODE in + any) + SSHCMD="" + RELOCATION_NODELIST="" + ;; + *) + SSHCMD="ssh root@$NODE " + ;; + esac + + $SSHCMD sed -i "s/^(xend-relocation-server yes)/#(xend-relocation-server yes)/g" $XEN_CONFIG_FILE + $SSHCMD sed -i "s/^(xend-relocation-port [^)]*)/#(xend-relocation-port $XEN_RELOCATION_PORT)/g" $XEN_CONFIG_FILE + $SSHCMD sed -i "s/^(xend-relocation-hosts-allow .*/#(xend-relocation-hosts-allow \'$RELOCATION_NODELIST')/g" $XEN_CONFIG_FILE + $SSHCMD rcxend restart + + if [ "$NODE" = "any" ] || [ "$MANAGE_ALL_RELOCATION_NODES" = "false" ] + then + exit 0 + fi + done +} + +relocate_status() { + if grep -q "^(xend-relocation-server .*yes)" $XEN_CONFIG_FILE + then + ENABLED="yes" + elif egrep -q "(^\(xend-relocation-server .*no\)|^#\(xend-relocation-server .*no\)|^#\(xend-relocation-server .*yes\))" $XEN_CONFIG_FILE + then + ENABLED="no" + fi + + echo "" + echo "Xend Relocation Server Enabled: $ENABLED" + echo "" +} + +#### Script Body ########################################################## + +case $1 in + on|ON|On|start) + case $ENABLE_RELOCATION in + true) + relocate_on + ;; + false) + ;; + esac + exit 0 + ;; + off|OFF|Off|stop) + relocate_off + exit 0 + ;; + status|STATUS|Status) + relocate_status + exit 0 + ;; + *) + usage + exit 1 + ;; +esac diff --git a/os-plugins/plugins/xen/files/xen.examples/scripts/xmclone.sh b/os-plugins/plugins/xen/files/xen.examples/scripts/xmclone.sh new file mode 100755 index 00000000..fd31249b --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/scripts/xmclone.sh @@ -0,0 +1,793 @@ +#! /bin/bash + +# Script to clone Xen Dom-Us. +# Based on XenClone by Glen Davis; rewritten by Bob Brandt. +# Further extended and restructured by Manfred Hollstein. +# Copyright (C) 2007 Manfred Hollstein, SUSE / Novell Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 +# USA. + +# +# Defaults +# +VERSION=0.4.5 +XEN_CONFIGS=/etc/xen/vm/ +XEN_BASE=/var/lib/xen/images/ +SOURCE= +DESTINATION= +DUPLICATE=0 +HOSTNAME= +IP= +MAC= +PART=2 +DOMU_IS_FILE_BASED= +DOMU_ROOTDEV= +FORCE=no + + +# +# Subroutines used in this script +# + +# Display the usage information for this script +function usage () +{ + cat << EOF +Usage: ${0##*/} [-h|--help] [-v|--version] [--force] [-c dir] [-b dir] [-d] + [-n hostname] [-i address] [-m address] + [-p number-of-root-partition-within-domU] + [-t target-device] + SourcedomU NewdomU + +Clones a domU, and gives a new Host name, MAC address and possibly IP address. +Once finished the new domU should boot without any additional configuration. +Currently works with single NIC, and basic bridge setup. Tested with cloning +a SLES10 install created from the SLES10 YaST Xen module. + + -h, --help Display this help message. + -v, --version Display the version of this program. + --force Silently overwrite files when destination already exists. + -c Xen configuration directory which defaults to: + $XEN_CONFIGS + -b Xen image base directory which defaults to: + $XEN_BASE + -d Duplicate only, do not modify attributes. + -n Hostname to be used, if not specified the NewdomU name + will be used. + -i IP address to be used, if not specified the IP address + will not be changed. + -m MAC address to be used, if not specified a psuedo-random + address will be used based on the ip address with the + format: 00:16:3e:BB:CC:DD + Where BB,CC,DD are the Hex octals of the IP address. + -p This script assumes that the second partition on any + writable disk of the domU to be cloned holds the root + file system in which attributes have to be changed. + If this is not the case for you, you can specify the + partition number using this flag. + -t If the SourcedomU uses a block device for its root/ + boot directory, you need to specify the new block + device for NewdomU. + +From XENSource Networking WIKI (http://wiki.xensource.com/xenwiki/XenNetworking) +Virtualised network interfaces in domains are given Ethernet MAC addresses. When +choosing MAC addresses to use, ensure you choose a unicast address. That is, one +with the low bit of the first octet set to zero. For example, an address +starting aa: is OK but ab: is not. +It is best to keep to the range of addresses declared to be "locally assigned" +(rather than allocated globally to hardware vendors). These have the second +lowest bit set to one in the first octet. For example, aa: is OK, a8: isn't. + +Exit status is 0 if OK, 1 if minor problems, 2 if serious trouble. +EOF +} + +# Display the version information for this script +function version () +{ + cat << EOF +${0##*/} (Xen VM clone utility) $VERSION +${0##*/} comes with ABSOLUTELY NO WARRANTY. +This is free software, and you are welcome to redistribute it under the terms +of the GNU General Public License . + +Written by Manfred Hollstein, based on work by Glen Davis and Bob Brandt. +EOF +} + +# Find/Replace text within a file +function replace () +{ + sed -i -e "s!$1!$2!g" "$3" +} + +# +# Find the first entry that names a writable image or device, assuming +# the Dom-U is going to boot from it: +# +function get_first_writable_image () +{ + local i + + for i in $@ + do + case $i in + # Match the first entry like "'phy:/dev/md0,xvda,w'," + *",w'," ) + # Strip off the leading "'" character: + i="${i#*\'}" + # Strip off the final trailing "'," + echo "${i%*\',}" + return + ;; + esac + done +} + +# +# Extract just the protocol and the file/device name part from a disk entry: +# +function extract_proto_and_filename () +{ + echo "$1" | cut -d, -f1 +} + + +# +# Make sure this script is run by the superuser root +# +if [ `id -u` -ne 0 ] +then + echo "You must be root to run this script!" >&2 + exit 1 +fi + + +# +# Process the parameters +# +# Must look for double -- arguments before calling getopts +# +if [ "$1" = "--version" ] +then + version + exit 0 +fi +if [ "$1" = "--help" ] +then + usage + exit 0 +fi +if [ "$1" = "--force" ] +then + FORCE=yes + shift +fi +while getopts ":b:c:dhi:m:n:p:t:v" opt +do + case $opt in + b ) + XEN_BASE=$OPTARG + ;; + c ) + XEN_CONFIGS=$OPTARG + ;; + d ) + DUPLICATE=1 + ;; + h ) + usage + exit 1 + ;; + i ) + IP=$OPTARG + ;; + m ) + MAC=$OPTARG + ;; + n ) + HOSTNAME=$OPTARG + ;; + p ) + PART=$OPTARG + ;; + t ) + DOMU_ROOTDEV=$OPTARG + ;; + v ) + version + exit 0 + ;; + esac +done +shift $(($OPTIND-1)) + +if [ $# -ne 2 ] +then + echo "Illegal number of arguments passed!" >&2 + echo "" >&2 + usage + exit 1 +fi + +SOURCE=$1 +DESTINATION=$2 + + +# +# Verify the Source and Destination parameters +# +# The source and destination should be relative directory names without +# trailing /'s. If the source does have a full path, use that path as the +# value for XEN_BASE. Otherwise remove all but the last part of the path +# for both source and destination +# +SOURCEDIR=${SOURCE%/*} +SOURCEBASE=${SOURCE##*/} +if [ "$SOURCEDIR" != "$SOURCEBASE" ] +then + XEN_BASE=$SOURCEDIR"/" + SOURCE=$SOURCEBASE +fi +SOURCE=${SOURCE##*/} +DESTINATION=${DESTINATION##*/} + + +# +# Verify the Xen Config and Source parameters +# +# Verify the validity of each argument, ask the user if there is a problem +while [ ! -d "$XEN_CONFIGS" ] +do + cat << EOF >&2 +$XEN_CONFIGS either does not exist or is not a directory. +Please enter a valid directory. +EOF + read -e -p "Xen Configuration Directory? " XEN_CONFIGS +done +while [ ! -d "$XEN_BASE" ] +do + cat << EOF >&2 +$XEN_BASE either does not exist or is not a directory. +Please enter a valid directory. +EOF + read -e -p "Xen Image Base Directory? " XEN_BASE +done + +# +# Directories should have a / after them +# +[ "$XEN_CONFIGS" != "" ] && XEN_CONFIGS="${XEN_CONFIGS%/}/" +[ "$XEN_BASE" != "" ] && XEN_BASE="${XEN_BASE%/}/" + + +# +# Verify that actual image and configuration file exist +# +while : +do + if [ ! -f "$XEN_CONFIGS$SOURCE" ] + then + echo "The $XEN_CONFIGS$SOURCE file does not exist." >&2 + echo "Please select a valid file." >&2 + FILES= + for FILE in `ls $XEN_CONFIGS` + do + # If the entry is a file + [ -f "$XEN_CONFIGS$FILE" ] && + FILES="$FILES $XEN_CONFIGS$FILE" + done + if [ -z "$FILES" ] + then + echo "There are no suitable files beneath $XEN_CONFIGS" >&2 + exit 1 + fi + echo "Files beneath $XEN_CONFIGS" + select FILE in $FILES + do + if [ -f "$FILE" ] + then + SOURCE=${FILE##*/} + break + fi + echo "Invalid Selection." >&2 + done + else + # + # Figure out what type of image we're using: + # + BOOTENTRY=$(get_first_writable_image $(sed -n -e 's,^disk[ ]*=[ ]*\[\(.*\)\],\1,p' "$XEN_CONFIGS$SOURCE")) + case "$BOOTENTRY" in + phy:* ) + DOMU_IS_FILE_BASED=no + ;; + file:* | \ + tap:aio:* ) + DOMU_IS_FILE_BASED=yes + ;; + * ) + echo "Don't know how to deal with the boot protocol/device you appear to be using: $BOOTENTRY" >&2 + echo "These are the ones this script supports: \"phy:*\", \"file:*\", \"tap:aio:*\"" >&2 + exit 1 + ;; + esac + fi + + + if [ ${DOMU_IS_FILE_BASED} = yes ] + then + if [ ! -d "$XEN_BASE$SOURCE" ] + then + echo "The directory $XEN_BASE$SOURCE is invalid." >&2 + echo "Please select another one." >&2 + FILES= + for FILE in `ls $XEN_BASE` + do + # If the entry is a directory and + # it is not empty + [ -d "$XEN_BASE$FILE" ] && + [ "`ls $XEN_BASE$FILE`" != "" ] && + FILES="$FILES $XEN_BASE$FILE" + done + if [ -z "$FILES" ] + then + echo "There are no suitable directories beneath $XEN_BASE" >&2 + exit 1 + fi + echo "Directories beneath $XEN_BASE" + select FILE in $FILES + do + if [ -d "$FILE" ] + then + SOURCE=${FILE##*/} + break + fi + echo "Invalid Selection." >&2 + done + continue + fi + break + + else # DomU is using some block device + while [ ! -b "${DOMU_ROOTDEV}" ] || [ ! -w "${DOMU_ROOTDEV}" ] + do + read -e -p "You need to specify a valid block device for the new target DomU: " DOMU_ROOTDEV + done + break + + fi +done +BOOTIMAGE="$(echo $BOOTENTRY | awk -F : '{ print $NF }' | sed -e 's:,[^,]*,[^,]*$::')" + + +# +# Verify that the destination location does not already have an image or +# config file +# +while [ -z "$DESTINATION" ] +do + echo "You have not specified a Destination." >&2 + read -e -p "New Destination? " DESTINATION +done +while : +do + if [ -f "$XEN_CONFIGS$DESTINATION" ] && [ $FORCE = no ] + then + echo "The target configuration file $XEN_CONFIGS$DESTINATION already exists!" >&2 + read -e -p "Please select a new Destination? " DESTINATION + fi + if [ ${DOMU_IS_FILE_BASED} = yes ] + then + if [ -d "$XEN_BASE$DESTINATION" ] && [ $FORCE = no ] + then + echo "The target image location $XEN_BASE$DESTINATION already exists!" >&2 + read -p "Please select a new Destination? " DESTINATION + continue + fi + fi + break +done + + +# +# Verify the network parameters (if Duplicate Only was not selected) +# +if [ $DUPLICATE -eq 0 ] +then + if [ -z "$HOSTNAME" ] + then + echo "You have not entered a host name. If you wish to, enter one now." >&2 + read -p "New host name? (Default: $DESTINATION) " HOSTNAME + fi + [ -z "$HOSTNAME" ] && HOSTNAME=$DESTINATION + + if [ -z "$IP" ] + then + echo "You have not specified an IP Address. If you wish to change the IP address, enter one now." + read -p "New IP Address? " IP + fi + while [ -n "$IP" ] && [ "${IP/*.*.*.*/ok}" != "ok" ] + do + echo "The IP Address you specified is invalid. If you wish, enter a new one now." + read -p "New IP Address? " IP + [ -z "$IP" ] && break + done + + if [ -z "$MASK" ] + then + echo "You have not specified a network mask in bits. Please enter one now. Default is 24 " + read -p "Network mask? " MASK + fi + while [ -n "$MASK" ] && [ "${MASK/**/ok}" != "ok" ] + do + echo "The Network mask you specified is invalid. If you wish, enter a new one now." + read -p "Network mask? " MASK + [ -z "$MASK" ] && MASK=24 + done + + if [ -z "$MAC" ] + then + newMAC="" + newMACtext="(format 01:23:45:67:89:AB)" + # If the IP Address is specified and the MAC isn't, generate one. + if [ -n "$IP" ] + then + octal1=${IP%%.*} + IP=${IP#*.} + octal2=${IP%%.*} + IP=${IP#*.} + octal3=${IP%%.*} + octal4=${IP#*.} + IP="$octal1.$octal2.$octal3.$octal4" + octal1="00"`echo $octal1 16 o p | dc | tr '[:upper:]' '[:lower:]'` + octal2="00"`echo $octal2 16 o p | dc | tr '[:upper:]' '[:lower:]'` + octal3="00"`echo $octal3 16 o p | dc | tr '[:upper:]' '[:lower:]'` + octal4="00"`echo $octal4 16 o p | dc | tr '[:upper:]' '[:lower:]'` + newMAC="00:16:3e:"${octal2:(-2)}":"${octal3:(-2)}":"${octal4:(-2)} + newMACtext="(default $newMAC)" + fi + echo "You have not specified a MAC Address. If you wish to change the MAC address, enter one now." + read -p "New MAC Address? $newMACtext " MAC + [ -z "$MAC" ] && MAC=$newMAC + fi + + while [ "$MAC" != "" ] && [ "${MAC/[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]:[[:xdigit:]][[:xdigit:]]/ok}" != "ok" ] + do + echo "The MAC Address you specified is invalid. If you wish, enter a new one now." + read -p "New MAC Address? (format 01:23:45:67:89:AB) " MAC + [ -z "$MAC" ] && break + done +else + HOSTNAME= + IP= + MASK= + MAC= +fi + + +# +# Make sure that the source VM is not running +# +xmid=`xm domid "$SOURCE" 2>/dev/null` +if [ $? -eq 0 ] && [ -n "$xmid" ] && [ -z "${xmid//[[:digit:]]/}" ] +then + echo "domU $SOURCE is currently running on Xen, please shutdown before cloning." >&2 + echo "The command \"xm shutdown $xmid -w\" will shutdown the domU" >&2 + exit 1 +fi + + +# +# Copy the Xen Config file +# +SOURCECONFIG="$XEN_CONFIGS$SOURCE" +DESTCONFIG="$XEN_CONFIGS$DESTINATION" +echo "Copying Configuration files" +if ! cp -fv "$SOURCECONFIG" "$DESTCONFIG" +then + echo "The Config file $SOURCECONFIG could not be copied to $DESTCONFIG" >&2 + exit 1 +fi + + +# +# Edit newly copied configuration file +# +echo "Editing config file ($DESTCONFIG), correcting the new domU Name." +if ! replace "$SOURCE" "$DESTINATION" "$DESTCONFIG" +then + echo "Unable to change the domU name in $DESTCONFIG from $SOURCE to $DESTINATION" >&2 + exit 1 +fi + +if [ $DUPLICATE -eq 0 ] +then + oldUUID=`grep "^uuid[ ]*=.*$" $DESTCONFIG` + if [ x"${oldUUID}" = x ] + then + echo 'uuid="'`uuidgen`'"' >> $DESTCONFIG + else + sed -i -e 's,^uuid[ ]*=.*$,uuid="'`uuidgen`'",' $DESTCONFIG + fi +fi + +if [ $DUPLICATE -eq 0 ] && [ -n "$MAC" ] +then + # Get the vif line in the config file + oldMAC=`grep "vif[ ]*=[ ]*" $DESTCONFIG` + # extract everything between the square brackets + oldMAC=${oldMAC#*[} + oldMAC=${oldMAC%*]} + # using the single quotes as delimiters, get the second field + # (this script can only deal with one adapter!) + oldMAC=`echo "$oldMAC" | cut -f2 -d\'` + # remove the mac= from the beginning + oldMAC=${oldMAC#mac=*} + + if ! replace "$oldMAC" "$MAC" "$DESTCONFIG" + then + echo "Unable to change the MAC address in $DESTCONFIG from ($oldMAC) to ($MAC)" >&2 + exit 1 + fi +fi + + +# +# Create and Copy image directory +# + +if [ $DOMU_IS_FILE_BASED = yes ] +then + SOURCEXEN="$XEN_BASE$SOURCE/" + DESTXEN="$XEN_BASE$DESTINATION/" + echo "Creating the new image directory $DESTXEN" + if ! mkdir -pv --mode=755 "$DESTXEN" + then + echo "Unable to create the directory $DESTXEN" >&2 + exit 1 + fi + echo "Copying complete image. (This may take a few minutes!)" + + tar -C $SOURCEXEN -cSf - --exclude=lost+found `cd $SOURCEXEN; echo *` \ + | tar -C $DESTXEN -xvBSpf - + if [ $? -ne 0 ] + then + echo "Unable to copy the images from $SOURCEXEN to $DESTXEN" >&2 + exit 1 + fi +else # Deal with block devices + if [ $DUPLICATE -eq 0 ] + then + echo "Editing config file ($DESTCONFIG), correcting the new domU root device name." + if ! replace ":$BOOTIMAGE," ":$DOMU_ROOTDEV," "$DESTCONFIG" + then + echo "Unable to change the domU root device name in $DESTCONFIG from $BOOTIMAGE to $DOMU_ROOTDEV" >&2 + exit 1 + fi + fi + echo "Copying from source block device ($BOOTIMAGE) to the new target device ($DOMU_ROOTDEV)" + echo "(This may take a few minutes!)" + if ! dd if=$BOOTIMAGE of=$DOMU_ROOTDEV bs=4K + then + echo "Failed to copy from $BOOTIMAGE to $DOMU_ROOTDEV" >&2 + exit 1 + fi +fi + + +# +# The rest of the script only applies if we are actually making changes within +# the image +# +if [ $DUPLICATE -eq 0 ] +then + # + # Create a temporary directory name + # + tmpdir=$(mktemp -d) + if [ $? -ne 0 ] + then + echo "Unable to create temporary directory $tmpdir." >&2 + exit 1 + fi + + if [ $DOMU_IS_FILE_BASED = yes ] + then + set -- $(echo $DESTXEN*) + else + set -- $(echo $DOMU_ROOTDEV) + fi + + for DISKIMAGE + do + # Silently ignore any directories (lost+found comes to mind): + [ -d $DISKIMAGE ] && continue + + # + # Mount the newly copied image file + # + loopdev='' + for dev in /dev/loop* + do + if [ ! -b "$dev" ] + then + continue + fi + + status=$(losetup "$dev" 2>/dev/null) || status='' + + if [ ! "$status" ] + then + status=$(losetup $dev "$DISKIMAGE") + if [ ! "$status" ] + then + kpartx -a $dev + loopdev=$dev + break + fi + fi + done + if [ ! "$loopdev" ] + then + echo "No loopback devices available." >&2 + exit 1 + fi + + echo -n "Trying to mount partition $PART of $DISKIMAGE ... " + mapperdev=$(echo "$loopdev" | sed -e 's/dev\//dev\/mapper\//g')p$PART + status=$(mount -o rw $mapperdev "$tmpdir") + if [ "$status" ] + then + kpartx -d $loopdev + losetup -d $loopdev + continue + fi + echo "succeeded." + + pushd "$tmpdir" > /dev/null + + # + # Find out if we are looking at SLE10 + # + SLE10= + if [ -f etc/SuSE-release ] + then + OSVER=`cat etc/SuSE-release | sed -n 1p | awk -F'(' '{ print $1 }' | sed 's/ $//g'` + if [ "$OSVER" == "openSUSE 10" -o \ + "$OSVER" == "SUSE Linux Enterprise Server 10" -o \ + "$OSVER" == "SUSE Linux Enterprise Desktop 10" ] + then + SLE10=1 + fi + fi + + # + # Change the Network Configuration in the mounted image file + # + if [ -n "$MAC" ] + then + if [ -d etc/sysconfig/network/ ] + then + echo "Changing the Network configuration in the newly copied image." + pushd "etc/sysconfig/network/" > /dev/null + # Find the ifcfg-ethMACADDRESS file in the + # newly copied image + ETH0=`ls | grep ifcfg-eth | cut -f1` + if [ -z "$ETH0" ] + then + echo "Unable to find ethernet file in image file" 2>&1 + cd /tmp; umount "$tmpdir"; rmdir "$tmpdir" + kpartx -d $loopdev + losetup -d $loopdev + exit 1 + fi + if [ "$SLE10" ] + then + mv -f "$ETH0" ifcfg-eth-id-$MAC + else + sed -i -e "s,^LLADDR=.*$,LLADDR=\'$MAC\'," \ + ifcfg-eth0 + fi + popd > /dev/null + fi + + if [ -d etc/udev/rules.d/ ] + then + # The 30-net_persistent_names.rules or 70-persistent-net.rules + # file controls which interface to use. + # By removing the SUBSYSTEM== lines, we force + # the system to recreate it. + pushd "etc/udev/rules.d/" > /dev/null + if [ "$SLE10" ] + then + sed -i -e "/SUBSYSTEM==/d" \ + 30-net_persistent_names.rules + else + sed -i -e "/SUBSYSTEM==/d" \ + 70-persistent-net.rules + fi + popd > /dev/null + fi + fi + + # + # Change the IP Address in the mounted image file + # + if [ -n "$IP" ] + then + if [ -d etc/sysconfig/network/ ] + then + echo "Modify the IP Address of the new domU." + + pushd "etc/sysconfig/network/" > /dev/null + if [ "$SLE10" ] + then + sed -i -e "s,^IPADDR=.*$,IPADDR=$IP," \ + ifcfg-eth-id-$MAC + else + sed -i -e "s,^IPADDR=.*$,IPADDR=$IP/$MASK," \ + ifcfg-eth0 + fi + popd > /dev/null + fi + fi + + # + # Change the HOSTNAME and hosts files in the mounted image file + # + if [ -n "$HOSTNAME" ] + then + if [ -d "etc/" ] + then + echo "Changing HOSTNAME file to $HOSTNAME." + + pushd "etc/" > /dev/null + # using the period as a delimiter, select the + # first entry for the hostname + oldHOSTNAME=`cut -f1 -d\. HOSTNAME` + if ! replace "$oldHOSTNAME" "$HOSTNAME" "HOSTNAME" + then + echo "Unable to change the HOSTNAME from $oldHOSTNAME to $HOSTNAME" >&2 + cd /tmp; umount "$tmpdir"; rmdir "$tmpdir" + kpartx -d $loopdev + losetup -d $loopdev + exit 1 + fi + FQDN=`cat HOSTNAME` + + # Add entries for the new domU to /etc/hosts, + # if it doesn't already include them: + if ! egrep -q "[[:space:]]$FQDN[^[:alnum:]]" \ + hosts + then + echo "Changing hosts file." + echo -e "$IP\t$FQDN $HOSTNAME" >> hosts + fi + popd > /dev/null + fi + fi + + popd > /dev/null + umount "$tmpdir" + kpartx -d $loopdev + losetup -d $loopdev + done + + rmdir "$tmpdir" +fi + +echo "Clone is complete. domU $DESTCONFIG is ready to start!" +exit 0 diff --git a/os-plugins/plugins/xen/files/xen.examples/xenapiusers b/os-plugins/plugins/xen/files/xen.examples/xenapiusers new file mode 100644 index 00000000..d8649da3 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/xenapiusers @@ -0,0 +1 @@ +root diff --git a/os-plugins/plugins/xen/files/xen.examples/xend-config-xenapi.sxp b/os-plugins/plugins/xen/files/xen.examples/xend-config-xenapi.sxp new file mode 100644 index 00000000..d80083ad --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/xend-config-xenapi.sxp @@ -0,0 +1,193 @@ +# -*- sh -*- + +# +# Xend configuration file. +# + +# This example configuration is appropriate for an installation that +# utilizes a bridged network configuration. Access to xend via http +# is disabled. + +# Commented out entries show the default for that entry, unless otherwise +# specified. + +#(logfile /var/log/xen/xend.log) +#(loglevel DEBUG) + + +# The Xen-API server configuration. (Please note that this server is +# available as an UNSUPPORTED PREVIEW in Xen 3.0.4, and should not be relied +# upon). +# +# This value configures the ports, interfaces, and access controls for the +# Xen-API server. Each entry in the list starts with either unix, a port +# number, or an address:port pair. If this is "unix", then a UDP socket is +# opened, and this entry applies to that. If it is a port, then Xend will +# listen on all interfaces on that TCP port, and if it is an address:port +# pair, then Xend will listen on the specified port, using the interface with +# the specified address. +# +# The subsequent string configures the user-based access control for the +# listener in question. This can be one of "none" or "pam", indicating either +# that users should be allowed access unconditionally, or that the local +# Pluggable Authentication Modules configuration should be used. If this +# string is missing or empty, then "pam" is used. +# +# The final string gives the host-based access control for that listener. If +# this is missing or empty, then all connections are accepted. Otherwise, +# this should be a space-separated sequence of regular expressions; any host +# with a fully-qualified domain name or an IP address that matches one of +# these regular expressions will be accepted. +# +# Example: listen on TCP port 9363 on all interfaces, accepting connections +# only from machines in example.com or localhost, and allow access through +# the unix domain socket unconditionally: +# + (xen-api-server ((9363 none))) +# (unix none))) +# +# Optionally, the TCP Xen-API server can use SSL by specifying the private +# key and certificate location: +# +# (9367 pam '' /etc/xen/xen-api.key /etc/xen/xen-api.crt) +# +# Default: +# (xen-api-server ((unix))) + + +#(xend-http-server no) +#(xend-unix-server no) +#(xend-tcp-xmlrpc-server no) +#(xend-unix-xmlrpc-server yes) +#(xend-relocation-server no) +(xend-relocation-server yes) + +#(xend-unix-path /var/lib/xend/xend-socket) + + +# Address and port xend should use for the legacy TCP XMLRPC interface, +# if xen-tcp-xmlrpc-server is set. +#(xen-tcp-xmlrpc-server-address 'localhost') +#(xen-tcp-xmlrpc-server-port 8006) + +# SSL key and certificate to use for the legacy TCP XMLRPC interface. +# Setting these will mean that this port serves only SSL connections as +# opposed to plaintext ones. +#(xend-tcp-xmlrpc-server-ssl-key-file /etc/xen/xmlrpc.key) +#(xend-tcp-xmlrpc-server-ssl-cert-file /etc/xen/xmlrpc.crt) + + +# Port xend should use for the HTTP interface, if xend-http-server is set. +#(xend-port 8000) + +# Port xend should use for the relocation interface, if xend-relocation-server +# is set. +#(xend-relocation-port 8002) + +# Address xend should listen on for HTTP connections, if xend-http-server is +# set. +# Specifying 'localhost' prevents remote connections. +# Specifying the empty string '' (the default) allows all connections. +#(xend-address '') +#(xend-address localhost) + +# Address xend should listen on for relocation-socket connections, if +# xend-relocation-server is set. +# Meaning and default as for xend-address above. +#(xend-relocation-address '') + +# The hosts allowed to talk to the relocation port. If this is empty (the +# default), then all connections are allowed (assuming that the connection +# arrives on a port and interface on which we are listening; see +# xend-relocation-port and xend-relocation-address above). Otherwise, this +# should be a space-separated sequence of regular expressions. Any host with +# a fully-qualified domain name or an IP address that matches one of these +# regular expressions will be accepted. +# +# For example: +# (xend-relocation-hosts-allow '^localhost$ ^.*\\.example\\.org$') +# +#(xend-relocation-hosts-allow '') +(xend-relocation-hosts-allow '^localhost$ ^localhost\\.localdomain$') + +# The limit (in kilobytes) on the size of the console buffer +#(console-limit 1024) + +## +# To bridge network traffic, like this: +# +# dom0: ----------------- bridge -> real eth0 -> the network +# | +# domU: fake eth0 -> vifN.0 -+ +# +# use +# +# (network-script network-bridge) +# +# Your default ethernet device is used as the outgoing interface, by default. +# To use a different one (e.g. eth1) use +# +# (network-script 'network-bridge netdev=eth1') +# +# The bridge is named xenbr0, by default. To rename the bridge, use +# +# (network-script 'network-bridge bridge=') +# +# It is possible to use the network-bridge script in more complicated +# scenarios, such as having two outgoing interfaces, with two bridges, and +# two fake interfaces per guest domain. To do things like this, write +# yourself a wrapper script, and call network-bridge from it, as appropriate. +# +(network-script network-bridge) + +# The script used to control virtual interfaces. This can be overridden on a +# per-vif basis when creating a domain or a configuring a new vif. The +# vif-bridge script is designed for use with the network-bridge script, or +# similar configurations. +# +# If you have overridden the bridge name using +# (network-script 'network-bridge bridge=') then you may wish to do the +# same here. The bridge name can also be set when creating a domain or +# configuring a new vif, but a value specified here would act as a default. +# +# If you are using only one bridge, the vif-bridge script will discover that, +# so there is no need to specify it explicitly. +# +(vif-script vif-bridge) + + +## Use the following if network traffic is routed, as an alternative to the +# settings for bridged networking given above. +#(network-script network-route) +#(vif-script vif-route) + + +## Use the following if network traffic is routed with NAT, as an alternative +# to the settings for bridged networking given above. +#(network-script network-nat) +#(vif-script vif-nat) + + +# Dom0 will balloon out when needed to free memory for domU. +# dom0-min-mem is the lowest memory level (in MB) dom0 will get down to. +# If dom0-min-mem=0, dom0 will never balloon out. +(dom0-min-mem 196) + +# In SMP system, dom0 will use dom0-cpus # of CPUS +# If dom0-cpus = 0, dom0 will take all cpus available +(dom0-cpus 0) + +# Whether to enable core-dumps when domains crash. +#(enable-dump no) + +# The tool used for initiating virtual TPM migration +#(external-migration-tool '') + +# The interface for VNC servers to listen on. Defaults +# to 127.0.0.1 To restore old 'listen everywhere' behaviour +# set this to 0.0.0.0 +#(vnc-listen '127.0.0.1') + +# The default password for VNC console on HVM domain. +# Empty string is no authentication. +(vncpasswd '') diff --git a/os-plugins/plugins/xen/files/xen.examples/xend-config.sxp b/os-plugins/plugins/xen/files/xen.examples/xend-config.sxp new file mode 100644 index 00000000..f91f5726 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/xend-config.sxp @@ -0,0 +1,323 @@ +# -*- sh -*- + +# +# Xend configuration file. +# + +# This example configuration is appropriate for an installation that +# utilizes a bridged network configuration. Access to xend via http +# is disabled. + +# Commented out entries show the default for that entry, unless otherwise +# specified. + +#(logfile /var/log/xen/xend.log) +#(loglevel DEBUG) + +# Uncomment the line below. Set the value to flask, acm, or dummy to +# select a security module. + +#(xsm_module_name dummy) + +# The Xen-API server configuration. +# +# This value configures the ports, interfaces, and access controls for the +# Xen-API server. Each entry in the list starts with either unix, a port +# number, or an address:port pair. If this is "unix", then a UDP socket is +# opened, and this entry applies to that. If it is a port, then Xend will +# listen on all interfaces on that TCP port, and if it is an address:port +# pair, then Xend will listen on the specified port, using the interface with +# the specified address. +# +# The subsequent string configures the user-based access control for the +# listener in question. This can be one of "none" or "pam", indicating either +# that users should be allowed access unconditionally, or that the local +# Pluggable Authentication Modules configuration should be used. If this +# string is missing or empty, then "pam" is used. +# +# The final string gives the host-based access control for that listener. If +# this is missing or empty, then all connections are accepted. Otherwise, +# this should be a space-separated sequence of regular expressions; any host +# with a fully-qualified domain name or an IP address that matches one of +# these regular expressions will be accepted. +# +# Example: listen on TCP port 9363 on all interfaces, accepting connections +# only from machines in example.com or localhost, and allow access through +# the unix domain socket unconditionally: +# +# (xen-api-server ((9363 pam '^localhost$ example\\.com$') +# (unix none))) +# +# Optionally, the TCP Xen-API server can use SSL by specifying the private +# key and certificate location: +# +# (9367 pam '' /etc/xen/xen-api.key /etc/xen/xen-api.crt) +# +# Default: +# (xen-api-server ((unix))) + + +#(xend-http-server no) +(xend-unix-server yes) +#(xend-tcp-xmlrpc-server no) +#(xend-unix-xmlrpc-server yes) +# Only enable xend-relocation-server on trusted networks as it lacks +# encryption and authentication. +#(xend-relocation-server no) +#(xend-relocation-ssl-server no) +#(xend-udev-event-server no) + +#(xend-unix-path /var/lib/xend/xend-socket) + + +# Address and port xend should use for the legacy TCP XMLRPC interface, +# if xend-tcp-xmlrpc-server is set. +#(xend-tcp-xmlrpc-server-address 'localhost') +#(xend-tcp-xmlrpc-server-port 8006) + +# SSL key and certificate to use for the legacy TCP XMLRPC interface. +# Setting these will mean that this port serves only SSL connections as +# opposed to plaintext ones. +#(xend-tcp-xmlrpc-server-ssl-key-file /etc/xen/xmlrpc.key) +#(xend-tcp-xmlrpc-server-ssl-cert-file /etc/xen/xmlrpc.crt) + + +# Port xend should use for the HTTP interface, if xend-http-server is set. +#(xend-port 8000) + +# Port xend should use for the relocation interface, if xend-relocation-server +# is set. +#(xend-relocation-port 8002) + +# Port xend should use for the ssl relocation interface, if +# xend-relocation-ssl-server is set. +#(xend-relocation-ssl-port 8003) + +# SSL key and certificate to use for the ssl relocation interface, if +# xend-relocation-ssl-server is set. +#(xend-relocation-server-ssl-key-file /etc/xen/xmlrpc.key) +#(xend-relocation-server-ssl-cert-file /etc/xen/xmlrpc.crt) + +# Whether to use ssl as default when relocating. +#(xend-relocation-ssl no) + +# Address xend should listen on for HTTP connections, if xend-http-server is +# set. +# Specifying 'localhost' prevents remote connections. +# Specifying the empty string '' (the default) allows all connections. +#(xend-address '') +#(xend-address localhost) + +# Address xend should listen on for relocation-socket connections, if +# xend-relocation-server is set. +# Meaning and default as for xend-address above. +#(xend-relocation-address '') + +# The hosts allowed to talk to the relocation port. If this is empty (the +# default), then all connections are allowed (assuming that the connection +# arrives on a port and interface on which we are listening; see +# xend-relocation-port and xend-relocation-address above). Otherwise, this +# should be a space-separated sequence of regular expressions. Any host with +# a fully-qualified domain name or an IP address that matches one of these +# regular expressions will be accepted. +# +# For example: +# (xend-relocation-hosts-allow '^localhost$ ^.*\\.example\\.org$') +# +#(xend-relocation-hosts-allow '') +(xend-relocation-hosts-allow '^localhost$ ^localhost\\.localdomain$') + +# The limit (in kilobytes) on the size of the console buffer +#(console-limit 1024) + +## +# To bridge network traffic, like this: +# +# dom0: ----------------- bridge -> real eth0 -> the network +# | +# domU: fake eth0 -> vifN.0 -+ +# +# use +# +# (network-script network-bridge) +# +# Your default ethernet device is used as the outgoing interface, by default. +# To use a different one (e.g. eth1) use +# +# (network-script 'network-bridge netdev=eth1') +# +# The bridge takes on the ethernet device name by default. To rename the +# bridge, use +# +# (network-script 'network-bridge bridge=') +# +# It is possible to use the network-bridge script in more complicated +# scenarios, such as having two outgoing interfaces, with two bridges, and +# two fake interfaces per guest domain. To do things like this, write +# yourself a wrapper script, and call network-bridge from it, as appropriate. +# +# SuSE users note: +# On openSUSE >= 11.1 and SLES >= 11, networks should be configured using +# native platform tool - YaST. vif-bridge and qemu-ifup can be used to +# connect vifs to the YaST-managed networks. +#(network-script network-bridge) +(network-script ) + +# The script used to control virtual interfaces. This can be overridden on a +# per-vif basis when creating a domain or a configuring a new vif. The +# vif-bridge script is designed for use with the network-bridge script, or +# similar configurations. +# +# If you have overridden the bridge name using +# (network-script 'network-bridge bridge=') then you may wish to do the +# same here. The bridge name can also be set when creating a domain or +# configuring a new vif, but a value specified here would act as a default. +# +# If you are using only one bridge, the vif-bridge script will discover that, +# so there is no need to specify it explicitly. +# +(vif-script vif-bridge) + + +## Use the following if network traffic is routed, as an alternative to the +# settings for bridged networking given above. +#(network-script network-route) +#(vif-script vif-route) + + +## Use the following if network traffic is routed with NAT, as an alternative +# to the settings for bridged networking given above. +#(network-script network-nat) +#(vif-script vif-nat) + +# dom0-min-mem is the lowest permissible memory level (in MB) for dom0. +# This is a minimum both for auto-ballooning (as enabled by +# enable-dom0-ballooning below) and for xm mem-set when applied to dom0. +(dom0-min-mem 512) + +# Whether to enable auto-ballooning of dom0 to allow domUs to be created. +# If enable-dom0-ballooning = no, dom0 will never balloon out. +(enable-dom0-ballooning yes) + +# In SMP system, dom0 will use dom0-cpus # of CPUS +# If dom0-cpus = 0, dom0 will take all cpus available +(dom0-cpus 0) + +# Whether to enable core-dumps when domains crash. +#(enable-dump no) + +# The tool used for initiating virtual TPM migration +#(external-migration-tool '') + +# The interface for VNC servers to listen on. Defaults +# to 127.0.0.1 To restore old 'listen everywhere' behaviour +# set this to 0.0.0.0 +#(vnc-listen '127.0.0.1') + +# The default password for VNC console on HVM domain. +# Empty string is no authentication. +(vncpasswd '') + +# The VNC server can be told to negotiate a TLS session +# to encryption all traffic, and provide x509 cert to +# clients enalbing them to verify server identity. The +# GTK-VNC widget, virt-viewer, virt-manager and VeNCrypt +# all support the VNC extension for TLS used in QEMU. The +# TightVNC/RealVNC/UltraVNC clients do not. +# +# To enable this create x509 certificates / keys in the +# directory /etc/xen/vnc +# +# ca-cert.pem - The CA certificate +# server-cert.pem - The Server certificate signed by the CA +# server-key.pem - The server private key +# +# and then uncomment this next line +# (vnc-tls 1) + +# The certificate dir can be pointed elsewhere.. +# +# (vnc-x509-cert-dir /etc/xen/vnc) + +# The server can be told to request & validate an x509 +# certificate from the client. Only clients with a cert +# signed by the trusted CA will be able to connect. This +# is more secure the password auth alone. Passwd auth can +# used at the same time if desired. To enable client cert +# checking uncomment this: +# +# (vnc-x509-verify 1) + +# The default keymap to use for the VM's virtual keyboard +# when not specififed in VM's configuration +#(keymap 'en-us') + +# Script to run when the label of a resource has changed. +#(resource-label-change-script '') + +# Rotation count of qemu-dm log file. +#(qemu-dm-logrotate-count 10) + +# Path where persistent domain configuration is stored. +# Default is /var/lib/xend/domains/ +# +#(xend-domains-path /var/lib/xend/domains) + +# Domain Locking +# In a multihost environment, domain locking prevents simultaneously +# running a domain on more than one host. +# +# If enabled, xend will execute a external lock utility (defined below) +# on each domain start and stop event. Disabled by default. Set to yes +# to enable domain locking. +# +#(xend-domain-lock no) + +# Path where domain lock is stored if xend-domain-lock is enabled. +# Note: This path must be accessible to all VM Servers participating +# in domain locking, e.g. by specifying a shared mount point. +# Lock is placed in //. +# Default is /var/lib/xend/domains/ +# +#(xend-domain-lock-path /var/lib/xend/domains) + +# External locking utility called by xend for acquiring/releasing +# domain lock. By default /etc/xen/scripts/domain-lock will be used +# if xend-domain-lock is set to yes. Set to path of custom locking +# utility to override the default. +# +# Synopsis of lock-util: +# lock-util [-l|-u] -n -i -p path" +# -l Acquire (create) lock +# -u Remove lock +# -n vm-name Name of domain +# -i vm-id Id or UUID of domain +# -p phy-host Name of physical host (dom0) +# path // +# Return 0 on success, non-zero on error. +# +# lock-util [-s] path" +# -s Lock status. If lock is acquired, print any contents +# on stdout and return 0. Return non-zero if lock is +# available. +# path // +# If lock is acquired, print any contents on stdout and return 0. +# Return non-zero if lock is available. +# +# Default lock-util behavior: +# On domain start event, domain-lock will create and flock(1) +# ///lock. Every two seconds it +# will write , , , and to the lock. +# is running counter. +# On domain stop event, domain-lock will unlock and remove +# ///lock. +# +# Note: If xend-domain-lock-path is a cluster-unaware file system, +# administrator intervention may be required to remove stale +# locks. Consider two hosts using NFS for xend-domain-lock-path +# when HostA, running vm1, crashes. HostB could not acquire a +# lock for vm1 since the NFS server holds an exclusive lock +# acquired by HostA. The lock file must be manually removed +# before starting vm1 on HostA. +# +#(xend-domain-lock-utility domain-lock) diff --git a/os-plugins/plugins/xen/files/xen.examples/xend-pci-permissive.sxp b/os-plugins/plugins/xen/files/xen.examples/xend-pci-permissive.sxp new file mode 100644 index 00000000..1a3fb90a --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/xend-pci-permissive.sxp @@ -0,0 +1,27 @@ +############################################################################### +# Configuration file for granting quiry PCI devices full write access to their +# configuration space. This file should only be used when you are unable to +# determine the exact registers required by your device. Even so, it should +# be used only temporarily. +# +# SEND A MESSAGE TO xen-devel@lists.xensource.com IF YOU USE THIS FILE. +# +# Using this file should NOT be necessary. If you must use it to make some +# device work, send a message to the above list with as much information about +# your device as possible so the developers can make accomodations for it. +# Once developers make the necessary updates you can remove the corresponding +# entry for your device. +############################################################################### +# Entries are formated as follows: :[::] +# +# Example: Appending to an existing list +# +# (unconstrained_dev_ids +# ('XXXX:XXXX:XXXX:XXXX' # existing entry +# 'YYYY:YYYY:YYYY:YYYY' # new entry 1 +# 'ZZZZ:ZZZZ') # new entry 2 +# ) +############################################################################### +(unconstrained_dev_ids + #('0123:4567:89AB:CDEF') +) diff --git a/os-plugins/plugins/xen/files/xen.examples/xend-pci-quirks.sxp b/os-plugins/plugins/xen/files/xen.examples/xend-pci-quirks.sxp new file mode 100644 index 00000000..6bce4b8a --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/xend-pci-quirks.sxp @@ -0,0 +1,96 @@ +############################################################################### +# Configuration file for quirky PCI devices that require write-access to +# parts of the configuration space. Use this file to specific PCI device +# IDs and the configuration space fields to which those devices must be +# able to write. +# +# Length is important, so be sure to match new entries with the +# lengths of comparable existing entries. +# +# Additions to this file take effect as soon as a new domain with a +# matching device is started. However, to remove a field that was +# previously applied to a device you must unbind the device from +# pciback. +############################################################################### +# This is a bogus entry to show how a new device would be added to the list +# +# (new_quirky_dev_name +# (pci_ids +# ('0123:4567:890A:BCEF') +# ) +# +# (pci_config_space_fields +# ('12345678:1:00000000') +# ) +# ) +############################################################################### + +(tg3 + (pci_ids + # Entries are formated as follows: + # :[::] + ('14e4:1644' # Broadcom Tigon3 5700 + '14e4:1645' # Broadcom Tigon3 5701 + '14e4:1646' # Broadcom Tigon3 5702 + '14e4:1647' # Broadcom Tigon3 5703 + '14e4:1648' # Broadcom Tigon3 5704 + '14e4:164d' # Broadcom Tigon3 5702FE + '14e4:1653' # Broadcom Tigon3 5705 + '14e4:1654' # Broadcom Tigon3 5705_2 + '14e4:165d' # Broadcom Tigon3 5705M + '14e4:165e' # Broadcom Tigon3 5705M_2 + '14e4:16a6' # Broadcom Tigon3 5702X + '14e4:16a7' # Broadcom Tigon3 5703X + '14e4:16a8' # Broadcom Tigon3 5704S + '14e4:16c6' # Broadcom Tigon3 5702A3 + '14e4:16c7' # Broadcom Tigon3 5703A3 + '14e4:1696' # Broadcom Tigon3 5782 + '14e4:169c' # Broadcom Tigon3 5788 + '14e4:169d' # Broadcom Tigon3 5789 + '14e4:170d' # Broadcom Tigon3 5901 + '14e4:1649' # Broadcom Tigon3 5704S_2 + '14e4:166e' # Broadcom Tigon3 5705F + '14e4:1658' # Broadcom Tigon3 5720 + '14e4:1659' # Broadcom Tigon3 5721 + '14e4:1676' # Broadcom Tigon3 5750 + '14e4:1677' # Broadcom Tigon3 5751 + '14e4:167c' # Broadcom Tigon3 5750M + '14e4:167d' # Broadcom Tigon3 5751M + '14e4:167e' # Broadcom Tigon3 5751F + '14e4:1600' # Broadcom Tigon3 5752 + '14e4:1601' # Broadcom Tigon3 5752M + '14e4:16f7' # Broadcom Tigon3 5753 + '14e4:16fd' # Broadcom Tigon3 5753M + '14e4:16fe' # Broadcom Tigon3 5753F + '14e4:1668' # Broadcom Tigon3 5714 + '14e4:1678' # Broadcom Tigon3 5715 + '14e4:166a' # Broadcom Tigon3 5780 + '14e4:166b' # Broadcom Tigon3 5780S + '14e4:16dd' # Broadcom Tigon3 5781 + '1148:4400' # Syskonnect 9DXX + '1148:4500' # Syskonnect 9MXX + '173b:03e8' # Altima AC1000 + '173b:03e9' # Altima AC1001 + '173b:03eb' # Altima AC1003 + '173b:03ea' # Altima AC9100 + '106b:1645') # Apple Tigon3 + ) + + (pci_config_space_fields + # Entries are formated as follows: + # :: + # size is measured in bytes (1,2,4 are valid sizes) + # mask is currently unused; use all zero's + ('00000078:4:00000000' # TG3PCI_REG_BASE_ADDR + '0000007c:4:00000000' # TG3PCI_MEM_WIN_BASE_ADDR + '00000080:4:00000000' # TG3PCI_REG_DATA + '00000084:4:00000000' # TG3PCI_MEM_WIN_DATA + '00000090:4:00000000' # TG3PCI_MISC_LOCAL_CTRL + '00000068:4:00000000' # TG3PCI_MISC_HOST_CTRL + '0000009C:4:00000000' # TG3PCI_STD_RING_PROD_IDX + TG3_64BIT_REG_LOW + '00000098:4:00000000' # TG3PCI_STD_RING_PROD_IDX + TG3_64BIT_REG_HIGH + '000000a4:4:00000000' # TG3PCI_RCV_RET_RING_CON_IDX + TG3_64BIT_REG_LOW + '000000a0:4:00000000' # TG3PCI_RCV_RET_RING_CON_IDX + TG3_64BIT_REG_HIGH + '00000070:4:00000000') # TG3PCI_PCISTATE + ) +) diff --git a/os-plugins/plugins/xen/files/xen.examples/xm-config-xenapi.xml b/os-plugins/plugins/xen/files/xen.examples/xm-config-xenapi.xml new file mode 100644 index 00000000..dbd8778b --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/xm-config-xenapi.xml @@ -0,0 +1,43 @@ + + + + + + + + diff --git a/os-plugins/plugins/xen/files/xen.examples/xm-config.xml b/os-plugins/plugins/xen/files/xen.examples/xm-config.xml new file mode 100644 index 00000000..943b74d2 --- /dev/null +++ b/os-plugins/plugins/xen/files/xen.examples/xm-config.xml @@ -0,0 +1,45 @@ + + + + + + + + -- cgit v1.2.3-55-g7522 From 3e8723555bb0a1be3e27330275c4d6b2da9945df Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Fri, 26 Mar 2010 22:09:31 +0100 Subject: NAT TFTP boot with VBox. rwimg support added --- .../virtualbox/OpenSLX/OSPlugin/virtualbox.pm | 52 ++++++++++-- os-plugins/plugins/virtualbox/XX_virtualbox.sh | 5 +- os-plugins/plugins/virtualbox/files/VirtualBox.xml | 41 --------- .../plugins/virtualbox/files/machine.include | 4 +- .../plugins/virtualbox/files/run-virt.include | 98 +++++++++++++--------- .../plugins/virtualbox/files/virtualbox.include | 4 +- .../plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm | 14 ++-- os-plugins/plugins/vmgrid/XX_vmgrid.sh | 29 +++---- os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 54 +++++++----- os-plugins/plugins/vmgrid/files/vmgrid | 10 ++- 10 files changed, 170 insertions(+), 141 deletions(-) delete mode 100644 os-plugins/plugins/virtualbox/files/VirtualBox.xml (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm index be7f2cb5..900d08a9 100644 --- a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm +++ b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm @@ -45,7 +45,8 @@ sub getInfo stateless client. End-of-Here precedence => 70, - required => [ qw( desktop ) ], + # headless mode does not require a desktop! + #required => [ qw( desktop ) ], }; } @@ -67,7 +68,7 @@ sub getAttrInfo should the 'virtualbox'-plugin be executed during boot? End-of-Here content_regex => qr{^(0|1)$}, - content_descr => '1 means active - 0 means inactive', + content_descr => '1 for active, 0 for inactive', default => '1', }, # attribute 'imagesrc' defines where we can find virtualbox images @@ -77,10 +78,9 @@ sub getAttrInfo description => unshiftHereDoc(<<' End-of-Here'), Where do we store our virtualbox images? NFS? Filesystem? End-of-Here - #TODO: check if the input is valid - #content_regex => qr{^(0|1)$}, - content_descr => 'Allowed values: local path or URI', - default => '', + content_regex => qr{^(/|nfs://)}, + content_descr => 'local path or URI or "-" (unset)', + default => undef, }, # attribute 'bridge' defines if bridged network mode should be # switched on @@ -92,10 +92,46 @@ sub getAttrInfo to the ethernet the host is connected to) be enabled End-of-Here content_regex => qr{^(0|1)$}, - content_descr => 'Allowed values: 0 or 1', + content_descr => '0 or 1', default => '1', }, - + # attribute 'mem' defines if memory should be forced + 'virtualbox::mem' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + Do you want to force a ralative amount of RAM? + (Not implemented right now!) + End-of-Here + content_regex => qr{^(\d\d??)$}, + content_descr => 'Between 0 - 99', + default => undef, + }, + # attribute 'kvm' defines if KVM modules should be forced + 'virtualbox::kvm' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + Do you want to force the usage of KVM modules where applicable? + (Not implemented right now!) + End-of-Here + content_regex => qr{^(0|1)$}, + content_descr => '0 or 1', + default => undef, + }, + # attribute 'tftpdir' defines TFTP dir for network boots /w NAT + 'virtualbox::tftpdir' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + Do you want to define a stage 4 TFTP dir for netwoork boots when + using NAT? + Hint: Mount your TFTP ro via NFS to a local dir + End-of-Here + content_regex => qr{^(/)}, + content_descr => 'local path or "-" (unset)', + default => undef, + }, }; } diff --git a/os-plugins/plugins/virtualbox/XX_virtualbox.sh b/os-plugins/plugins/virtualbox/XX_virtualbox.sh index 4599b197..07e58428 100644 --- a/os-plugins/plugins/virtualbox/XX_virtualbox.sh +++ b/os-plugins/plugins/virtualbox/XX_virtualbox.sh @@ -30,8 +30,9 @@ if [ -e ${CONFFILE} ]; then if [ $virtualbox_active -ne 0 2>/dev/null ]; then [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'virtualbox' os-plugin ..."; + # load general configuration - . /initramfs/machine-setup + . /etc/initramfs-setup # get source of virtualbox image server (get type, server and path) if strinstr "/" "${virtualbox_imagesrc}" ; then @@ -55,7 +56,7 @@ if [ -e ${CONFFILE} ]; then cp ${PLUGINDIR}/*.include ${PLUGINCONFDIR} # copy ${CONFFILE} to ${PLUGINCONFDIR} just in case cp ${CONFFILE} ${PLUGINCONFDIR} - + # # TODO: create rawdisk if requested # # create raw disk # for part in $(grep -qE " 44 | 45 " /etc/disk.partition); do diff --git a/os-plugins/plugins/virtualbox/files/VirtualBox.xml b/os-plugins/plugins/virtualbox/files/VirtualBox.xml deleted file mode 100644 index d9a36795..00000000 --- a/os-plugins/plugins/virtualbox/files/VirtualBox.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/os-plugins/plugins/virtualbox/files/machine.include b/os-plugins/plugins/virtualbox/files/machine.include index e11f95c5..125e45cd 100644 --- a/os-plugins/plugins/virtualbox/files/machine.include +++ b/os-plugins/plugins/virtualbox/files/machine.include @@ -1,5 +1,5 @@ # Include file (machine template) for run-virt.include of the virtualbox plugin -cat < "${machconfig}" @@ -110,7 +110,7 @@ cat < - + @@ -20,7 +20,7 @@ cat < - + diff --git a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm index c3186251..5ee52d0c 100644 --- a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm +++ b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm @@ -73,7 +73,7 @@ sub getAttrInfo End-of-Here content_regex => qr{^(vmware|virtualbox|qemukvm|xen)$}, #openvz|vserver - content_descr => 'possible values: vmware, virtualbox, qemukvm, xen', + content_descr => 'vmware, virtualbox, qemukvm, xen', #openvz, vserver default => undef, }, @@ -141,7 +141,7 @@ sub getAttrInfo (only if supported by plugin) End-of-Here content_regex => qr{^(0|1)$}, - content_descr => 'possible values: "0", "1" or "-" (for unset)', + content_descr => '"0", "1" or "-" (for unset)', default => undef, }, 'vmgrid::maxvcpus' => { @@ -153,7 +153,7 @@ sub getAttrInfo (only if supported by plugin) End-of-Here content_regex => qr{^(1|2|4|8|16)$}, - content_descr => 'possible values: 1, 2, 4, 8, 16', + content_descr => '1, 2, 4, 8, 16', default => undef, }, 'vmgrid::minvcpus' => { @@ -165,7 +165,7 @@ sub getAttrInfo (only if supported by plugin) End-of-Here content_regex => qr{^(1|2|4|8|16)$}, - content_descr => 'possible values: 1, 2, 4, 8, 16', + content_descr => '1, 2, 4, 8, 16', default => undef, }, 'vmgrid::memratio' => { @@ -183,7 +183,7 @@ sub getAttrInfo (only if supported by plugin) End-of-Here content_regex => qr{^(\d\d??,\d\d??,\d\d??,\d\d??,\d\d??,\d\d??)$}, - content_descr => 'vals: \d\d??,\d\d??,\d\d??,\d\d??,\d\d??,\d\d??', + content_descr => '\d\d??,\d\d??,\d\d??,\d\d??,\d\d??,\d\d??', default => '40,0,0,0,40,20', }, 'vmgrid::maxram' => { @@ -195,7 +195,7 @@ sub getAttrInfo (only if supported by plugin) End-of-Here content_regex => qr{^(1|2|3|4|5|6|7|8|9)}, - content_descr => 'values can be absolute or relative e.g. 512 or 50%', + content_descr => 'absolute or relative e.g. 512 or 50%', default => undef, }, 'vmgrid::minram' => { @@ -207,7 +207,7 @@ sub getAttrInfo (only if supported by plugin) End-of-Here content_regex => qr{^(1|2|3|4|5|6|7|8|9)}, - content_descr => 'values can be absolute or relative e.g. 512 or 50%', + content_descr => 'absolute or relative e.g. 512 or 50%', default => undef, }, }; diff --git a/os-plugins/plugins/vmgrid/XX_vmgrid.sh b/os-plugins/plugins/vmgrid/XX_vmgrid.sh index 39b8501a..3cac7c12 100644 --- a/os-plugins/plugins/vmgrid/XX_vmgrid.sh +++ b/os-plugins/plugins/vmgrid/XX_vmgrid.sh @@ -15,9 +15,6 @@ # include default directories . /etc/openslx.conf -# include functions -. /etc/functions - CONFFILE="/initramfs/plugin-conf/vmgrid.conf" PLUGINCONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/vmgrid VIRTUALIZATIONPLUGIN=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/virtualization @@ -37,7 +34,9 @@ if [ -f $CONFFILE ]; then [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'vmgrid' os-plugin ..." # load general configuration - . /initramfs/machine-setup + . /etc/initramfs-setup + # include functions + . /etc/functions testmkd ${PLUGINCONFDIR} # create folder for virtual virtualization plugin @@ -63,15 +62,14 @@ if [ -f $CONFFILE ]; then fi # create rw share - testmkd 1777 ${RWSHARE}/rwdir + testmkd ${RWSHARE} # bind mount id 45 to ${RWSHARE} if strinstr "id45" "${vmgrid_rwshare}" ; then id45part=$(grep " 45 " /etc/disk.partition | awk '{print $1}' | \ cut -f 3,3 -d /) if [ -n "${id45part}" ]; then - # use rwdir because we want to use rwimg.vdi as well - testmkd /mnt/media/${id45part}/vmgrid/rwdir - mount --bind -n /mnt/media/${id45part}/vmgrid/rwdir ${RWSHARE}/rwdir \ + testmkd /mnt/media/${id45part}/vmgrid + mount --bind -n /mnt/media/${id45part}/vmgrid ${RWSHARE} \ >>/tmp/vmgrid.log 2>&1 fi # mount nfs rw share @@ -88,20 +86,17 @@ if [ -f $CONFFILE ]; then fsmount ${rwshareprot} ${rwshareserv} ${rwsharepath} ${rwtarget} rw # hostname? host_name=${host_name:=$clientip} - # use rwdir because we want to use rwimg.vdi as well - testmkd ${RWSHAREMNT}/${host_name}/rwdir - mount --bind ${RWSHAREMNT}/${host_name}/rwdir ${RWSHARE}/rwdir \ + testmkd ${RWSHAREMNT}/${host_name} + mount --bind ${RWSHAREMNT}/${host_name} ${RWSHARE} \ >>/tmp/vmgrid.log 2>&1 fi else - # use rwdir because we want to use rwimg.vdi as well - testmkd 1777 /mnt/tmp/vmgrid/rwdir - mount --bind -n /mnt/tmp/vmgrid/rwdir ${RWSHARE}/rwdir \ - >>/tmp/vmgrid.log 2>&1 + testmkd /mnt/tmp/vmgrid + mount --bind -n /mnt/tmp/vmgrid ${RWSHARE} >>/tmp/vmgrid.log 2>&1 fi # chmod so that everybody can write - chmod -R 1777 ${RWSHARE} - echo "vmgrid_rwdir=${RWSHARE#/mnt}" >> ${PLUGINCONFDIR}/vmgrid.conf + chmod 1777 ${RWSHARE} + echo "vmgrid_rwmnt=${RWSHARE#/mnt}" >> ${PLUGINCONFDIR}/vmgrid.conf # TODO: virtual virtualization plugin diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index ac1dd8fd..c300e9ce 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -38,14 +38,13 @@ RWSHARE=/var/opt/openslx/plugins/vmgrid/share ################################################################################ # function to write to stdout and logfile -mkdir -m 1777 -p ${RWSHARE}/var/log/openslx 2>/dev/null writelog () { # write to stdout echo -e "$1" # log into file echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log # log into share dir, so that log is available in vm as well - echo -e "$1" >> ${RWSHARE}/var/log/openslx/run-vmgrid.${USER}.$$.log + echo -e "$1" >> ${vmgrid_rwmnt}/logs/run-vmgrid.${USER}.$$.log } ################################################################################ @@ -81,6 +80,11 @@ if ! [ -r "${xmlfile}" ]; then exit 1 fi +# start to log, create shrare log dir +mkdir -m 1777 -p ${vmgrid_rwmnt}/logs +echo "Starting to log at $(date)" \ + >${vmgrid_rwmnt}/logs/run-vmgrid.${USER}.$$.log + # test how many instances running runningvms=$(ps aux | grep "run-vmgrid.sh " | grep -v grep | wc -l) runningvms=$(expr ${runningvms} - 1) @@ -131,8 +135,7 @@ writelog "Starting configuration..." writelog "\tVM-ID:\t\t\t${VM_ID}" writelog "\tLogfile:\t\t${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log" writelog "\t/tmp info:\t\t$(df -h | grep " /tmp$" | awk '{print $2}') \c" -writelog " $(grep "/tmp " /proc/mounts) $(df -h | \ - grep " /tmp$" | awk '{print $2}')" +writelog "$(grep "/tmp " /proc/mounts | awk '{print $1" "$2" "$3" "$4}')" writelog "\tVM XML dir:\t\t${vmgrid_xmlpath}" writelog "\tVM Image dir:\t\t${vmgrid_imgpath}" @@ -149,42 +152,47 @@ writelog "VM config:" imgname=$(grep -io '/dev/null | grep '/' >/dev/null 2>&1; then imgpath=$(dirname ${imgname}) imgname=$(basename ${imgname}) + vmpath=${imgpath}/${imgname} else imgpath=${vmgrid_imgpath} + vmpath=${imgpath}/${imgname} fi -# set default v path -vmpath=${imgpath}/${imgname} # check if virtual machine container file exists, only if not rwimg -if ! [ -e $vmpath ] && ! [ "${imgmode}" = "rwimg" ]; then +if ! [ -e "${vmpath}" ] && [ "${imgmode}" != "rwimg" ]; then writelog "\tVirtual machine image or directory ${vmpath} not found!" exit 1 fi writelog "\tVM file/dir:\t\t$vmpath" -# name of the virt machine, sed because of Windows formatting -vm_name=$(grep -o 'short_description param=.*"' ${xmlfile} | \ - sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}') -# if ${vm_name} not defined use ${imgname} -vm_name=${vm_name:-"${imgname%.*}"} -# define vm_shortname since vm_name can be very long -vm_shortname=$(echo ${imgname%.*} | sed -e "s, ,-,g") -# vm_name = displayname, define for old scripts -displayname=${vm_name} - # is there an additional configuration provided? additional_config=$(grep -o 'additional_config param=.*"' ${xmlfile} | \ sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}') @@ -289,7 +297,9 @@ scsi="FALSE" hddrv="ide" # add rw share -sharepath="${vmgrid_rwdir}/rwdir" +sharepath="${vmgrid_rwmnt}/folders/${vm_shortname}" +mkdir -p ${sharepath} +chmod 1777 "${vmgrid_rwmnt}/folders" sharename="share" # set hostname: using original hostname and adding string @@ -319,7 +329,9 @@ fi # start headless if [ -n "${VIRTCMDHL}" ]; then writelog "Starting ${vmgrid_virt} headless..." - ${VIRTCMDHL} ${VIRTCMDOPTSHL} + # TODO: for testing use VBox + VirtualBox + #${VIRTCMDHL} ${VIRTCMDOPTSHL} else writelog "${vmgrid_virt}: No headless mode defined, exiting!" exit 1 diff --git a/os-plugins/plugins/vmgrid/files/vmgrid b/os-plugins/plugins/vmgrid/files/vmgrid index b8806ab3..b60d8902 100644 --- a/os-plugins/plugins/vmgrid/files/vmgrid +++ b/os-plugins/plugins/vmgrid/files/vmgrid @@ -51,20 +51,24 @@ RWSHARE=/var/opt/openslx/plugins/vmgrid/share ################################################################################ # function to write to stdout and logfile -mkdir -m 1777 -p ${RWSHARE}/var/log/openslx 2>/dev/null writelog () { # write to stdout echo -e "$1" # log into file echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log # log into share dir, so that log is available in vm as well - echo -e "$1" >> ${RWSHARE}/var/log/openslx/run-vmgrid.${USER}.$$.log + echo -e "$1" >> ${vmgrid_rwmnt}/logs/run-vmgrid.${USER}.$$.log } ################################################################################ ### Configure VMs for autostart and set RAM ################################################################################ +# start to log, create shrare log dir +mkdir -m 1777 -p ${vmgrid_rwmnt}/logs +echo "Starting to log at $(date)" \ + >${vmgrid_rwmnt}/logs/run-vmgrid.${USER}.$$.log + # remove blanks vmgrid_memratio=$(echo ${vmgrid_memratio} | sed -e "s, *,,g") vmgrid_startvms=$(echo ${vmgrid_startvms} | sed -e "s, *,,g") @@ -109,7 +113,7 @@ vmsumratios=0 for i in {1..4}; do vm[$i]=$(echo ${vmgrid_startvms} | awk -F ',' '{print $1}') # remove ${vm[$i]} from list because of '{print $1}' - vmgrid_startvms=$(echo ${vmgrid_startvms} | sed -e "s/${vm[$i]},*//") + vmgrid_startvms=$(echo ${vmgrid_startvms} | sed -e "s,${vm[$i]}\,*,,") vmratio[$i]=$(echo ${vmgrid_memratio} | awk -F ',' '{print $1}') # remove ${vmratio[$i]} from list because of '{print $1}' vmgrid_memratio=$(echo ${vmgrid_memratio} | sed -e "s/${vmratio[$i]},*//") -- cgit v1.2.3-55-g7522 From 1f29892fec8d5a131dd5f9ff7971b7a902eabce6 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Mon, 29 Mar 2010 22:56:08 +0200 Subject: vmgrid graphical mode ;) --- .../virtualbox/OpenSLX/OSPlugin/virtualbox.pm | 1 - .../plugins/virtualbox/files/run-virt.include | 2 +- .../plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm | 80 +++++++++++++++++++++- os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 57 ++++++++++----- os-plugins/plugins/vmgrid/files/vmgrid | 11 ++- 5 files changed, 127 insertions(+), 24 deletions(-) (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm index 900d08a9..5d8206cd 100644 --- a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm +++ b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm @@ -200,7 +200,6 @@ sub checkStage3AttrValues sub _writeRunlevelScript { my $self = shift; - my $initfile = newInitFile(); my $script = ""; diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index 6d300044..8543e376 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -125,7 +125,7 @@ if echo "${imgmode}" | grep -q rw; then exit 1 # image rw? elif ! [ -w ${vmpath} ]; then - writelog "You defined mode rw, but image is not rw! \c" + writelog "You defined mode rw, but image ${vmpath} is not rw! \c" writelog "Please correct, exiting!" exit 1 fi diff --git a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm index 5ee52d0c..d73e0720 100644 --- a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm +++ b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm @@ -20,6 +20,7 @@ use base qw(OpenSLX::OSPlugin::Base); use OpenSLX::Basics; use OpenSLX::Utils; +use OpenSLX::DistroUtils; sub new { @@ -221,6 +222,8 @@ sub installationPhase my $pluginRepoPath = $info->{'plugin-repo-path'}; my $openslxBasePath = $info->{'openslx-base-path'}; + $self->_writeRunlevelScript(); + # copy all needed files now: my $pluginName = $self->{'name'}; my $pluginBasePath = "$openslxBasePath/lib/plugins/$pluginName/files"; @@ -240,5 +243,80 @@ sub removalPhase return; } -1; +# Write the runlevelscript +sub _writeRunlevelScript +{ + my $self = shift; + my $initfile = newInitFile(); + + $initfile->setName("vmgrid-slx"); + $initfile->setDesc("Setup environment for vmgrid. Part of OpenSLX vmgrid plugin."); + + # todo: Function need to be formated proper... not important right now + #$initfile->addFunction( + # 'running', + # 'lsmod | grep -q "$1[^_-]"' + #); + + # Is a VM running? + my $runningvms = unshiftHereDoc(<<' End-of-Here'); + if [ -e /tmp/vmgrid/vmgrid.pids ]; then + for pid in $(cat /tmp/vmgrid/vmgrid.pids); do + if ps aux | grep " ${pid} " | grep vmgrid; then + echo "Running: ${pid}" + fi + done + fi + End-of-Here + + # Kill all VMS! + my $killvms = unshiftHereDoc(<<' End-of-Here'); + if [ -e /tmp/vmgrid/vmgrid.pids ]; then + for pid in $(cat /tmp/vmgrid/vmgrid.pids); do + if ps aux | grep " ${pid} " | grep vmgrid; then + kill ${pid} + fi + done + fi + End-of-Here + # FORCE: Kill all VMS! + my $fkillvms = unshiftHereDoc(<<' End-of-Here'); + if [ -e /tmp/vmgrid/vmgrid.pids ]; then + for pid in $(cat /tmp/vmgrid/vmgrid.pids); do + if ps aux | grep " ${pid} " | grep vmgrid; then + kill -9 ${pid} + fi + done + fi + End-of-Here + + $initfile->addFunction( + 'start', + ' vmgrid', + ); + $initfile->addToCase( + 'kill', + 'killvms' + ); + $initfile->addToCase( + 'force-kill', + 'fkillvms' + ); + $initfile->addToCase( + 'status', + 'runningvms' + ); + $initfile->addToCase( + 'restart', + 'stop && start' + ); + + # get distro version +# my $distro = (split('-',$self->{'os-plugin-engine'}->distroName()))[0]; +# my $runlevelscript = getInitFileForDistro($initfile, $distro); +# +# spitFile("$self->{'pluginRepositoryPath'}/vmgrid-slx", $runlevelscript); +} + +1; diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index c300e9ce..21d7cbf8 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -51,13 +51,28 @@ writelog () { ### Get XML file and dir ################################################################################ -# check if forcemem set -if [ "$1" = "--forcemem" ]; then - forcemem=$2 - xmlfile=$3 -else - xmlfile=$1 -fi +# check if forcemem or graphical mode set +while [ $# -gt 0 ]; do + case "$1" in + -h|--help) + echo -e "Usage: run-vmgrid.sh [-g] [--forcemem ] \c" + echo -e "[/path/]filename[.xml]" + exit + ;; + -g) + headless=0 + ;; + --forcemem) + forcemem=$2 + shift + ;; + *) + xmlfile=$@ + break + ;; + esac + shift +done # absolute or relative path? if ls ${xmlfile} 2>/dev/null | grep '/' >/dev/null 2>&1; then @@ -75,8 +90,8 @@ xmlfile="${xmlpath}/${xmlfile%.xml}.xml" # test if the xml file is valid if ! [ -r "${xmlfile}" ]; then - echo -e "Usage: run-vmgrid.sh [--forcemem ] \c" - echo -e "[/path/]filename[.xml]" + writelog "${xmlfile} not a readable XML file!" + run-vmgrid.sh -h & exit 1 fi @@ -299,7 +314,7 @@ hddrv="ide" # add rw share sharepath="${vmgrid_rwmnt}/folders/${vm_shortname}" mkdir -p ${sharepath} -chmod 1777 "${vmgrid_rwmnt}/folders" +chmod -f 1777 "${vmgrid_rwmnt}/folders" sharename="share" # set hostname: using original hostname and adding string @@ -326,22 +341,28 @@ else exit 1 fi +# start graphical mode +if [ ${headless} -eq 0 2>/dev/null ]; then + if [ -z "${VIRTCMD}" ]; then + writelog "Grapical mode not available, exiting" + exit 1 + fi + writelog "Starting ${vmgrid_virt} in graphical mode..." + ${VIRTCMD} ${VIRTCMDOPTS} # start headless -if [ -n "${VIRTCMDHL}" ]; then - writelog "Starting ${vmgrid_virt} headless..." - # TODO: for testing use VBox - VirtualBox - #${VIRTCMDHL} ${VIRTCMDOPTSHL} +elif [ -n "${VIRTCMDHL}" ]; then + writelog "Starting ${vmgrid_virt} in headless mode..." + ${VIRTCMDHL} ${VIRTCMDOPTSHL} else writelog "${vmgrid_virt}: No headless mode defined, exiting!" exit 1 fi -writelog "${vmgrid_virt} exited. Cleanning up...\c" if echo "${RMDIRS}" 2>/dev/null | grep ${vmgrid_virt} >/dev/null 2>&1; then + writelog "${vmgrid_virt} exited. Cleanning up...\c" rm -rf ${RMDIRS} >/dev/null 2>&1 + writelog "done" fi -writelog "done" -writelog "Bye." +echo -e "Bye." exit 0 diff --git a/os-plugins/plugins/vmgrid/files/vmgrid b/os-plugins/plugins/vmgrid/files/vmgrid index b60d8902..d93f4fbd 100644 --- a/os-plugins/plugins/vmgrid/files/vmgrid +++ b/os-plugins/plugins/vmgrid/files/vmgrid @@ -24,11 +24,13 @@ if [ -n "$1" ]; then if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then - echo "Usage: vmgrid [[/path/]filename[.xml]]" + echo -e "Usage: vmgrid [[-g] [--forcemem ] \c" + echo -e "[/path/]filename[.xml]]" exit 0 else - run-vmgrid.sh $@ & - exit 0 + echo "Starting run-vmgrid.sh with options '$@'" + run-vmgrid.sh $@ + exit fi fi @@ -66,6 +68,8 @@ writelog () { # start to log, create shrare 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 @@ -153,6 +157,7 @@ for i in {1..4}; do else writelog "Starting ${vm[$i]} via run-vmgrid.sh with ${vmmem[$i]} MB RAM" run-vmgrid.sh --forcemem ${vmmem[$i]} ${vm[$i]} & + echo $! > /tmp/vmgrid/${USER}/vmgrid.pids # wait 5 secs for the next vm to start sleep 5 fi -- cgit v1.2.3-55-g7522 From 9a95c0c2d4a6382683725d5be0ab9171f9aed828 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Tue, 30 Mar 2010 20:11:25 +0200 Subject: diskless boot + minor modifications, virtualization.conf /w freemem --- .../plugins/virtualbox/files/machine.include | 2 +- .../plugins/virtualbox/files/run-virt.include | 61 ++++++++--------- os-plugins/plugins/vmgrid/XX_vmgrid.sh | 23 ++++++- os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 78 +++++++++++++--------- os-plugins/plugins/vmgrid/files/vmgrid | 8 +-- 5 files changed, 100 insertions(+), 72 deletions(-) (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/virtualbox/files/machine.include b/os-plugins/plugins/virtualbox/files/machine.include index 125e45cd..78c4bee8 100644 --- a/os-plugins/plugins/virtualbox/files/machine.include +++ b/os-plugins/plugins/virtualbox/files/machine.include @@ -111,7 +111,7 @@ cat << EOF > "${machconfig}" - + /d" ${machconfig} +fi + # add ssh port if linux and NAT if [ "${vmostype}" = "Linux26" ] && [ "${network_kind}" = "NAT" ]; then vmsshport="220${VM_ID}" @@ -322,33 +331,17 @@ fi # wait for a certain command to settle # get the PID of the right process -# TODO: not very good! But seems to work -# TODO: not needed? KILL!!! +# kill PID, seems to work VBMANPID=$(pstree -p | grep VBoxXPCOMIPCD | grep -ivE "VirtualBox|VBoxHeadless"\ | sed -e "s/.*VBoxXPCOMIPCD(\(.*\)).*/\1/") for i in $(echo ${VBMANPID}); do kill -9 ${VBMANPID} >/dev/null 2>&1 done -# TODO: OLD Version, NOW: KILL process -#VBMANPID=$(pstree -p | grep VBoxXPCOMIPCD | grep -ivE "VirtualBox|VBoxHeadless"\ -# | sed -e "s/.*VBoxXPCOMIPCD(\(.*\)).*/\1/" | tail -n 1) -#for i in {0..999}; do -# ps aux | grep -v grep | grep VBoxXPCOMIPCD | grep -q " ${VBMANPID} " || break -# if [ $i -eq 999 ]; then -# kill -9 ${VBMANPID} >/dev/null 2>&1 -# writelog "Process ID ${VBMANPID} did not finish, killing!" -# fi -#done # set the variables appropriately (several interfaces with different names) VIRTCMD=$(which VirtualBox 2>/dev/null) VIRTCMDOPTS="--startvm ${machineuuid} --start-running" -# SDL tests -#VIRTCMDSDL=$(which VBoxSDL 2>/dev/null) -#VIRTCMDOPTSSDL="--startvm ${machineuuid} --fullscreen --hwvirtex --memory 1024 \ -# --fixedmode 1680 1050 24 --hostkey 302 0" - # set headless mode VIRTCMDHL=$(which VBoxHeadless 2>/dev/null) VIRTCMDOPTSHL="-s ${machineuuid}" diff --git a/os-plugins/plugins/vmgrid/XX_vmgrid.sh b/os-plugins/plugins/vmgrid/XX_vmgrid.sh index 3cac7c12..d9e35dfb 100644 --- a/os-plugins/plugins/vmgrid/XX_vmgrid.sh +++ b/os-plugins/plugins/vmgrid/XX_vmgrid.sh @@ -39,8 +39,6 @@ if [ -f $CONFFILE ]; then . /etc/functions testmkd ${PLUGINCONFDIR} - # create folder for virtual virtualization plugin - testmkd ${VIRTUALIZATIONPLUGIN} testmkd ${VIRTDIR} cp $CONFFILE ${PLUGINCONFDIR}/vmgrid.conf # create link to binpath @@ -98,7 +96,26 @@ if [ -f $CONFFILE ]; then chmod 1777 ${RWSHARE} echo "vmgrid_rwmnt=${RWSHARE#/mnt}" >> ${PLUGINCONFDIR}/vmgrid.conf - # TODO: virtual virtualization plugin + # 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 ..." diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index 21d7cbf8..e1b2ffe6 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -52,6 +52,7 @@ writelog () { ################################################################################ # check if forcemem or graphical mode set +headless=1 while [ $# -gt 0 ]; do case "$1" in -h|--help) @@ -109,7 +110,7 @@ if [ $runningvms -le 0 ]; then exit 1 fi # check if vmchooser plugin installed -if [ ${vmchooser_active} -eq 1 2>/dev/null ] && [ ${runningvms} -gt 1 ]; then +if [ -n "${vmchooser_active}" ] && [ ${runningvms} -gt 1 ]; then # only allow one instance of vmgrid writelog "Already 1 VMs running and vmchooser plugin is active." writelog "Can't start ${xmlfile}, exiting!" @@ -151,8 +152,7 @@ writelog "\tVM-ID:\t\t\t${VM_ID}" writelog "\tLogfile:\t\t${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log" writelog "\t/tmp info:\t\t$(df -h | grep " /tmp$" | awk '{print $2}') \c" writelog "$(grep "/tmp " /proc/mounts | awk '{print $1" "$2" "$3" "$4}')" -writelog "\tVM XML dir:\t\t${vmgrid_xmlpath}" -writelog "\tVM Image dir:\t\t${vmgrid_imgpath}" +writelog "\tVM XML dir:\t\t$(dirname ${xmlfile})" if ! grep '/dev/null 2>&1; then writelog \ @@ -167,45 +167,66 @@ writelog "VM config:" imgname=$(grep -io '/dev/null | grep '/' >/dev/null 2>&1; then +# diskless boot +elif [ "${boot}" = "n" ] && [ -z "${imgname}" ]; then + diskless=1 + vmpath="{diskless boot}" +# imagename /w full path +elif echo ${imgname} 2>/dev/null | grep -q '/' >/dev/null 2>&1; then imgpath=$(dirname ${imgname}) imgname=$(basename ${imgname}) vmpath=${imgpath}/${imgname} +# get path from var else imgpath=${vmgrid_imgpath} vmpath=${imgpath}/${imgname} fi # check if virtual machine container file exists, only if not rwimg -if ! [ -e "${vmpath}" ] && [ "${imgmode}" != "rwimg" ]; then +if ! [ -e "${vmpath}" ] && [ "${imgmode}" != "rwimg" ] && [ ${diskless} -eq 0 ]; +then writelog "\tVirtual machine image or directory ${vmpath} not found!" exit 1 fi +# name of the virt machine, sed because of Windows formatting +vm_name=$(grep -o 'short_description param=.*"' ${xmlfile} | \ + sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}') + +# define vm_shortname since vm_name can be very long +if [ -n "${imgname}" ]; then + # if ${vm_name} not defined use ${imgname} + vm_name=${vm_name:-"${imgname%.*}"} + vm_shortname=$(basename ${imgname%.*} | sed -e "s, ,-,g") +elif [ -n "${vm_name}" ]; then + vm_shortname=$(echo ${vm_name} | awk '{print $1" "$2" "$3}' \ + | sed -e "s, ,-,g;s,-$,,;s,-$,,") +else + vm_name=$(date | md5sum | awk '{print $1}') + vm_shortname=${vm_name} +fi +# vm_name = displayname, define for old scripts +displayname=${vm_name} + +[ "${imgmode}" != "rwimg" ] && [ ${diskless} -eq 0 ] \ + && writelog "\tVM Image dir:\t\t${imgpath}" writelog "\tVM file/dir:\t\t$vmpath" # is there an additional configuration provided? @@ -253,7 +274,7 @@ elif [ -z "${xmlvirt}" ]; then writelog "result:\t${xmlvirt}" fi -# TODO: confs von openvz lesen? +# check for virt if [ "${vmgrid_virt}" != "${xmlvirt}" ]; then writelog "\tThe virtual machine specified in ${xmlfile}" writelog "\tdoes not match the virtualization used here (${vmgrid_virt})" @@ -269,9 +290,6 @@ network_kind=$(grep -io 'network param=.*"' ${xmlfile} | \ network_card=$(grep -io 'netcard param=.*"' ${xmlfile} | \ awk -F '"' '{ print $2 }') -# get boot attr -boot=$(grep -io 'boot param=.*"' ${xmlfile} | awk -F '"' '{ print $2 }') - writelog "\tVirtualization:\t\t$xmlvirt" writelog "\tVM name:\t\t$vm_name" writelog "\tVM short name:\t\t$vm_shortname" @@ -342,24 +360,24 @@ else fi # start graphical mode -if [ ${headless} -eq 0 2>/dev/null ]; then +if [ ${headless} -eq 0 ]; then if [ -z "${VIRTCMD}" ]; then - writelog "Grapical mode not available, exiting" + writelog "Grapical mode not available, exiting!" exit 1 fi writelog "Starting ${vmgrid_virt} in graphical mode..." - ${VIRTCMD} ${VIRTCMDOPTS} + ${VIRTCMD} ${VIRTCMDOPTS} 2>/dev/null # start headless elif [ -n "${VIRTCMDHL}" ]; then writelog "Starting ${vmgrid_virt} in headless mode..." - ${VIRTCMDHL} ${VIRTCMDOPTSHL} + ${VIRTCMDHL} ${VIRTCMDOPTSHL} 2>/dev/null else writelog "${vmgrid_virt}: No headless mode defined, exiting!" exit 1 fi -if echo "${RMDIRS}" 2>/dev/null | grep ${vmgrid_virt} >/dev/null 2>&1; then - writelog "${vmgrid_virt} exited. Cleanning up...\c" +if echo "${RMDIRS}" 2>/dev/null | grep -q ${vmgrid_virt}; then + writelog "${vmgrid_virt} exited. Cleanning up... \c" rm -rf ${RMDIRS} >/dev/null 2>&1 writelog "done" fi diff --git a/os-plugins/plugins/vmgrid/files/vmgrid b/os-plugins/plugins/vmgrid/files/vmgrid index d93f4fbd..b75b5341 100644 --- a/os-plugins/plugins/vmgrid/files/vmgrid +++ b/os-plugins/plugins/vmgrid/files/vmgrid @@ -29,7 +29,7 @@ if [ -n "$1" ]; then exit 0 else echo "Starting run-vmgrid.sh with options '$@'" - run-vmgrid.sh $@ + run-vmgrid.sh $@ 2>/dev/null exit fi fi @@ -90,7 +90,7 @@ if [ ${hostmem} -lt 256 2>/dev/null ]; then fi # get other vm mem -if [ ${vmchooser_active} -eq 1 ]; then +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 @@ -156,10 +156,10 @@ 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]} & + run-vmgrid.sh --forcemem ${vmmem[$i]} ${vm[$i]} 2>/dev/null & echo $! > /tmp/vmgrid/${USER}/vmgrid.pids # wait 5 secs for the next vm to start - sleep 5 + sleep 10 fi fi done -- cgit v1.2.3-55-g7522 From b61aa15b79765c51afc35946867e17ecc4ff8704 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Wed, 31 Mar 2010 22:44:38 +0200 Subject: xen bridge change + xennet TODO: load xennet --- os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 36 +++++++++---------- os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm | 6 ++-- os-plugins/plugins/xen/XX_xen.sh | 2 +- .../init-hooks/20-nw-bridge-config/xen-bridge.sh | 42 ---------------------- 4 files changed, 23 insertions(+), 63 deletions(-) delete mode 100755 os-plugins/plugins/xen/init-hooks/20-nw-bridge-config/xen-bridge.sh (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index e1b2ffe6..4c5ecbb9 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -164,12 +164,12 @@ writelog "\tXML file:\t\t$xmlfile" writelog "VM config:" # name of the virt image or dir -imgname=$(grep -io '/proc/sys/kernel/printk echo "/sbin/mdev" >/proc/sys/kernel/hotplug modprobe -a ${MODPRV} usbhid hid-bright 2>/dev/null & nwcardlist=$(echo ${slxconf_listnwmod}|sed "s/\ /|/g") -hwinfo --netcard --usb-ctrl | grep modprobe | grep -E "$nwcardlist|hcd" | \ +# save results for later info and for Xen plugin when starting Xen VM +hwinfo --netcard --usb-ctrl >/etc/hwinfo.netcard-usbctrl +grep modprobe /etc/hwinfo.netcard-usbctrl | grep -E "$nwcardlist|hcd" | \ grep -v ehci | sed 's/.* Cmd: "//;s/"//' | sort -u >/etc/modprobe.base # virtio hack if [ $(grep -ic "virtio_pci" /etc/modprobe.base) -ge 1 ]; then diff --git a/os-plugins/plugins/qemukvm/files/run-virt.include b/os-plugins/plugins/qemukvm/files/run-virt.include index 84e534e8..7db2bfc9 100644 --- a/os-plugins/plugins/qemukvm/files/run-virt.include +++ b/os-plugins/plugins/qemukvm/files/run-virt.include @@ -46,7 +46,7 @@ diskfile=${vmpath} # check the file type if echo ${imgname} | grep -iE "img|qcow|vmdk" >/dev/null 2>&1; then - imgtype=$(echo ${imgname#*.} | tr [a-z] [A-Z]) + imgtype=$(echo ${imgname##*.} | tr [a-z] [A-Z]) else writelog "${imgname} is not a valid image type (img|qcow*|vmdk), exiting!" exit 1 @@ -115,7 +115,7 @@ VIRTCMDOPTS="${VIRTCMDOPTS} -m ${mem}" # network adaptor alternatives: rtl8139, pcnet, e1000 network_card=${network_card:=pcnet} -VIRTCMDOPTS="${VIRTCMDOPTS} -net nic,model=${network_card}" +VIRTCMDOPTS="${VIRTCMDOPTS} -net nic,macaddr=${macaddr},model=${network_card}" # define net kind and apply script qemu_ifscripts="script=${PLUGINDIRQK}/ifup,downscript=${PLUGINDIRQK}/ifdown" @@ -135,6 +135,25 @@ case "${network_kind}" in ;; esac +# translate boot, use if set else set to HardDisk +if [ -n "${boot}" ]; then + case ${boot} in + n*) # usually support for a,c,d,n, stands for Floppy, HD, CD-ROM, Network + boot="n" + # TODO: does not work yet, can be removed if tap1 solution better + if [ "${network_kind}" = "user" ] && [ -n "${virtualbox_tftpdir}" ]; then + VIRTCMDOPTS="${VIRTCMDOPTS},tftp=${virtualbox_tftpdir}" + fi + ;; + # later maybe c|disk|hd*|sd*) for HD and d|cd*) for CD-ROM + *) + boot="c" + ;; + esac +else + boot="c" +fi + # external GUI port vncport="590${VM_ID}" @@ -237,17 +256,15 @@ writelog "\tNetwork kind:\t\t${network_kind}" #-show-cursor show cursor # check for kvm modules -if [ -n "${kvm}" ]; then - if [ -e /dev/kvm ]; then - for tool in kvm qemu-kvm; do - VIRTCMD=$(which ${tool} 2>/dev/null) - [ -n "$VIRTCMD" ] && break - done - else - VIRTCMD=$(which qemu 2>/dev/null) - writelog "KVM available but /dev/kvm not found!" - writelog "Trying fallback to QEMU emulation." - fi +if [ -c /dev/kvm ]; then + for tool in kvm qemu-kvm; do + VIRTCMD=$(which ${tool} 2>/dev/null) + [ -n "$VIRTCMD" ] && break + done +else + VIRTCMD=$(which qemu 2>/dev/null) + writelog "KVM available but /dev/kvm not found!" + writelog "Trying fallback to QEMU emulation." fi if [ -z "${VIRTCMD}" ]; then diff --git a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm index 5d8206cd..f8fad1ba 100644 --- a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm +++ b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm @@ -84,6 +84,8 @@ sub getAttrInfo }, # attribute 'bridge' defines if bridged network mode should be # switched on + # TODO: change to net -> nat, bridge, hostonly? + # TODO: since we use def in XML maybe use to override 'virtualbox::bridge' => { applies_to_systems => 1, applies_to_clients => 1, @@ -139,7 +141,7 @@ sub installationPhase { my $self = shift; my $info = shift; - + $self->{pluginRepositoryPath} = $info->{'plugin-repo-path'}; $self->{pluginTempPath} = $info->{'plugin-temp-path'}; $self->{openslxBasePath} = $info->{'openslx-base-path'}; @@ -147,7 +149,7 @@ sub installationPhase $self->{attrs} = $info->{'plugin-attrs'}; my $engine = $self->{'os-plugin-engine'}; - + # Different names of the tool (should be unified somehow!?) if (!isInPath('VirtualBox')) { # todo: fix this @@ -170,7 +172,7 @@ sub installationPhase foreach my $file ( qw( run-virt.include virtualbox.include machine.include empty-diff.vdi.gz rwimg.vdi.gz ) ) { copyFile("$pluginBasePath/$file", "$self->{pluginRepositoryPath}/"); - chmod 0755, "$self->{pluginRepositoryPath}/$file"; + chmod 0644, "$self->{pluginRepositoryPath}/$file"; } return; diff --git a/os-plugins/plugins/virtualbox/files/machine.include b/os-plugins/plugins/virtualbox/files/machine.include index 78c4bee8..a76c7e6f 100644 --- a/os-plugins/plugins/virtualbox/files/machine.include +++ b/os-plugins/plugins/virtualbox/files/machine.include @@ -2,7 +2,7 @@ cat << EOF > "${machconfig}" - + @@ -15,7 +15,7 @@ cat << EOF > "${machconfig}" - + diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index f904b5f2..abf1e0be 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -185,16 +185,21 @@ else fi # translate network cards -if [ "${network_card}" = "e1000" ]; then - vb_network_card="82540EM" -else - network_card="pcnet" - vb_network_card="Am79C973" -fi +case "${network_card}" in + e1000) + vb_network_card="82540EM" + ;; + virtio) + vb_network_card="virtio" + ;; + *) + network_card="pcnet" + vb_network_card="Am79C973" +esac # translate network kinds (nat, bridged, host-only) case "${network_kind}" in - bridged) + bridge*) network_kind='BridgedInterface name="br0"' ;; hostonly|host-only) @@ -204,6 +209,33 @@ case "${network_kind}" in network_kind="NAT" esac +# translate boot, use if set else set to HardDisk +# usually support for a,c,d,n, stands for Floppy, HD, CD-ROM, Network +# support nfs and tftp as well +if [ -n "${boot}" ]; then + case ${boot} in + n*|tftp) + boot="Network" + if [ "${network_kind}" = "NAT" ] && [ -n "${virtualbox_tftpdir}" ]; then + # remove spaces from VM name to avoid Problems /w TFTP in NAT + vm_name=$(echo ${vm_name} | sed -e "s, ,-,g") + # link TFTP dir for NAT TFTP boots + mkdir -p ${confdir}/TFTP + cp ${virtualbox_tftpdir}/pxelinux.0 ${confdir}/TFTP/${vm_name}.pxe + for i in $(ls ${virtualbox_tftpdir}); do + ln -sf ${virtualbox_tftpdir}/${i} ${confdir}/TFTP/${i} + done + fi + ;; + # later maybe c|disk|hd*|sd*) for HD and d|cd*) for CD-ROM + *) + boot="HardDisk" + ;; + esac +else + boot="HardDisk" +fi + # external GUI vrdpport="590${VM_ID}" @@ -232,31 +264,6 @@ cdrom1=${cdtest:-"FALSE"} ide="TRUE" hddrv="ide" -# translate boot, use if set else set to HardDisk -if [ -n "${boot}" ]; then - case ${boot} in - n*) # usually support for a,c,d,n, stands for Floppy, HD, CD-ROM, Network - boot="Network" - if [ "${network_kind}" = "NAT" ] && [ -n "${virtualbox_tftpdir}" ]; then - # remove spaces from VM name to avoid Problems /w TFTP in NAT - vm_name=$(echo ${vm_name} | sed -e "s, ,-,g") - # link TFTP dir for NAT TFTP boots - mkdir -p ${confdir}/TFTP - cp ${virtualbox_tftpdir}/pxelinux.0 ${confdir}/TFTP/${vm_name}.pxe - for i in $(ls ${virtualbox_tftpdir}); do - ln -sf ${virtualbox_tftpdir}/${i} ${confdir}/TFTP/${i} - done - fi - ;; - # later maybe c|disk|hd*|sd*) for HD and d|cd*) for CD-ROM - *) - boot="HardDisk" - ;; - esac -else - boot="HardDisk" -fi - [ ${diskless} -eq 0 ] && writelog "\tSnapshots dir:\t\t$snapshotdir" writelog "Diskimage:" [ ${diskless} -eq 0 ] && writelog "\tDisk file:\t\t$diskfile" diff --git a/os-plugins/plugins/virtualbox/files/virtualbox.include b/os-plugins/plugins/virtualbox/files/virtualbox.include index 49b3ce61..09a2f33b 100644 --- a/os-plugins/plugins/virtualbox/files/virtualbox.include +++ b/os-plugins/plugins/virtualbox/files/virtualbox.include @@ -13,7 +13,7 @@ cat << EOF > "${confdir}/VirtualBox.xml" - + diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index 4c5ecbb9..716371d5 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -103,7 +103,13 @@ echo "Starting to log at $(date)" \ # test how many instances running runningvms=$(ps aux | grep "run-vmgrid.sh " | grep -v grep | wc -l) +# 2 steps, /w only one is seems not to work runningvms=$(expr ${runningvms} - 1) +# if Xen use different method +if [ "${vmgrid_virt}" = "xen" ]; then + runningvms=$(xm list 2>/dev/null | grep -vE "Domain-0|Name.*ID" | wc -l) + runningvms=$(expr ${runningvms} + 1) +fi # check value if [ $runningvms -le 0 ]; then writelog "Error in value: Running VMs: ${runningvms}. Exit!" @@ -189,7 +195,7 @@ elif [ "${boot}" = "n" ] && [ -z "${imgname}" ]; then diskless=1 vmpath="{diskless boot}" # imagename /w full path -elif echo ${imgname} 2>/dev/null | grep -q '/' >/dev/null 2>&1; then +elif echo ${imgname} 2>/dev/null | grep -q '^/' >/dev/null 2>&1; then imgpath=$(dirname ${imgname}) imgname=$(basename ${imgname}) vmpath=${imgpath}/${imgname} @@ -209,19 +215,12 @@ fi # name of the virt machine, sed because of Windows formatting vm_name=$(grep -o 'short_description param=.*"' ${xmlfile} \ | sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}') +# if ${vm_name} not defined use ${xmlfile} +vm_name=${vm_name:-${xmlfile%.xml}} # define vm_shortname since vm_name can be very long -if [ -n "${imgname}" ]; then - # if ${vm_name} not defined use ${imgname} - vm_name=${vm_name:-"${imgname%.*}"} - vm_shortname=$(basename ${imgname%.*} | sed -e "s, ,-,g") -elif [ -n "${vm_name}" ]; then - vm_shortname=$(echo ${vm_name} | awk '{print $1"-"$2"-"$3}' \ - | sed -e "s,-$,,;s,-$,,") -else - vm_name=$(date | md5sum | awk '{print $1}') - vm_shortname=${vm_name} -fi +vm_shortname=$(basename ${xmlfile%.xml} | sed -e "s, ,-,g") + # vm_name = displayname, define for old scripts displayname=${vm_name} @@ -376,6 +375,7 @@ else exit 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" rm -rf ${RMDIRS} >/dev/null 2>&1 diff --git a/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm b/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm index 99993e23..8af752b4 100644 --- a/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm +++ b/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm @@ -62,9 +62,63 @@ sub getAttrInfo # set active to 0, later set specially created Xen system to 1 default => '0', }, + # attribute 'imagesrc' defines where we can find xen images + 'xen::imagesrc' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + Where do we store our xen images? NFS? Filesystem? + End-of-Here + content_regex => qr{^(/|nfs://)}, + content_descr => 'local path or URI or "-" (unset)', + default => undef, + }, + # attribute 'tftpdir' defines TFTP dir for network boots /w NAT + 'xen::tftpdir' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + Do you want to define a stage 4 TFTP dir for netwoork boots? + Needed to boot Xen via NFS, we only need the initramfs + Hint: Mount your TFTP ro via NFS to a local dir + End-of-Here + content_regex => qr{^(/)}, + content_descr => 'local path or "-" (unset)', + default => undef, + }, }; } +sub installationPhase +{ + my $self = shift; + my $info = shift; + + $self->{pluginRepositoryPath} = $info->{'plugin-repo-path'}; + $self->{openslxBasePath} = $info->{'openslx-base-path'}; + + # 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 machine.include hvm.include ) ) { + copyFile("$pluginBasePath/$file", "$self->{pluginRepositoryPath}/"); + chmod 0644, "$self->{pluginRepositoryPath}/$file"; + } + + return; +} + +sub removalPhase +{ + my $self = shift; + my $info = shift; + + return; +} + sub suggestAdditionalKernelModules { my $self = shift; @@ -74,7 +128,6 @@ sub suggestAdditionalKernelModules # Xen needs bridge module, for guests xennet and maybe xenblk # earlier versions needed netloop - # TODO: xennet laden push @suggestedModules, qw( bridge xennet xenblk ); return @suggestedModules; diff --git a/os-plugins/plugins/xen/XX_xen.sh b/os-plugins/plugins/xen/XX_xen.sh index 610a3cfb..af3f6cc4 100644 --- a/os-plugins/plugins/xen/XX_xen.sh +++ b/os-plugins/plugins/xen/XX_xen.sh @@ -18,18 +18,56 @@ . /etc/openslx.conf CONFFILE=/initramfs/plugin-conf/xen.conf +PLUGINCONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/xen +PLUGINDIR=/mnt/${OPENSLX_DEFAULT_DIR}/plugin-repo/xen +VIRTDIR=/mnt/${OPENSLX_DEFAULT_VIRTDIR}/xen +# check if the configuration file is available if [ -e ${CONFFILE} ]; then + + # load needed variables . ${CONFFILE} - if [ $xen_active -ne 0 ]; then + + # Test if this plugin is activated... more or less useless with the + # new plugin system + if [ $xen_active -ne 0 2>/dev/null ]; then + + [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'xen' os-plugin ..."; + + # load general configuration + . /etc/initramfs-setup + + # get source of xen image server (get type, server and path) + if strinstr "/" "${xen_imagesrc}" ; then + vbimgprot=$(uri_token ${xen_imagesrc} prot) + vbimgserv=$(uri_token ${xen_imagesrc} server) + vbimgpath="$(uri_token ${xen_imagesrc} path)" + fi + if [ -n "${vbimgserv}" ] ; then + # directory where qemu images are expected in + mnttarget=${VIRTDIR} + # mount the xen image source readonly (ro) + fsmount ${vbimgprot} ${vbimgserv} ${vbimgpath} ${mnttarget} ro + else + [ $DEBUGLEVEL -gt 1 ] && \ + error " * Incomplete information in variable ${xen_imagesrc}." \ + nonfatal + fi + + # copy virtualization include files to config dir + testmkd ${PLUGINCONFDIR} testmkd /mnt/var/log/xen testmkd /mnt/var/run/xend testmkd /mnt/var/run/xenstored + cp ${PLUGINDIR}/*.include ${PLUGINCONFDIR} + # copy ${CONFFILE} to ${PLUGINCONFDIR} just in case + cp ${CONFFILE} ${PLUGINCONFDIR} -# TODO: disable for testing purposes. suse 11.0 kills network -# rllinker "xendomains" 14 8 -# rllinker "xend" 13 9 + # activate init files # TODO: in xen-slx start - modprobe loop max_loop=64 + # increase loop devices for loop images + modprobe -q loop max_loop=64 >/tmp/xen.log 2>&1 + rllinker "xendomains" 14 8 + rllinker "xend" 13 9 fi fi diff --git a/os-plugins/plugins/xen/files/run-virt.include b/os-plugins/plugins/xen/files/run-virt.include index aeadf68e..40cca17a 100644 --- a/os-plugins/plugins/xen/files/run-virt.include +++ b/os-plugins/plugins/xen/files/run-virt.include @@ -36,19 +36,19 @@ mkdir -m 1777 /tmp/${self} 2>/dev/null # dir for configs confdir="/tmp/${self}/${USER}/${VM_ID}" # use vm_shortname for VM name since vm_name can be very long -vm_name=${vm_shortname} +# add id so we can start more tahn one of the same image +vm_name="${vm_shortname}-${VM_ID}" conffile=${confdir}/${vm_name} # define dirs and files which can be removed after exit, be carefull! -RMDIRS="${confdir}" 2>/dev/null -rm -rf ${RMDIRS} 2>/dev/null +rm -rf ${confdir} 2>/dev/null +mkdir -p ${confdir} 2>/dev/null # TODO: read from XML file -xen_kernel=/boot/vmlinuz-xen -xen_ramdisk=/initrd-xen -xen_root=/dev/sda1 -xen_extra=3 -xen_disk="file:${vmpath},sda1,r" -xen_vif="mac=$macaddr, bridge=xenbr0" +xen_kernel=${kernel:-"/boot/vmlinuz-xen"} +xen_ramdisk=${initramfs:-"/boot/initrd-xen"} +xen_extra="xencons=tty 3" +xen_disk="file:${vmpath},hda1,r" +xen_vif="mac=$macaddr, bridge=br0" xen_dhcp="dhcp" # off writelog "Directories:" @@ -99,8 +99,33 @@ else fi fi +xen::tftpdir +# translate boot, use if set else set to disk +if [ -n "${boot}" ]; then + case ${boot} in + n*|tftp) + if [ -n "${imgname}" ] && [ -n "${xen_tftpdir}" ]; then + root=/dev/nfs + tftp_label=$(grep -A 3 "^LABEL *${imgname}" \ + ${xen_tftpdir}/pxelinux.cfg/default 2>/dev/null \ + | grep "^ *KERNEL ") + xen_kernel="${xen_tftpdir}/$(echo ${tftp_label} \ + | awk -F " --- " '{print $2}' | awk '{print $1}')" + xen_ramdisk="${xen_tftpdir}/$(echo ${tftp_label} \ + | awk -F " --- " '{print $3}')" + fi + ;; + # later maybe c|disk|hd*|sd*) for HD and d|cd*) for CD-ROM + *) + xen_root=/dev/hda1 + ;; + esac +else + xen_root=/dev/hda1 +fi + writelog "Diskimage:" -writelog "\tMachine diskfile:\t\t$vmpath" +writelog "\tMachine diskfile:\t$vmpath" writelog "Virtual Hardware:" writelog "\tGuest RAM:\t\t${mem} MB" # echo nur wenn memhost gesetzt @@ -119,7 +144,8 @@ writelog "\tMAC address:\t\t$macaddr" # set the variables appropriately (several interfaces with different names) VIRTCMD=$(which xm 2>/dev/null) -VIRTCMDOPTS="create ${conffile}" +# '-c' for console, no graphical output available, later vnc possible +VIRTCMDOPTS="create -c ${conffile}" # set headless mode VIRTCMDHL=$(which xm 2>/dev/null) diff --git a/os-plugins/plugins/xen/init-hooks/10-have-nw-modules/xennet.sh b/os-plugins/plugins/xen/init-hooks/10-have-nw-modules/xennet.sh new file mode 100644 index 00000000..d514b68d --- /dev/null +++ b/os-plugins/plugins/xen/init-hooks/10-have-nw-modules/xennet.sh @@ -0,0 +1,4 @@ +# load xennet if necessary, usualy within a NFS VM +if grep -q "Xen Virtual Ethernet Card" /etc/hwinfo.netcard-usbctrl; then + modprobe xennet >/tmp/xennet.log 2>&1 +fi -- cgit v1.2.3-55-g7522 From 5dd09617cd77f2a616c770152c4cd8319803a05f Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Fri, 2 Apr 2010 20:50:29 +0200 Subject: qemu tap coniguration hell --- .../plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm | 35 +++++++------ os-plugins/plugins/qemukvm/files/ifup | 47 ++++++++++------- os-plugins/plugins/qemukvm/files/run-virt.include | 34 ++++++++----- .../init-hooks/60-have-servconfig/vm-dhcpd.sh | 10 ++-- .../plugins/virtualbox/files/run-virt.include | 42 +++++++-------- os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 12 ++--- os-plugins/plugins/xen/files/machine.include | 2 +- os-plugins/plugins/xen/files/run-virt.include | 59 ++++++++++++---------- 8 files changed, 133 insertions(+), 108 deletions(-) (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm index 203a7ed3..e4ef657f 100644 --- a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm +++ b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm @@ -150,38 +150,42 @@ sub installationPhase elif grep -q ^flags.*\\\ /proc/cpuinfo; then module=kvm_amd else - unset module + module=kqemu fi End-of-Here my $do_start = unshiftHereDoc(<<' End-of-Here'); # loading kvm module + kvm_module [ -n "${module}" ] && modprobe -q ${module} # load the tunnel device module modprobe -q tun + # TODO: maybe in the ifup-script better solution? # configuring the tap0 interface to the existing bridge configured in stage3 - for i in 0 1 2; do - /opt/openslx/uclib-rootfs/sbin/tunctl -t tap${i} >/dev/null 2>&1 - ip link set dev tap${i} up - done - /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tap0 - ip addr add ${nataddress} dev tap1 - ip addr add ${hoaddress} dev tap2 - echo "1" >/proc/sys/net/ipv4/conf/br0/forwarding - echo "1" >/proc/sys/net/ipv4/conf/tap0/forwarding + #for i in 0 1 2; do + # /opt/openslx/uclib-rootfs/sbin/tunctl -t tap${i} >/dev/null 2>&1 + # ip link set dev tap${i} up + #done + #/opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tap0 + #ip addr add ${nataddress} dev tap1 + #ip addr add ${hoaddress} dev tap2 + #echo "1" >/proc/sys/net/ipv4/conf/br0/forwarding + #echo "1" >/proc/sys/net/ipv4/conf/tap0/forwarding # make /dev/fb0 writable for all # TODO: maybe solve via group or udev, etc... chmod 766 /dev/fb* End-of-Here my $do_stop = unshiftHereDoc(<<' End-of-Here'); + kvm_module [ -n "${module}" ] && modprobe -q -r ${module} modprobe -q -r tun - /opt/openslx/uclib-rootfs/usr/sbin/brctl delif br0 tap0 - ip addr del ${nataddress} dev tap1 - ip addr del ${hoaddress} dev tap2 - echo "0" >/proc/sys/net/ipv4/conf/br0/forwarding - echo "0" >/proc/sys/net/ipv4/conf/tap0/forwarding + # TODO: tun removed, so this is not necessary + #/opt/openslx/uclib-rootfs/usr/sbin/brctl delif br0 tap0 + #ip addr del ${nataddress} dev tap1 + #ip addr del ${hoaddress} dev tap2 + #echo "0" >/proc/sys/net/ipv4/conf/br0/forwarding + #echo "0" >/proc/sys/net/ipv4/conf/tap0/forwarding chmod 760 /dev/fb* End-of-Here @@ -192,6 +196,7 @@ sub installationPhase # add helper functions to initfile # first parameter name of the function # second parameter content of the function + $initFile->addFunction('kvm_module', $kvm_module); $initFile->addFunction('do_start', $do_start); $initFile->addFunction('do_stop', $do_stop); $initFile->addFunction('do_restart', $do_restart); diff --git a/os-plugins/plugins/qemukvm/files/ifup b/os-plugins/plugins/qemukvm/files/ifup index ed4a277d..ee5fdecf 100644 --- a/os-plugins/plugins/qemukvm/files/ifup +++ b/os-plugins/plugins/qemukvm/files/ifup @@ -16,7 +16,10 @@ . /etc/opt/openslx/openslx.conf PLUGINCONFDIR=${OPENSLX_DEFAULT_CONFDIR}/plugins/qemukvm -QKTMPDIR=/tmp/qemukvm/$USER/$$ + +# get VM_ID through tap name +VM_ID=$(echo $1 | grep -oE "0[0-4]$") +QKTMPDIR=/tmp/qemukvm/${USER}/${VM_ID} # Use the udhcpcd as DHCP server and brctl as provided by default in OpenSLX # environments via uclibc-wrapper. @@ -25,34 +28,44 @@ QKTMPDIR=/tmp/qemukvm/$USER/$$ # Just decide by the virtual network device used which kind of connection # should be set up (passed in $1): tap0 = bridge, tap1 = nat, tap2 = hostonly. case "$1" in - tap0) + tapbridge0*) # Adding the tap0 interface to the existing bridge configured in stage3 - # brctl addif br0 tap0 + 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 ;; - tap1) + tapnat0*) # Configuring DHCP on host tap1 interface and enable IP masquerading - [ -d ${QKTMPDIR} ] || mkdir -p ${QKTMPDIR} - # cut the last .NNN/MM from nataddress - sed -e "s,NWIF,tap1,;s,/misc/,/qemu/," \ - -e "s,CNETWORK,${nataddress%.*},;s,PIDFILE,${QKTMPDIR}/udhcpd.pid," \ + sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t $1 >/dev/null 2>&1 + sudo ip addr add ${nataddress} dev $1 + # not necessary since already done by run-virt.include + #[ -d ${QKTMPDIR} ] || mkdir -p ${QKTMPDIR} + # cut the last .NNN/MM from nataddress ${natnetwork%.*} + # TODO: we use here atatic address, maybe change later + sed -e "s,NWIF,$1,;s,/misc/,/qemu/," \ + -e "s,CNETWORK,192.168.1${VM_ID}.254,;s,PIDFILE,${QKTMPDIR}/udhcpd.pid," \ -e "s,LEASEFILE,${QKTMPDIR}/udhcpd.leases," \ - ${OPENSLX_DEFAULT_CONFDIR}/udhcpd.conf \ - >${QKTMPDIR}/udhcpd.conf + ${OPENSLX_DEFAULT_CONFDIR}/udhcpd.conf \ + >${QKTMPDIR}/udhcpd.conf touch ${QKTMPDIR}/udhcpd.leases - # ip link set tap1 up - # ip addr add 192.168.101.254/24 dev tap1 + # 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 ;; - tap2) + taphost0*) # Configuring DHCP on host tap2 interface - [ -d ${QKTMPDIR} ] || mkdir -p /tmp/qemu-$USER - sed "s,NWIF,tap2,;s,/misc/,/qemu/,;s,USER,$USER,;s,CNETWORK,$hoaddress," \ + sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t $1 >/dev/null 2>&1 + sudo ip addr add ${hoaddress} dev $1 + [ -d ${QKTMPDIR} ] || mkdir -p ${QKTMPDIR} + sed "s,NWIF,$1,;s,/misc/,/qemu/,;s,USER,$USER,;s,CNETWORK,192.168.1${VM_ID}.254," \ ${OPENSLX_DEFAULT_CONFDIR}/udhcpd.conf >${QKTMPDIR}/udhcpd.conf touch ${QKTMPDIR}/udhcpd.leases - # ip link set tap2 up - # ip addr add 192.168.101.254/24 dev tap2 + # 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 ;; diff --git a/os-plugins/plugins/qemukvm/files/run-virt.include b/os-plugins/plugins/qemukvm/files/run-virt.include index 7db2bfc9..69c5dad4 100644 --- a/os-plugins/plugins/qemukvm/files/run-virt.include +++ b/os-plugins/plugins/qemukvm/files/run-virt.include @@ -74,10 +74,10 @@ writelog "\tDisk file:\t\t$diskfile" if [ -n "${forcemem}" ]; then mem="${forcemem}" else -# permem=30 -# if [ "${totalmem}" -ge "1600" ]; then -# permem=40 -# fi + 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 @@ -95,12 +95,12 @@ else # #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 + mem=$(expr ${totalmem} / 100 \* ${permem}) + if [ "${id44}" = "1" ]; then + memhost=$(expr ${totalmem} - ${mem}) + else + memhost=$(expr ${totalmem} - ${mem} - ${mem}) + fi # static first permem=50 mem=$(expr ${totalmem} / 100 \* ${permem}) @@ -118,16 +118,22 @@ network_card=${network_card:=pcnet} VIRTCMDOPTS="${VIRTCMDOPTS} -net nic,macaddr=${macaddr},model=${network_card}" # define net kind and apply script -qemu_ifscripts="script=${PLUGINDIRQK}/ifup,downscript=${PLUGINDIRQK}/ifdown" +qemu_ifscr="script=${PLUGINDIRQK}/ifup,downscript=${PLUGINDIRQK}/ifdown" case "${network_kind}" in bridge*) - VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap0,${qemu_ifscripts}" + VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tapbridge${VM_ID},${qemu_ifscr}" + #sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t tapbridge${VM_ID} 2>/tmp/asdf + #sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tapbridge${VM_ID} 2>>/tmp/asdf ;; NAT|nat) - VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap1,${qemu_ifscripts}" + VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tapnat${VM_ID},${qemu_ifscr}" + #sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t tapbnat${VM_ID} 2>/tmp/asdf + #sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tapnat${VM_ID} 2>>/tmp/asdf ;; hostonly|host-only) - VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tap2,${qemu_ifscripts}" + VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=taphost${VM_ID},${qemu_ifscr}" + #sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t tapbhost${VM_ID} 2>/tmp/asdf + #sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 taphost${VM_ID} 2>>/tmp/asdf ;; *) network_kind="user" diff --git a/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh b/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh index 13771a43..396631c1 100755 --- a/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh +++ b/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh @@ -34,15 +34,15 @@ interface NWIF offer_time 6000 # location of the leases file -lease_file LEASEDIR/udhcpd.leases +lease_file LEASEFILE # location of the pid file -pidfile PIDFILE/udhcpd.pid +pidfile PIDFILE -opt dns ${domain_name_servers} +option dns ${domain_name_servers} option subnet 255.255.255.0 -opt router CNETWORK.254 -opt wins CNETWORK.10 +option router CNETWORK.254 +option wins CNETWORK.10 option domain virtual.site ${domain_name} # additional options known to udhcpd diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index abf1e0be..2a0b84a2 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -212,29 +212,25 @@ esac # translate boot, use if set else set to HardDisk # usually support for a,c,d,n, stands for Floppy, HD, CD-ROM, Network # support nfs and tftp as well -if [ -n "${boot}" ]; then - case ${boot} in - n*|tftp) - boot="Network" - if [ "${network_kind}" = "NAT" ] && [ -n "${virtualbox_tftpdir}" ]; then - # remove spaces from VM name to avoid Problems /w TFTP in NAT - vm_name=$(echo ${vm_name} | sed -e "s, ,-,g") - # link TFTP dir for NAT TFTP boots - mkdir -p ${confdir}/TFTP - cp ${virtualbox_tftpdir}/pxelinux.0 ${confdir}/TFTP/${vm_name}.pxe - for i in $(ls ${virtualbox_tftpdir}); do - ln -sf ${virtualbox_tftpdir}/${i} ${confdir}/TFTP/${i} - done - fi - ;; - # later maybe c|disk|hd*|sd*) for HD and d|cd*) for CD-ROM - *) - boot="HardDisk" - ;; - esac -else - boot="HardDisk" -fi +case ${boot} in + n*|tftp) + boot="Network" + if [ "${network_kind}" = "NAT" ] && [ -n "${virtualbox_tftpdir}" ]; then + # remove spaces from VM name to avoid Problems /w TFTP in NAT + vm_name=$(echo ${vm_name} | sed -e "s, ,-,g") + # link TFTP dir for NAT TFTP boots + mkdir -p ${confdir}/TFTP + cp ${virtualbox_tftpdir}/pxelinux.0 ${confdir}/TFTP/${vm_name}.pxe + for i in $(ls ${virtualbox_tftpdir}); do + ln -sf ${virtualbox_tftpdir}/${i} ${confdir}/TFTP/${i} + done + fi + ;; + # later maybe c|disk|hd*|sd*) for HD and d|cd*) for CD-ROM + *) + boot="HardDisk" + ;; +esac # external GUI vrdpport="590${VM_ID}" diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index 716371d5..626dfcca 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -162,7 +162,7 @@ writelog "\tVM XML dir:\t\t$(dirname ${xmlfile})" if ! grep '/dev/null 2>&1; then writelog \ - "\tSubmitted configuration file ${xmlfile} seems to have wrong XML format" + "Submitted configuration file ${xmlfile} seems to have wrong XML format" exit 1 fi @@ -208,7 +208,7 @@ fi # check if virtual machine container file exists, only if not rwimg if ! [ -e "${vmpath}" ] && [ "${imgmode}" != "rwimg" ] && [ ${diskless} -eq 0 ]; then - writelog "\tVirtual machine image or directory ${vmpath} not found!" + writelog "Virtual machine image or directory ${vmpath} not found!" exit 1 fi @@ -239,8 +239,8 @@ xmlvirt=$(grep -o 'virtualmachine param=.*"' ${xmlfile} \ # make a guess from the filename extension if ${xmlvirt} is empty # (not set within the XML file) if [ -z "${xmlvirt}" ] && [ -n "${additional_config}" ]; then - writelog "\tNo virtual machine parameter defined in ${xmlfile}" - writelog "\tTrying to guess VM...\c" + writelog "No virtual machine parameter defined in ${xmlfile}" + writelog "Trying to guess VM...\c" case "$(cat ${additional_config} | tr [A-Z] [a-z])" in *config.version*|*virtualhw.version*|*independent-nonpersistent*|*vmdk*) xmlvirt="vmware" @@ -275,8 +275,8 @@ fi # check for virt if [ "${vmgrid_virt}" != "${xmlvirt}" ]; then - writelog "\tThe virtual machine specified in ${xmlfile}" - writelog "\tdoes not match the virtualization used here (${vmgrid_virt})" + writelog "The virtual machine specified in ${xmlfile}" + writelog "does not match the virtualization used here (${vmgrid_virt})" exit 1 fi diff --git a/os-plugins/plugins/xen/files/machine.include b/os-plugins/plugins/xen/files/machine.include index a1573578..06848949 100644 --- a/os-plugins/plugins/xen/files/machine.include +++ b/os-plugins/plugins/xen/files/machine.include @@ -58,7 +58,7 @@ vif = [ '${xen_vif}' ] # where UNAME is the device, DEV is the device name the domain will see, # and MODE is r for read-only, w for read-write. # disk = [ 'phy:hda1,hda1,w' ] -disk = [ '${xen_disk}' ] +${xen_disk} #---------------------------------------------------------------------------- # Define frame buffer device. diff --git a/os-plugins/plugins/xen/files/run-virt.include b/os-plugins/plugins/xen/files/run-virt.include index 40cca17a..43213e34 100644 --- a/os-plugins/plugins/xen/files/run-virt.include +++ b/os-plugins/plugins/xen/files/run-virt.include @@ -43,13 +43,10 @@ conffile=${confdir}/${vm_name} rm -rf ${confdir} 2>/dev/null mkdir -p ${confdir} 2>/dev/null -# TODO: read from XML file xen_kernel=${kernel:-"/boot/vmlinuz-xen"} xen_ramdisk=${initramfs:-"/boot/initrd-xen"} xen_extra="xencons=tty 3" -xen_disk="file:${vmpath},hda1,r" -xen_vif="mac=$macaddr, bridge=br0" -xen_dhcp="dhcp" # off +[ -n "${imgname}" ] && xen_disk="disk = [ 'file:${vmpath},hda1,r' ]" writelog "Directories:" writelog "\tConfig dir:\t\t$confdir" @@ -99,33 +96,41 @@ else fi fi -xen::tftpdir +# translate network kinds (nat, bridged, host-only) +case "${network_kind}" in + bridge*) + xen_vif="mac=$macaddr, bridge=br0" + ;; + *) + xen_vif="mac=$macaddr" +esac +xen_dhcp="dhcp" # off + # translate boot, use if set else set to disk -if [ -n "${boot}" ]; then - case ${boot} in - n*|tftp) - if [ -n "${imgname}" ] && [ -n "${xen_tftpdir}" ]; then - root=/dev/nfs - tftp_label=$(grep -A 3 "^LABEL *${imgname}" \ - ${xen_tftpdir}/pxelinux.cfg/default 2>/dev/null \ - | grep "^ *KERNEL ") - xen_kernel="${xen_tftpdir}/$(echo ${tftp_label} \ +xen_root=/dev/hda1 +case ${boot} in + n*|tftp) + pxe_label=$(grep -o 'pxe_label param=.*"' ${xmlfile} \ + | sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}') + pxe_label=$(grep -A 3 "^LABEL *${pxe_label}" \ + ${xen_tftpdir}/pxelinux.cfg/default 2>/dev/null \ + | grep "^ *KERNEL ") + if [ -n "${pxe_label}" ] && [ -n "${xen_tftpdir}" ]; then + xen_root=/dev/nfs + xen_kernel="${xen_tftpdir}/$(echo ${pxe_label} \ | awk -F " --- " '{print $2}' | awk '{print $1}')" - xen_ramdisk="${xen_tftpdir}/$(echo ${tftp_label} \ + xen_ramdisk="${xen_tftpdir}/$(echo ${pxe_label} \ | awk -F " --- " '{print $3}')" - fi - ;; - # later maybe c|disk|hd*|sd*) for HD and d|cd*) for CD-ROM - *) - xen_root=/dev/hda1 - ;; - esac -else - xen_root=/dev/hda1 -fi + fi + ;; + # later maybe c|disk|hd*|sd*) for HD and d|cd*) for CD-ROM + *) + xen_root=/dev/hda1 + ;; +esac -writelog "Diskimage:" -writelog "\tMachine diskfile:\t$vmpath" +[ ${diskless} -eq 0 ] && writelog "Diskimage:" +[ ${diskless} -eq 0 ] && writelog "\tMachine diskfile:\t$vmpath" writelog "Virtual Hardware:" writelog "\tGuest RAM:\t\t${mem} MB" # echo nur wenn memhost gesetzt -- cgit v1.2.3-55-g7522 From ad9e7762c242a4b8a85330f530726fdf9da15b61 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Tue, 6 Apr 2010 22:21:25 +0200 Subject: ifup modified of qemukvm --- .../init-hooks/10-have-nw-modules/bootsplash.sh | 1 - .../init-hooks/10-nw-if-config/bootsplash.sh | 1 + os-plugins/plugins/qemukvm/XX_qemukvm.sh | 7 +++++-- os-plugins/plugins/qemukvm/files/ifup | 22 +++++++++++++--------- os-plugins/plugins/qemukvm/files/run-virt.include | 15 ++++++++------- .../plugins/virtualbox/files/run-virt.include | 2 ++ .../xen/init-hooks/10-have-nw-modules/xennet.sh | 4 ---- .../xen/init-hooks/10-nw-if-config/xennet.sh | 4 ++++ 8 files changed, 33 insertions(+), 23 deletions(-) delete mode 100644 os-plugins/plugins/bootsplash/init-hooks/10-have-nw-modules/bootsplash.sh create mode 100644 os-plugins/plugins/bootsplash/init-hooks/10-nw-if-config/bootsplash.sh delete mode 100644 os-plugins/plugins/xen/init-hooks/10-have-nw-modules/xennet.sh create mode 100644 os-plugins/plugins/xen/init-hooks/10-nw-if-config/xennet.sh (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/bootsplash/init-hooks/10-have-nw-modules/bootsplash.sh b/os-plugins/plugins/bootsplash/init-hooks/10-have-nw-modules/bootsplash.sh deleted file mode 100644 index 7f3d563e..00000000 --- a/os-plugins/plugins/bootsplash/init-hooks/10-have-nw-modules/bootsplash.sh +++ /dev/null @@ -1 +0,0 @@ -[ ${no_bootsplash} -eq 0 ] && /bin/splashy_update "progress 10" >/dev/null 2>&1 diff --git a/os-plugins/plugins/bootsplash/init-hooks/10-nw-if-config/bootsplash.sh b/os-plugins/plugins/bootsplash/init-hooks/10-nw-if-config/bootsplash.sh new file mode 100644 index 00000000..7f3d563e --- /dev/null +++ b/os-plugins/plugins/bootsplash/init-hooks/10-nw-if-config/bootsplash.sh @@ -0,0 +1 @@ +[ ${no_bootsplash} -eq 0 ] && /bin/splashy_update "progress 10" >/dev/null 2>&1 diff --git a/os-plugins/plugins/qemukvm/XX_qemukvm.sh b/os-plugins/plugins/qemukvm/XX_qemukvm.sh index 2a907861..ac97b52f 100644 --- a/os-plugins/plugins/qemukvm/XX_qemukvm.sh +++ b/os-plugins/plugins/qemukvm/XX_qemukvm.sh @@ -99,17 +99,20 @@ ${qemukvm_imagesrc}." nonfatal [ -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: /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: ${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: /opt/openslx/uclib-rootfs/sbin/tunctl -t tap* +#ALL ALL=NOPASSWD: ${ippath} link set dev tap* #ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/sbin/ip addr add * dev tap* -#ALL ALL=NOPASSWD: /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tap* EOF fi else diff --git a/os-plugins/plugins/qemukvm/files/ifup b/os-plugins/plugins/qemukvm/files/ifup index ee5fdecf..9d94ac64 100644 --- a/os-plugins/plugins/qemukvm/files/ifup +++ b/os-plugins/plugins/qemukvm/files/ifup @@ -30,24 +30,25 @@ QKTMPDIR=/tmp/qemukvm/${USER}/${VM_ID} 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 /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 + #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 ;; tapnat0*) # Configuring DHCP on host tap1 interface and enable IP masquerading - sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t $1 >/dev/null 2>&1 + #sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t $1 >/dev/null 2>&1 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: we use here atatic address, maybe change later - sed -e "s,NWIF,$1,;s,/misc/,/qemu/," \ - -e "s,CNETWORK,192.168.1${VM_ID}.254,;s,PIDFILE,${QKTMPDIR}/udhcpd.pid," \ + sed -e "s,NWIF,$1,;s,CNETWORK,192.168.1${VM_ID}," \ + -e "s,PIDFILE,${QKTMPDIR}/udhcpd.pid," \ -e "s,LEASEFILE,${QKTMPDIR}/udhcpd.leases," \ - ${OPENSLX_DEFAULT_CONFDIR}/udhcpd.conf \ + ${OPENSLX_DEFAULT_CONFDIR}/udhcpd.conf \ >${QKTMPDIR}/udhcpd.conf touch ${QKTMPDIR}/udhcpd.leases # ip link set $1 up @@ -58,10 +59,13 @@ case "$1" in ;; taphost0*) # Configuring DHCP on host tap2 interface - sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t $1 >/dev/null 2>&1 + #sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t $1 >/dev/null 2>&1 sudo ip addr add ${hoaddress} dev $1 - [ -d ${QKTMPDIR} ] || mkdir -p ${QKTMPDIR} - sed "s,NWIF,$1,;s,/misc/,/qemu/,;s,USER,$USER,;s,CNETWORK,192.168.1${VM_ID}.254," \ + sudo ip link set dev $1 up + #[ -d ${QKTMPDIR} ] || mkdir -p ${QKTMPDIR} + 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 diff --git a/os-plugins/plugins/qemukvm/files/run-virt.include b/os-plugins/plugins/qemukvm/files/run-virt.include index 69c5dad4..08a8b4f1 100644 --- a/os-plugins/plugins/qemukvm/files/run-virt.include +++ b/os-plugins/plugins/qemukvm/files/run-virt.include @@ -122,18 +122,18 @@ qemu_ifscr="script=${PLUGINDIRQK}/ifup,downscript=${PLUGINDIRQK}/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>/tmp/asdf - #sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tapbridge${VM_ID} 2>>/tmp/asdf + sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t tapbridge${VM_ID} #2>/dev/null + sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tapbridge${VM_ID} ;; NAT|nat) VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=tapnat${VM_ID},${qemu_ifscr}" - #sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t tapbnat${VM_ID} 2>/tmp/asdf - #sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tapnat${VM_ID} 2>>/tmp/asdf + sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t tapnat${VM_ID} + sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 tapnat${VM_ID} ;; hostonly|host-only) VIRTCMDOPTS="${VIRTCMDOPTS} -net tap,ifname=taphost${VM_ID},${qemu_ifscr}" - #sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t tapbhost${VM_ID} 2>/tmp/asdf - #sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 taphost${VM_ID} 2>>/tmp/asdf + sudo /opt/openslx/uclib-rootfs/sbin/tunctl -t taphost${VM_ID} + sudo /opt/openslx/uclib-rootfs/usr/sbin/brctl addif br0 taphost${VM_ID} ;; *) network_kind="user" @@ -299,4 +299,5 @@ VIRTCMDOPTSHL="${VIRTCMDOPTS} -nographic ${diskfile}" # graphical start VIRTCMD="$VIRTCMD" # vga std/cirrus/vmware? -VIRTCMDOPTS="${VIRTCMDOPTS} -vga std -full-screen ${diskfile}" +#VIRTCMDOPTS="${VIRTCMDOPTS} -vga std -full-screen ${diskfile}" +VIRTCMDOPTS="${VIRTCMDOPTS} ${diskfile}" diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index 2a0b84a2..5fc0641a 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -48,6 +48,8 @@ machconfig="${machfolder}/${vm_shortname}/${vm_shortname}.xml" diskfolder="${confdir}/HardDisks" snapshotdir=${machfolder}/${vm_shortname}/Snapshots mkdir -p ${diskfolder} ${snapshotdir} 2>/dev/null +# check if diskless var empty? +[ -z "${diskless}" ] && diskless=0 # configure our own rwimg, empty image which we support if [ "${imgmode}" = "rwimg" ]; then diff --git a/os-plugins/plugins/xen/init-hooks/10-have-nw-modules/xennet.sh b/os-plugins/plugins/xen/init-hooks/10-have-nw-modules/xennet.sh deleted file mode 100644 index d514b68d..00000000 --- a/os-plugins/plugins/xen/init-hooks/10-have-nw-modules/xennet.sh +++ /dev/null @@ -1,4 +0,0 @@ -# load xennet if necessary, usualy within a NFS VM -if grep -q "Xen Virtual Ethernet Card" /etc/hwinfo.netcard-usbctrl; then - modprobe xennet >/tmp/xennet.log 2>&1 -fi diff --git a/os-plugins/plugins/xen/init-hooks/10-nw-if-config/xennet.sh b/os-plugins/plugins/xen/init-hooks/10-nw-if-config/xennet.sh new file mode 100644 index 00000000..d514b68d --- /dev/null +++ b/os-plugins/plugins/xen/init-hooks/10-nw-if-config/xennet.sh @@ -0,0 +1,4 @@ +# load xennet if necessary, usualy within a NFS VM +if grep -q "Xen Virtual Ethernet Card" /etc/hwinfo.netcard-usbctrl; then + modprobe xennet >/tmp/xennet.log 2>&1 +fi -- cgit v1.2.3-55-g7522 From 8ac3d72cd1ba2d9b76f6c201b6cb9f3389915cb6 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Thu, 8 Apr 2010 21:07:44 +0200 Subject: virtualization plugin refurbished ;). booting 64bit guest on 32 bit hosts now possible /w virtualbox --- boot-env/OpenSLX/MakeInitRamFS/Engine/Base.pm | 16 +-- os-plugins/plugins/virtualbox/XX_virtualbox.sh | 6 +- .../plugins/virtualbox/files/machine.include | 2 +- .../plugins/virtualbox/files/run-virt.include | 44 ++++++-- .../plugins/virtualbox/files/virtualbox.include | 2 +- 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 +++++++++++++++++++++ 12 files changed, 296 insertions(+), 124 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 (limited to 'os-plugins/plugins') 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/virtualbox/XX_virtualbox.sh b/os-plugins/plugins/virtualbox/XX_virtualbox.sh index 07e58428..807ef0a8 100644 --- a/os-plugins/plugins/virtualbox/XX_virtualbox.sh +++ b/os-plugins/plugins/virtualbox/XX_virtualbox.sh @@ -87,7 +87,11 @@ if [ -e ${CONFFILE} ]; then mknod -m 0660 /dev/vboxdrv c 10 59 chown root:vboxusers /dev/vboxdrv + + # finished ... + [ $DEBUGLEVEL -gt 0 ] && echo "done with 'virtualbox' os-plugin ..." fi else - [ $DEBUGLEVEL -gt 0 ] && echo " * Configuration of virtualbox plugin failed" + [ $DEBUGLEVEL -gt 0 ] \ + && echo " * Configuration of 'virtualbox' plugin failed" fi diff --git a/os-plugins/plugins/virtualbox/files/machine.include b/os-plugins/plugins/virtualbox/files/machine.include index a76c7e6f..0482d03a 100644 --- a/os-plugins/plugins/virtualbox/files/machine.include +++ b/os-plugins/plugins/virtualbox/files/machine.include @@ -14,7 +14,7 @@ cat << EOF > "${machconfig}" - + diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index 5fc0641a..af5595ee 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -66,7 +66,7 @@ diskfile="${diskfolder}/${imgname}" [ ${diskless} -eq 0 ] && ln -sf ${vmpath} ${diskfile} # check the file type -if echo ${imgname} | grep -iE "vdi|vmdk|vhd" && [ ${diskless} -eq 0 ]; then +if echo ${imgname} | grep -qiE "vdi|vmdk|vhd" && [ ${diskless} -eq 0 ]; then imgfmt=$(echo ${imgname##*.} | tr [a-z] [A-Z]) elif [ ${diskless} -eq 0 ]; then writelog "${imgname} is not a valid image format (vdi|vmdk|vhd), exiting!" @@ -76,17 +76,31 @@ fi # TODO: maybe rewrite, to reduce checks, merge it with network option, # so we can have a "compatibility to vmware config" section case "${vmostype}" in - winxp*) + winxp*|windowsxp*) vmostype="WindowsXP" ;; - winvista*) + winvista*|windowsvista*) vmostype="WindowsVista" ;; - Windows7*) + windows7*) vmostype="Windows7" ;; - linux*) - vmostype="Linux26" + linux*|*ubuntu*|*suse*|debian*|*sci*) + if echo "${vmostype}" | grep -q "64"; then + vmostype="Linux26_64" + # check for vtflag + if [ ${vtflag} -ne 1 ]; then + writelog "You are trying to boot a 64 bit OS without a VT enabled CPU" + writelog "This is not supported, exiting!" + exit 1 + fi + # check if host is only 32 bit, then use only 1 cpu (only 1 supported) + if echo "${host_arch}" | grep -qE "i.86"; then + cpu_cores=1 + fi + else + vmostype="Linux26" + fi ;; esac @@ -123,7 +137,7 @@ if echo "${imgmode}" | grep -q rw; then # lock existing? if [ -e "${vmpath}.lock" ]; then writelog "This rw image is already in use: ${vmpath}, exiting!" - writelog "Remove lock if you are shure that this is not the case" + writelog "Remove lock if you are sure that this is not the case" exit 1 # image rw? elif ! [ -w ${vmpath} ]; then @@ -144,6 +158,9 @@ elif [ ${diskless} -eq 0 ]; then | gunzip > "${snapshotdir}/{${snapshotuuid}}.vdi" fi +# make sure cpu_cores is not empty +cpu_cores=${cpu_cores:-"1"} + # TODO: MEM muss noch angepasst werden. Maschine crasht wenn nehr als 50% MEM # memory part equal to vmware plugin # percentage of memory to use for virtualbox in standard case @@ -222,7 +239,13 @@ case ${boot} in vm_name=$(echo ${vm_name} | sed -e "s, ,-,g") # link TFTP dir for NAT TFTP boots mkdir -p ${confdir}/TFTP - cp ${virtualbox_tftpdir}/pxelinux.0 ${confdir}/TFTP/${vm_name}.pxe + if [ -e ${virtualbox_tftpdir}/pxelinux.0 ]; then + cp ${virtualbox_tftpdir}/pxelinux.0 ${confdir}/TFTP/${vm_name}.pxe + else + writelog "${virtualbox_tftpdir}/pxelinux.0 not found!" + writelog "Network boot won't work, exiting!" + exit 1 + fi for i in $(ls ${virtualbox_tftpdir}); do ln -sf ${virtualbox_tftpdir}/${i} ${confdir}/TFTP/${i} done @@ -271,6 +294,7 @@ writelog "Diskimage:" writelog "\tMachine UUID:\t\t$machineuuid" [ ${diskless} -eq 0 ] && writelog "\tDisk UUID:\t\t$diskuuid" writelog "Virtual Hardware:" +[ ${vtflag} -eq 1 ] && writelog "\tVT enabled CPU" writelog "\tGuest RAM:\t\t${mem} MB" # echo nur wenn memhost gesetzt [ -n "${memhost}" ] && writelog "\tHost RAM:\t\t${memhost} MB" @@ -315,8 +339,8 @@ if [ ${diskless} -eq 1 ]; then sed -i "//d" ${machconfig} fi -# add ssh port if linux and NAT -if [ "${vmostype}" = "Linux26" ] && [ "${network_kind}" = "NAT" ]; then +# add ssh port if Linux26* and NAT +if echo "${vmostype}" | grep -q "Linux26" && [ "${network_kind}" = "NAT" ]; then vmsshport="220${VM_ID}" extradataitem=' "${confdir}/VirtualBox.xml" - + 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 75efed0008dd9576e8484904e35d6b82a98f5e4a Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Fri, 9 Apr 2010 22:04:04 +0200 Subject: qemu network scripts and sudoers, should work now --- 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 +++++++++-------- .../plugins/virtualbox/files/run-virt.include | 2 +- .../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 ++++-- 8 files changed, 70 insertions(+), 65 deletions(-) (limited to 'os-plugins/plugins') 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/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index af5595ee..4dc6d4fc 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -221,7 +221,7 @@ case "${network_kind}" in bridge*) network_kind='BridgedInterface name="br0"' ;; - hostonly|host-only) + host*) network_kind='HostOnlyInterface name="vboxnet0"' ;; *) 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 1125aeed09b614136ce01446b17981965bfce22a Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Sun, 11 Apr 2010 23:05:28 +0200 Subject: virtualization plugin, now with calculation of mem, run-vmgrid and run-virt use them --- .../plugins/virtualbox/files/run-virt.include | 12 ++-- 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 ++++++++++++---------- 8 files changed, 139 insertions(+), 122 deletions(-) (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index 4dc6d4fc..f846a442 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -190,14 +190,14 @@ else fi mem=$(expr ${totalmem} / 100 \* ${permem}) if [ "${id44}" = "1" ]; then - memhost=$(expr ${totalmem} - ${mem}) + hostmem=$(expr ${totalmem} - ${mem}) else - memhost=$(expr ${totalmem} - ${mem} - ${mem}) + hostmem=$(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)!" + if [ "${mem}" -lt "256" ] || [ "${hostmem}" -lt "256" ]; then + writelog "Memory out of range: ${mem} MB (guest) / ${hostmem} MB (host)!" writelog "Min. 256 MB for host and guest!" exit 1 fi @@ -296,8 +296,8 @@ writelog "Diskimage:" writelog "Virtual Hardware:" [ ${vtflag} -eq 1 ] && writelog "\tVT enabled CPU" writelog "\tGuest RAM:\t\t${mem} MB" -# echo nur wenn memhost gesetzt -[ -n "${memhost}" ] && writelog "\tHost RAM:\t\t${memhost} MB" +# echo nur wenn hostmem gesetzt +[ -n "${hostmem}" ] && writelog "\tHost RAM:\t\t${hostmem} MB" writelog "\tMAC address:\t\t$macaddr" writelog "\tNetwork card:\t\t${vb_network_card}" writelog "\tNetwork kind:\t\t${network_kind}" 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 From 4f30ed99307f55ae8b1f5c9fd6377bf6b3122750 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Tue, 13 Apr 2010 22:07:37 +0200 Subject: disable audio when using vmgrid --- .../plugins/virtualbox/files/machine.include | 2 +- .../plugins/virtualbox/files/run-virt.include | 3 ++- .../plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm | 26 +++++++++++----------- os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 1 + os-plugins/plugins/vmgrid/files/vmgrid | 17 +++++++++----- 5 files changed, 28 insertions(+), 21 deletions(-) (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/virtualbox/files/machine.include b/os-plugins/plugins/virtualbox/files/machine.include index 0482d03a..1544d4d6 100644 --- a/os-plugins/plugins/virtualbox/files/machine.include +++ b/os-plugins/plugins/virtualbox/files/machine.include @@ -59,7 +59,7 @@ cat << EOF > "${machconfig}" - + diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index f846a442..b2c55c0d 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -284,6 +284,7 @@ cdrom1=${cdtest:-"FALSE"} # be done while creating the runscripts ... ide="TRUE" hddrv="ide" +audio=${audio:-"true"} [ ${diskless} -eq 0 ] && writelog "\tSnapshots dir:\t\t$snapshotdir" writelog "Diskimage:" @@ -371,6 +372,6 @@ done VIRTCMD=$(which VirtualBox 2>/dev/null) VIRTCMDOPTS="--startvm ${machineuuid} --start-running" -# set headless mode +# set headless mode (-v off to disable vrdp) VIRTCMDHL=$(which VBoxHeadless 2>/dev/null) VIRTCMDOPTSHL="-s ${machineuuid}" diff --git a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm index d73e0720..401a2151 100644 --- a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm +++ b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm @@ -133,7 +133,7 @@ sub getAttrInfo content_descr => 'name of xml file e.g. scilin-5.4-wn(.xml)', default => undef, }, - 'vmgrid::hvm' => { + 'vmgrid::vt' => { applies_to_systems => 1, applies_to_clients => 1, description => unshiftHereDoc(<<' End-of-Here'), @@ -249,7 +249,7 @@ sub _writeRunlevelScript my $self = shift; my $initfile = newInitFile(); - $initfile->setName("vmgrid-slx"); + $initfile->setName("vmgrid"); $initfile->setDesc("Setup environment for vmgrid. Part of OpenSLX vmgrid plugin."); # todo: Function need to be formated proper... not important right now @@ -258,16 +258,16 @@ sub _writeRunlevelScript # 'lsmod | grep -q "$1[^_-]"' #); - # Is a VM running? - my $runningvms = unshiftHereDoc(<<' End-of-Here'); - if [ -e /tmp/vmgrid/vmgrid.pids ]; then - for pid in $(cat /tmp/vmgrid/vmgrid.pids); do - if ps aux | grep " ${pid} " | grep vmgrid; then - echo "Running: ${pid}" - fi - done - fi - End-of-Here +# # Is a VM running? +# my $runningvms = unshiftHereDoc(<<' End-of-Here'); +# if [ -e /tmp/vmgrid/vmgrid.pids ]; then +# for pid in $(cat /tmp/vmgrid/vmgrid.pids); do +# if ps aux | grep " ${pid} " | grep vmgrid; then +# echo "Running: ${pid}" +# fi +# done +# fi +# End-of-Here # Kill all VMS! my $killvms = unshiftHereDoc(<<' End-of-Here'); @@ -312,7 +312,7 @@ sub _writeRunlevelScript 'stop && start' ); - # get distro version +# # get distro version # my $distro = (split('-',$self->{'os-plugin-engine'}->distroName()))[0]; # my $runlevelscript = getInitFileForDistro($initfile, $distro); # diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index 1501749e..a684310b 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -331,6 +331,7 @@ macaddr=$(echo "${macguestpart}:${machostpart}" | tr [a-z] [A-Z]) ide="TRUE" scsi="FALSE" hddrv="ide" +audio="false" # add rw share sharepath="${vmgrid_rwmnt}/folders/${vm_shortname}" diff --git a/os-plugins/plugins/vmgrid/files/vmgrid b/os-plugins/plugins/vmgrid/files/vmgrid index d8ccd938..77efe4e0 100644 --- a/os-plugins/plugins/vmgrid/files/vmgrid +++ b/os-plugins/plugins/vmgrid/files/vmgrid @@ -57,9 +57,9 @@ writelog () { # write to stdout echo -e "$1" # log into file - echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/run-vmgrid.${USER}.$$.log + echo -e "$1" >> ${OPENSLX_DEFAULT_LOGDIR}/vmgrid.${USER}.$$.log # log into share dir, so that log is available in vm as well - echo -e "$1" >> ${vmgrid_rwmnt}/logs/run-vmgrid.${USER}.$$.log + echo -e "$1" >> ${vmgrid_rwmnt}/logs/vmgrid.${USER}.$$.log } ################################################################################ @@ -71,7 +71,7 @@ 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 + >${vmgrid_rwmnt}/logs/vmgrid.${USER}.$$.log if [ -z "${hostratio}" ]; then writelog "There has been an error in the memory configuration in stage 3" @@ -111,7 +111,7 @@ for i in {1..4}; do # calculate VMs mem: mem = $freemem * $vmratio/100 * 100/$restratio # multiple of 4 vmmem[$i]=$(expr ${freemem} \* ${vmratio[$i]} / ${restratio} / 4 \* 4 \ - 2>/dev/null) + 2>/dev/null) if [ -n "${vm[$i]}" ] && [ ${vmmem[$i]} -lt 512 2>/dev/null ]; then writelog "Not enough free RAM for ${vm[$i]} (min. 512 MB), \c" writelog "free: ${vmmem[$i]} MB" @@ -126,8 +126,13 @@ done # start vms for i in {1..4}; do if [ -n "${vm[$i]}" ]; then - alreadyrunning=$(ps aux | grep run-vmgrid.sh | grep -v grep | \ - grep "${vm[$i]}" | wc -l) + alreadyrunning=$(ps aux | grep run-vmgrid.sh | grep -v grep \ + | grep "${vm[$i]}" | wc -l) + # if Xen use different method + if [ "${vmgrid_virt}" = "xen" ]; then + alreadyrunning=$(xm list 2>/dev/null | grep -vE "Domain-0|Name.*ID" \ + | grep "${vm[$i]}-0.$" | wc -l) + fi if [ ${alreadyrunning} -gt 0 2>/dev/null ]; then writelog "${vm[$i]} already running, skipping!" else -- cgit v1.2.3-55-g7522 From bdf81fac4346f25eb11ce4834afc5d918a6f92d1 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Tue, 20 Apr 2010 20:44:28 +0200 Subject: now different port forwards can be submitted via xml, to be tested --- .../plugins/virtualbox/files/run-virt.include | 28 ++++++++++++---------- .../init-hooks/80-after-plugins/virtualization.sh | 2 +- .../plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm | 4 ++-- os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 21 ++++++++++++++-- .../init-hooks/80-after-plugins/virtualization.sh | 2 +- 5 files changed, 38 insertions(+), 19 deletions(-) (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index b2c55c0d..119b1e16 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -340,19 +340,21 @@ if [ ${diskless} -eq 1 ]; then sed -i "//d" ${machconfig} fi -# add ssh port if Linux26* and NAT -if echo "${vmostype}" | grep -q "Linux26" && [ "${network_kind}" = "NAT" ]; then - vmsshport="220${VM_ID}" - extradataitem='" - extradataprotocol='Protocol" value="TCP"/>' - sed -i "s,, ${extradataitem}${extradataguestport}\n\ - ${extradataitem}${extradatahostport}\n\ - ${extradataitem}${extradataprotocol}\n\ - ," "${machconfig}" - writelog "\tGuest SSH port:\t\t${vmsshport}" +# define redirects +if [ -n "${redirects}" ]; then + (( i=1 )) + while [ ${i} -le ${redirects} ]; do + extradataitem='" + extradatahostport="HostPort\" value=\"${redirect_hport[$i]}\"/>" + extradataguestport="GuestPort\" value=\"${redirect_gport[$i]}\"/>" + sed -i "s,, ${extradataitem}${extradataguestport}\n\ + ${extradataitem}${extradatahostport}\n\ + ${extradataitem}${extradataprotocol}\n\ + ," "${machconfig}" + writelog "\tGuest ${redirect_name[$i]} port:\t\t${redirect_hport[$i]}" fi ################################################################################ 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 400075cd..a1da2e63 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 [ ${vmgrid_active} -ne 0 ] && active=1 [ $DEBUGLEVEL -gt 0 ] \ - && echo -e "Executing the virtual 'virtualization' plugin ... \c" + && echo -e "Executing the 'virtualization' plugin ... \c" if [ ${active} -ne 0 ] ; then diff --git a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm index 401a2151..c3542274 100644 --- a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm +++ b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm @@ -72,9 +72,9 @@ sub getAttrInfo description => unshiftHereDoc(<<' End-of-Here'), which virtualization technique schould be used? End-of-Here - content_regex => qr{^(vmware|virtualbox|qemukvm|xen)$}, + content_regex => qr{^(virtualbox|qemukvm|xen)$}, #openvz|vserver - content_descr => 'vmware, virtualbox, qemukvm, xen', + content_descr => 'virtualbox, qemukvm, xen', #openvz, vserver default => undef, }, diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index a684310b..4fdd4af0 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -289,11 +289,28 @@ vmostype=$(grep -io '" extradataguestport="GuestPort\" value=\"${redirect_gport[$i]}\"/>" sed -i "s,, ${extradataitem}${extradataguestport}\n\ - ${extradataitem}${extradatahostport}\n\ - ${extradataitem}${extradataprotocol}\n\ - ," "${machconfig}" - writelog "\tGuest ${redirect_name[$i]} port:\t\t${redirect_hport[$i]}" + ${extradataitem}${extradatahostport}\n\ + ${extradataitem}${extradataprotocol}\n\ + ," "${machconfig}" + writelog "${tabspace}${redirect_name[$i]} port: ${redirect_hport[$i]}" + tabspace='\t\t\t\t' + (( i=$i+1 )) + done fi ################################################################################ diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index 4fdd4af0..9b9adb44 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -49,6 +49,17 @@ writelog () { echo -e "$1" >> ${vmgrid_rwmnt}/logs/run-vmgrid.${USER}.$$.log } +# remove config dirs when exit +cleanexit () { + if echo "${RMDIRS}" 2>/dev/null | grep -q ${vmgrid_virt}; then + writelog "${vmgrid_virt} exited. Cleanning up... \c" + rm -rf ${RMDIRS} >/dev/null 2>&1 + writelog "done" + fi + + exit "$1" +} + ################################################################################ ### Get XML file and dir ################################################################################ @@ -349,6 +360,7 @@ ide="TRUE" scsi="FALSE" hddrv="ide" audio="false" +remotedesktopport="590${VM_ID}" # add rw share sharepath="${vmgrid_rwmnt}/folders/${vm_shortname}" @@ -384,7 +396,7 @@ fi if [ ${headless} -eq 0 ]; then if [ -z "${VIRTCMD}" ]; then writelog "Grapical mode not available, exiting!" - exit 1 + cleanexit 1 fi writelog "Starting ${vmgrid_virt} in graphical mode..." ${VIRTCMD} ${VIRTCMDOPTS} 2>/dev/null @@ -394,7 +406,7 @@ elif [ -n "${VIRTCMDHL}" ]; then ${VIRTCMDHL} ${VIRTCMDOPTSHL} 2>/dev/null else writelog "${vmgrid_virt}: No headless mode defined, exiting!" - exit 1 + cleanexit 1 fi # postrun for scripts after virtualization finishes @@ -402,12 +414,5 @@ if [ -n "${POSTRUN}" ]; then eval ${POSTRUN} >/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" - rm -rf ${RMDIRS} >/dev/null 2>&1 - writelog "done" -fi - -echo -e "Bye." +cleanexit 0 exit 0 -- cgit v1.2.3-55-g7522 From 0921974c54dbf828c2f427c304b43470798a5322 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Sun, 9 May 2010 20:56:34 +0200 Subject: smaller changes --- .../plugins/virtualbox/files/run-virt.include | 6 ++-- .../init-hooks/80-after-plugins/virtualization.sh | 8 +++--- .../plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm | 32 ++++++++++------------ os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 14 +++++----- os-plugins/plugins/vmgrid/files/vmgrid | 4 +-- .../init-hooks/80-after-plugins/virtualization.sh | 8 +++--- 6 files changed, 33 insertions(+), 39 deletions(-) (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index 2091f79e..4a1e2c14 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -136,7 +136,8 @@ imageuuid=${snapshotuuid} if echo "${imgmode}" | grep -q rw; then # lock existing? if [ -e "${vmpath}.lock" ]; then - writelog "This rw image is already in use: ${vmpath}, exiting!" + writelog "This rw image is already in use." + writelog "Found lock in: ${vmpath}.lock, exiting!" writelog "Remove lock if you are sure that this is not the case" cleanexit 1 # image rw? @@ -158,9 +159,6 @@ elif [ ${diskless} -eq 0 ]; then | gunzip > "${snapshotdir}/{${snapshotuuid}}.vdi" fi -# make sure cpu_cores is not empty -cpu_cores=${cpu_cores:-"1"} - # TODO: MEM muss noch angepasst werden. Maschine crasht wenn nehr als 50% MEM # memory part equal to vmware plugin # percentage of memory to use for virtualbox in standard case 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 a1da2e63..37576331 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} -[ ${vmchooser_active} -ne 0 ] && active=1 +[ "x${vmchooser_active}" = "x1" ] && active=1 [ -f ${CONFFILEVMGRID} ] && . ${CONFFILEVMGRID} -[ ${vmgrid_active} -ne 0 ] && active=1 +[ "x${vmgrid_active}" = "x1" ] && active=1 [ $DEBUGLEVEL -gt 0 ] \ && echo -e "Executing the 'virtualization' plugin ... \c" @@ -46,7 +46,7 @@ if [ ${active} -ne 0 ] ; then | awk '{print $2}') / 1024) echo "totalmem=${totalmem}" >> ${PLUGINCONFDIR}/virtualization.conf - if [ ${vmgrid_active} -ne 0 ]; then + if [ "x${vmgrid_active}" = "x1" ]; then totalmemtest=$(expr $(echo ${vmgrid_memratio} \ | awk -F ',' '{print $1" + "$2" + "$3" + "$4" + "$5" + "$6}')) @@ -63,7 +63,7 @@ if [ ${active} -ne 0 ] ; then fi # main vm mem (vmchooser) - if [ ${vmchooser_active} -ne 0 ]; then + if [ "x${vmchooser_active}" = "x1" ]; 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 diff --git a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm index c3542274..d90a6f53 100644 --- a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm +++ b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm @@ -1,4 +1,4 @@ -# Copyright (c) 2008, 2009 - OpenSLX GmbH +# Copyright (c) 2008, 2010 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING @@ -6,7 +6,7 @@ # If you have any feedback please consult http://openslx.org/feedback and # send your suggestions, praise, or complaints to feedback@openslx.org # -# General information about OpenSLX can be found at http://openslx.org/ +# General information about OpenSLX can be found at http://openslx.org # ----------------------------------------------------------------------------- # vmgrid.pm # - ... @@ -107,7 +107,7 @@ sub getAttrInfo applies_to_clients => 1, description => unshiftHereDoc(<<' End-of-Here'), location of virtual images - for starts /wo full path + for starts /w relative path End-of-Here content_descr => 'absolute path to vm image files', default => '/var/lib/virt/vmgrid/images', @@ -117,7 +117,7 @@ sub getAttrInfo applies_to_clients => 1, description => unshiftHereDoc(<<' End-of-Here'), location of XML configuration for virtual images - for starts /wo full path + for starts /w relative path End-of-Here content_descr => 'absolute path to vm xml files', default => '/var/lib/virt/vmgrid/xml', @@ -150,7 +150,6 @@ sub getAttrInfo applies_to_clients => 1, description => unshiftHereDoc(<<' End-of-Here'), use this number of vcpus as maximum for one vm - will be used only if applicable (only if supported by plugin) End-of-Here content_regex => qr{^(1|2|4|8|16)$}, @@ -162,7 +161,6 @@ sub getAttrInfo applies_to_clients => 1, description => unshiftHereDoc(<<' End-of-Here'), use this number of vcpus as minimum for one vm - will be used only if applicable (only if supported by plugin) End-of-Here content_regex => qr{^(1|2|4|8|16)$}, @@ -180,35 +178,33 @@ sub getAttrInfo according to their ratio if less than 4 VMs defined in startvms the memory is being reserved for a later manual start - set to 0 if you don't intend to start them manually + set to 0 if you do not intend to start them manually (only if supported by plugin) End-of-Here content_regex => qr{^(\d\d??,\d\d??,\d\d??,\d\d??,\d\d??,\d\d??)$}, content_descr => '\d\d??,\d\d??,\d\d??,\d\d??,\d\d??,\d\d??', default => '40,0,0,0,40,20', }, - 'vmgrid::maxram' => { + 'vmgrid::maxmem' => { applies_to_systems => 1, applies_to_clients => 1, description => unshiftHereDoc(<<' End-of-Here'), - maximum of RAM used for ALL vms - will be used only if applicable + maximum RAM used by one vm (only if supported by plugin) End-of-Here - content_regex => qr{^(1|2|3|4|5|6|7|8|9)}, - content_descr => 'absolute or relative e.g. 512 or 50%', + content_regex => qr{^(\d\d\d\d??\d??)$}, + content_descr => 'absolute amount: \d\d\d\d??\d??', default => undef, }, - 'vmgrid::minram' => { - applies_to_systems => 1, + 'vmgrid::minmem' => { + applies_to_systems => 1, applies_to_clients => 1, description => unshiftHereDoc(<<' End-of-Here'), - minimum of RAM used for ALL vms - will be used only if applicable + minimum RAM used by one vm (only if supported by plugin) End-of-Here - content_regex => qr{^(1|2|3|4|5|6|7|8|9)}, - content_descr => 'absolute or relative e.g. 512 or 50%', + content_regex => qr{^(\d\d\d\d??\d??)$}, + content_descr => 'absolute amount: \d\d\d\d??\d??', default => undef, }, }; diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index 9b9adb44..9e3cbf0a 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -69,7 +69,7 @@ headless=1 while [ $# -gt 0 ]; do case "$1" in -h|--help) - echo -e "Usage: run-vmgrid.sh [-g] [--mem ] \c" + echo -e "Usage: run-vmgrid.sh [-g] [--mem ] \c" echo -e "[/path/]filename[.xml]" exit ;; @@ -253,6 +253,7 @@ xmlvirt=$(grep -o 'virtualmachine param=.*"' ${xmlfile} \ # make a guess from the filename extension if ${xmlvirt} is empty # (not set within the XML file) +# TODO: implement possibility to submit own configuration files if [ -z "${xmlvirt}" ] && [ -n "${additional_config}" ]; then writelog "No virtual machine parameter defined in ${xmlfile}" writelog "Trying to guess VM...\c" @@ -330,20 +331,19 @@ writelog "\tVM short name:\t\t$vm_shortname" ### Declaration of default variables ############################################################################### -# TODO: cpu cores +# make sure cpu_cores is not empty +cpu_cores=${cpu_cores:-"1"} #vmgrid::maxvcpus #vmgrid::minvcpus -#cpu_cores="${cpu_cores}" - # check for CPU virtualization flags -#vmgrid::hvm +#vmgrid::vt # 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) -#vmgrid::maxram -#vmgrid::minram +#vmgrid::maxmem +#vmgrid::minmem # configuring ethernet mac address: first 3 bytes are fixed (00:50:56) # 4th byte is the VM-ID diff --git a/os-plugins/plugins/vmgrid/files/vmgrid b/os-plugins/plugins/vmgrid/files/vmgrid index 3b6713b8..2ddfc5a0 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] [--mem ] \c" + echo -e "Usage: vmgrid [[-g] [--mem ] \c" echo -e "[/path/]filename[.xml]]" exit 0 else @@ -145,7 +145,7 @@ for i in {1..4}; do writelog "Starting ${vm[$i]} via run-vmgrid.sh with ${vmmem[$i]} MB RAM" 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 + # wait 10 secs for the next vm to start sleep 10 fi fi 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 a1da2e63..37576331 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} -[ ${vmchooser_active} -ne 0 ] && active=1 +[ "x${vmchooser_active}" = "x1" ] && active=1 [ -f ${CONFFILEVMGRID} ] && . ${CONFFILEVMGRID} -[ ${vmgrid_active} -ne 0 ] && active=1 +[ "x${vmgrid_active}" = "x1" ] && active=1 [ $DEBUGLEVEL -gt 0 ] \ && echo -e "Executing the 'virtualization' plugin ... \c" @@ -46,7 +46,7 @@ if [ ${active} -ne 0 ] ; then | awk '{print $2}') / 1024) echo "totalmem=${totalmem}" >> ${PLUGINCONFDIR}/virtualization.conf - if [ ${vmgrid_active} -ne 0 ]; then + if [ "x${vmgrid_active}" = "x1" ]; then totalmemtest=$(expr $(echo ${vmgrid_memratio} \ | awk -F ',' '{print $1" + "$2" + "$3" + "$4" + "$5" + "$6}')) @@ -63,7 +63,7 @@ if [ ${active} -ne 0 ] ; then fi # main vm mem (vmchooser) - if [ ${vmchooser_active} -ne 0 ]; then + if [ "x${vmchooser_active}" = "x1" ]; 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 -- cgit v1.2.3-55-g7522 From 716fb67d6e4b105b77d6ea0a51aedd986415de48 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Mon, 17 May 2010 22:24:43 +0200 Subject: changer router addres to x.x.x.1 since vmware seems to need that. virtualbox changes, /wo vt flags only one vcpu possible --- .../qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh | 4 ++-- os-plugins/plugins/virtualbox/files/machine.include | 4 ++-- os-plugins/plugins/virtualbox/files/run-virt.include | 16 ++++++++++++---- os-plugins/plugins/vmware/files/run-virt.include | 2 +- .../vmware/init-hooks/60-have-servconfig/vm-dhcpd.sh | 18 +++++++++++------- 5 files changed, 28 insertions(+), 16 deletions(-) (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh b/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh index 396631c1..4d10965d 100755 --- a/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh +++ b/os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh @@ -10,7 +10,7 @@ # General information about OpenSLX can be found at http://openslx.org # # Init hook to create a bridge on the active network interface -# (should be kept identical to the files of virtualbox and vmware plugins) +# (should be kept identical in vmware, virtualbox and qemukvm plugins) ############################################################################# . /etc/openslx.conf @@ -41,7 +41,7 @@ pidfile PIDFILE option dns ${domain_name_servers} option subnet 255.255.255.0 -option router CNETWORK.254 +option router CNETWORK.1 option wins CNETWORK.10 option domain virtual.site ${domain_name} diff --git a/os-plugins/plugins/virtualbox/files/machine.include b/os-plugins/plugins/virtualbox/files/machine.include index 1544d4d6..8d1e23c4 100644 --- a/os-plugins/plugins/virtualbox/files/machine.include +++ b/os-plugins/plugins/virtualbox/files/machine.include @@ -15,8 +15,8 @@ cat << EOF > "${machconfig}" - - + + diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index 4a1e2c14..a4ebe222 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -94,10 +94,6 @@ case "${vmostype}" in writelog "This is not supported, exiting!" cleanexit 1 fi - # check if host is only 32 bit, then use only 1 cpu (only 1 supported) - if echo "${host_arch}" | grep -qE "i.86"; then - cpu_cores=1 - fi else vmostype="Linux26" fi @@ -244,6 +240,10 @@ case ${boot} in writelog "Network boot won't work, exiting!" cleanexit 1 fi + # check if host is only 32 bit, then use only 1 cpu (only 1 supported) + if echo "${host_arch}" | grep -qE "i.86"; then + cpu_cores=1 + fi for i in $(ls ${virtualbox_tftpdir}); do ln -sf ${virtualbox_tftpdir}/${i} ${confdir}/TFTP/${i} done @@ -255,6 +255,14 @@ case ${boot} in ;; esac +# nested paging +npaging="false" +# enable VT +enablevt="false" +# check for VT, if not available use only 1 cpu (only 1 supported) +[ ${vtflag} -eq 0 ] && cpu_cores=1 +[ ${vtflag} -eq 1 ] && enablevt="true" + # external GUI vrdpport=${remotedesktopport} diff --git a/os-plugins/plugins/vmware/files/run-virt.include b/os-plugins/plugins/vmware/files/run-virt.include index 8b91275a..2c501156 100644 --- a/os-plugins/plugins/vmware/files/run-virt.include +++ b/os-plugins/plugins/vmware/files/run-virt.include @@ -61,7 +61,7 @@ case "$vmversion" in cpuid.coresPerSocket = \"${cpu_cores}\" maxvcpus = \"4\" # svga.numDisplays = "2" -# svgy.maxWidth = "2560" +# svga.maxWidth = "2560" # svga.maxHeight = "2048" # svga.vramSize = "134217728" monitor.virtual_mmu = \"automatic\" diff --git a/os-plugins/plugins/vmware/init-hooks/60-have-servconfig/vm-dhcpd.sh b/os-plugins/plugins/vmware/init-hooks/60-have-servconfig/vm-dhcpd.sh index 6bdfb8f1..4d10965d 100755 --- a/os-plugins/plugins/vmware/init-hooks/60-have-servconfig/vm-dhcpd.sh +++ b/os-plugins/plugins/vmware/init-hooks/60-have-servconfig/vm-dhcpd.sh @@ -10,12 +10,16 @@ # General information about OpenSLX can be found at http://openslx.org # # Init hook to create a bridge on the active network interface -# (should be kept identical to the files of virtualbox and qemukvm plugins) +# (should be kept identical in vmware, virtualbox and qemukvm plugins) ############################################################################# +. /etc/openslx.conf + +CONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR} +testmkd ${CONFDIR} + # configuring dhcpd stub for virtual networks -testmkd /mnt/etc/opt/openslx -echo " +cat > ${CONFDIR}/udhcpd.conf << EOF # general udhcpd configuration file for virtual machines written by # $0 during OpenSLX stage3 configuration @@ -35,10 +39,10 @@ lease_file LEASEFILE # location of the pid file pidfile PIDFILE -opt dns ${domain_name_servers} +option dns ${domain_name_servers} option subnet 255.255.255.0 -opt router CNETWORK.254 -opt wins CNETWORK.10 +option router CNETWORK.1 +option wins CNETWORK.10 option domain virtual.site ${domain_name} # additional options known to udhcpd @@ -53,4 +57,4 @@ option domain virtual.site ${domain_name} #wins #lease #ntpsrv #tftp #bootfile -" >/mnt/etc/opt/openslx/udhcpd.conf +EOF -- cgit v1.2.3-55-g7522 From a7e065e15feaa375bcdc03fc3868b32d4ade906a Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Thu, 20 May 2010 19:26:04 +0200 Subject: accidently moved if clause to use only one core /w 64 guests on 32 bit clients --- os-plugins/plugins/virtualbox/files/run-virt.include | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index a4ebe222..f8a6ff79 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -94,6 +94,10 @@ case "${vmostype}" in writelog "This is not supported, exiting!" cleanexit 1 fi + # check if host is only 32 bit, then use only 1 cpu (only 1 supported) + if echo "${host_arch}" | grep -qE "i.86"; then + cpu_cores=1 + fi else vmostype="Linux26" fi @@ -133,7 +137,7 @@ if echo "${imgmode}" | grep -q rw; then # lock existing? if [ -e "${vmpath}.lock" ]; then writelog "This rw image is already in use." - writelog "Found lock in: ${vmpath}.lock, exiting!" + writelog "Found lock: ${vmpath}.lock, exiting!" writelog "Remove lock if you are sure that this is not the case" cleanexit 1 # image rw? @@ -240,10 +244,6 @@ case ${boot} in writelog "Network boot won't work, exiting!" cleanexit 1 fi - # check if host is only 32 bit, then use only 1 cpu (only 1 supported) - if echo "${host_arch}" | grep -qE "i.86"; then - cpu_cores=1 - fi for i in $(ls ${virtualbox_tftpdir}); do ln -sf ${virtualbox_tftpdir}/${i} ${confdir}/TFTP/${i} done -- cgit v1.2.3-55-g7522 From f2ebeaa58d6c52708d5d2f7969dfe6fb4edfaad1 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Tue, 25 May 2010 22:23:08 +0200 Subject: nice level added to vmgrid --- .../plugins/virtualbox/files/run-virt.include | 6 ++--- os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 30 +++++++++++++++++----- os-plugins/plugins/vmgrid/files/vmgrid | 2 +- 3 files changed, 28 insertions(+), 10 deletions(-) (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include index f8a6ff79..9dbe47ac 100644 --- a/os-plugins/plugins/virtualbox/files/run-virt.include +++ b/os-plugins/plugins/virtualbox/files/run-virt.include @@ -43,7 +43,7 @@ export VBOX_USER_HOME=${confdir} RMDIRS="${snapshotdir} ${confdir} /tmp/.vbox-${USER}-ipc" rm -rf ${RMDIRS} 2>/dev/null machfolder="${confdir}/Machines" -# use vm_shortname for VM name since vm_name can be very long +# use vm_shortname for dir and config names since vm_name can be very long machconfig="${machfolder}/${vm_shortname}/${vm_shortname}.xml" diskfolder="${confdir}/HardDisks" snapshotdir=${machfolder}/${vm_shortname}/Snapshots @@ -233,8 +233,8 @@ case ${boot} in n*|tftp) boot="Network" if [ "${network_kind}" = "NAT" ] && [ -n "${virtualbox_tftpdir}" ]; then - # remove spaces from VM name to avoid Problems /w TFTP in NAT - vm_name=$(echo ${vm_name} | sed -e "s, ,-,g") + # use vm_shortname to avoid Problems /w TFTP in NAT + vm_name=${vm_shortname} # link TFTP dir for NAT TFTP boots mkdir -p ${confdir}/TFTP if [ -e ${virtualbox_tftpdir}/pxelinux.0 ]; then diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index 9e3cbf0a..b4830dc9 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -64,13 +64,14 @@ cleanexit () { ### Get XML file and dir ################################################################################ -# check if mem or graphical mode set +# check if mem, nice or graphical mode set headless=1 +unice=19 while [ $# -gt 0 ]; do case "$1" in -h|--help) echo -e "Usage: run-vmgrid.sh [-g] [--mem ] \c" - echo -e "[/path/]filename[.xml]" + echo -e "[--nice ] [/path/]filename[.xml]" exit ;; -g) @@ -78,10 +79,25 @@ while [ $# -gt 0 ]; do ;; --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) + if echo $2 | grep -qE \ + '^[2-9][0-9][0-9]$|^[1-9][0-9][0-9][0-9]$|^1[0-9][0-9][0-9][0-9]$'; + then + forcemem=$(expr $2 / 4 \* 4) + else + echo "memory $2 not supported (200-19999)!" + exit 1 + fi shift ;; + --nice) + # set nice level + if echo $2 | grep -qE '^-[1-9]$|-1[0-9]$|^-20$|^[0-9]$|^1[0-9]$'; then + unice=$2 + else + echo "nice level $2 does not exist!" + exit 1 + fi + shift *) xmlfile=$@ break @@ -399,11 +415,13 @@ if [ ${headless} -eq 0 ]; then cleanexit 1 fi writelog "Starting ${vmgrid_virt} in graphical mode..." - ${VIRTCMD} ${VIRTCMDOPTS} 2>/dev/null + # start /w low nice level + nice -n ${unice} ${VIRTCMD} ${VIRTCMDOPTS} 2>/dev/null # start headless elif [ -n "${VIRTCMDHL}" ]; then writelog "Starting ${vmgrid_virt} in headless mode..." - ${VIRTCMDHL} ${VIRTCMDOPTSHL} 2>/dev/null + # start /w low nice level + nice -n ${unice} ${VIRTCMDHL} ${VIRTCMDOPTSHL} 2>/dev/null else writelog "${vmgrid_virt}: No headless mode defined, exiting!" cleanexit 1 diff --git a/os-plugins/plugins/vmgrid/files/vmgrid b/os-plugins/plugins/vmgrid/files/vmgrid index 2ddfc5a0..9450ecf7 100644 --- a/os-plugins/plugins/vmgrid/files/vmgrid +++ b/os-plugins/plugins/vmgrid/files/vmgrid @@ -25,7 +25,7 @@ if [ -n "$1" ]; then if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then echo -e "Usage: vmgrid [[-g] [--mem ] \c" - echo -e "[/path/]filename[.xml]]" + echo -e "[--nice ] [/path/]filename[.xml]]" exit 0 else echo "Starting run-vmgrid.sh with options '$@'" -- cgit v1.2.3-55-g7522 From 3254c82af147c5ccbd06fbd225ff1988af699f0e Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Wed, 26 May 2010 22:59:18 +0200 Subject: host.conf stuff added --- os-plugins/plugins/vmchooser/files/run-virt.sh | 2 +- .../vmchooser/init-hooks/80-after-plugins/virtualization.sh | 11 ++++++++++- os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 6 +++--- .../vmgrid/init-hooks/80-after-plugins/virtualization.sh | 11 ++++++++++- 4 files changed, 24 insertions(+), 6 deletions(-) (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/vmchooser/files/run-virt.sh b/os-plugins/plugins/vmchooser/files/run-virt.sh index 771ebef4..df2a7404 100644 --- a/os-plugins/plugins/vmchooser/files/run-virt.sh +++ b/os-plugins/plugins/vmchooser/files/run-virt.sh @@ -132,7 +132,7 @@ mem=$(expr ${totalmem} / 100 \* ${permem} / 4 \* 4) # last two bytes are taken from the bridge of the host # define one MAC per guest macguestpart="00:50:56:${VM_ID}" -machostpart=$(echo ${machostaddr} | awk -F ":" '{print $(NF-1)":"$NF}') +machostpart=$(echo ${hostmacaddr} | awk -F ":" '{print $(NF-1)":"$NF}') macaddr=$(echo "${macguestpart}:${machostpart}" | tr [a-z] [A-Z]) #TODO: remove when vmware modified mac=${machostpart} 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 37576331..23095abf 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 @@ -109,7 +109,11 @@ EOF fi # write mac - echo "machostaddr=${macaddr}" >> ${PLUGINCONFDIR}/virtualization.conf + echo "hostmacaddr=${macaddr}" >> ${PLUGINCONFDIR}/virtualization.conf + # ip addr + echo "hostip=${clientip}" >> ${PLUGINCONFDIR}/virtualization.conf + # hostname + echo "hostname=${host_name}" >> ${PLUGINCONFDIR}/virtualization.conf # get further hw information waitfor /etc/hwinfo.cdrom @@ -126,6 +130,11 @@ EOF j=$(expr $j + 1) done + # copy host information to rwshare of vmgrid plugin + if [ "x${vmgrid_active}" = "x1" ]; then + cp ${PLUGINCONFDIR}/virtualization.conf ${vmgrid_rwmnt}/host.conf + fi + # finished ... [ $DEBUGLEVEL -gt 0 ] \ && echo "ok" diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index b4830dc9..3bbb789d 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -366,7 +366,7 @@ mem=$(expr ${totalmem} / 100 \* ${permem} / 4 \* 4) # last two bytes are taken from the bridge of the host # define one MAC per guest macguestpart="00:50:56:${VM_ID}" -machostpart=$(echo ${machostaddr} | awk -F ":" '{print $(NF-1)":"$NF}') +machostpart=$(echo ${hostmacaddr} | awk -F ":" '{print $(NF-1)":"$NF}') macaddr=$(echo "${macguestpart}:${machostpart}" | tr [a-z] [A-Z]) # ide is expected default, test for the virtual disk image type should @@ -414,12 +414,12 @@ if [ ${headless} -eq 0 ]; then writelog "Grapical mode not available, exiting!" cleanexit 1 fi - writelog "Starting ${vmgrid_virt} in graphical mode..." + writelog "Starting ${vmgrid_virt} in graphical mode /w nice level ${unice}..." # start /w low nice level nice -n ${unice} ${VIRTCMD} ${VIRTCMDOPTS} 2>/dev/null # start headless elif [ -n "${VIRTCMDHL}" ]; then - writelog "Starting ${vmgrid_virt} in headless mode..." + writelog "Starting ${vmgrid_virt} in headless mode /w nice level ${unice}..." # start /w low nice level nice -n ${unice} ${VIRTCMDHL} ${VIRTCMDOPTSHL} 2>/dev/null else 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 37576331..23095abf 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 @@ -109,7 +109,11 @@ EOF fi # write mac - echo "machostaddr=${macaddr}" >> ${PLUGINCONFDIR}/virtualization.conf + echo "hostmacaddr=${macaddr}" >> ${PLUGINCONFDIR}/virtualization.conf + # ip addr + echo "hostip=${clientip}" >> ${PLUGINCONFDIR}/virtualization.conf + # hostname + echo "hostname=${host_name}" >> ${PLUGINCONFDIR}/virtualization.conf # get further hw information waitfor /etc/hwinfo.cdrom @@ -126,6 +130,11 @@ EOF j=$(expr $j + 1) done + # copy host information to rwshare of vmgrid plugin + if [ "x${vmgrid_active}" = "x1" ]; then + cp ${PLUGINCONFDIR}/virtualization.conf ${vmgrid_rwmnt}/host.conf + fi + # finished ... [ $DEBUGLEVEL -gt 0 ] \ && echo "ok" -- cgit v1.2.3-55-g7522 From c754284c9851ebfd0f7ee120c58561515dd84f59 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Fri, 4 Jun 2010 14:58:44 +0200 Subject: forgot ;; in case --- os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index 3bbb789d..376e8182 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -98,6 +98,7 @@ while [ $# -gt 0 ]; do exit 1 fi shift + ;; *) xmlfile=$@ break -- cgit v1.2.3-55-g7522 From 0a4ffc605c3f9bd83975ab2cf191ba309d1aacb2 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Mon, 21 Jun 2010 20:11:48 +0200 Subject: added default to tftpdit attr. --- os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm index f8fad1ba..22d1d73b 100644 --- a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm +++ b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm @@ -132,7 +132,7 @@ sub getAttrInfo End-of-Here content_regex => qr{^(/)}, content_descr => 'local path or "-" (unset)', - default => undef, + default => '/var/lib/virt/virtualbox', }, }; } -- cgit v1.2.3-55-g7522 From 337b6418f8067fb79122fdaaa070baddb016f760 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Fri, 25 Jun 2010 20:19:17 +0200 Subject: added ovz plugin stubs --- .../plugins/openvz/OpenSLX/OSPlugin/openvz.pm | 109 +++++++++++++++++++++ os-plugins/plugins/openvz/XX_openvz.sh | 66 +++++++++++++ os-plugins/plugins/openvz/files/machine.include | 0 os-plugins/plugins/openvz/files/run-virt.include | 37 +++++++ .../init-hooks/20-nw-bridge-config/bridge.sh | 30 ++++++ 5 files changed, 242 insertions(+) create mode 100644 os-plugins/plugins/openvz/OpenSLX/OSPlugin/openvz.pm create mode 100644 os-plugins/plugins/openvz/XX_openvz.sh create mode 100644 os-plugins/plugins/openvz/files/machine.include create mode 100644 os-plugins/plugins/openvz/files/run-virt.include create mode 100755 os-plugins/plugins/openvz/init-hooks/20-nw-bridge-config/bridge.sh (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/openvz/OpenSLX/OSPlugin/openvz.pm b/os-plugins/plugins/openvz/OpenSLX/OSPlugin/openvz.pm new file mode 100644 index 00000000..71ed6f98 --- /dev/null +++ b/os-plugins/plugins/openvz/OpenSLX/OSPlugin/openvz.pm @@ -0,0 +1,109 @@ +# Copyright (c) 2007 - OpenSLX GmbH +# +# This program 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 suggestions, praise, or complaints to feedback@openslx.org +# +# General information about OpenSLX can be found at http://openslx.org/ +# ----------------------------------------------------------------------------- +# openvz.pm +# - implementation of the 'openvz' plugin +# ----------------------------------------------------------------------------- +package OpenSLX::OSPlugin::openvz; + +use strict; +use warnings; + +use base qw(OpenSLX::OSPlugin::Base); + +use File::Path; + +use OpenSLX::Basics; +use OpenSLX::Utils; + +sub new +{ + my $class = shift; + + my $self = { + name => 'openvz', + }; + + return bless $self, $class; +} + +sub getInfo +{ + my $self = shift; + + return { + description => unshiftHereDoc(<<' End-of-Here'), + Configures openVZ diskless boot, no installation yet. + End-of-Here + precedence => 20, + }; +} + +sub getAttrInfo +{ + my $self = shift; + + return { + 'openvz::active' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + should the 'openvz'-plugin be executed during boot? + End-of-Here + content_regex => qr{^(0|1)$}, + content_descr => '1 means active - 0 means inactive', + # set active to 0, later set specially created openVZ system to 1 + default => '0', + }, + # attribute 'imagesrc' defines where we can find openvz images + 'openvz::imagesrc' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + Where do we store our openvz images? NFS? Filesystem? + End-of-Here + content_regex => qr{^(/|nfs://)}, + content_descr => 'local path or URI or "-" (unset)', + default => undef, + }, + }; +} + +sub installationPhase +{ + my $self = shift; + my $info = shift; + + $self->{pluginRepositoryPath} = $info->{'plugin-repo-path'}; + $self->{openslxBasePath} = $info->{'openslx-base-path'}; + + # 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 machine.include ) ) { + copyFile("$pluginBasePath/$file", "$self->{pluginRepositoryPath}/"); + chmod 0644, "$self->{pluginRepositoryPath}/$file"; + } + + return; +} + +sub removalPhase +{ + my $self = shift; + my $info = shift; + + return; +} + +1; diff --git a/os-plugins/plugins/openvz/XX_openvz.sh b/os-plugins/plugins/openvz/XX_openvz.sh new file mode 100644 index 00000000..cbaa31c7 --- /dev/null +++ b/os-plugins/plugins/openvz/XX_openvz.sh @@ -0,0 +1,66 @@ +# Copyright (c) 2007..2008 - RZ Uni Freiburg +# Copyright (c) 2008 - 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 +# +# stage3 part of 'openvz' plugin - the runlevel script +# +# 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/openvz.conf +PLUGINCONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/openvz +PLUGINDIR=/mnt/${OPENSLX_DEFAULT_DIR}/plugin-repo/openvz +VIRTDIR=/mnt/${OPENSLX_DEFAULT_VIRTDIR}/openvz + +# check if the configuration file is available +if [ -e ${CONFFILE} ]; then + + # load needed variables + . ${CONFFILE} + + # Test if this plugin is activated... more or less useless with the + # new plugin system + if [ $openvz_active -ne 0 2>/dev/null ]; then + + [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'openvz' os-plugin ..."; + + # load general configuration + . /etc/initramfs-setup + + # get source of openvz image server (get type, server and path) + if strinstr "/" "${openvz_imagesrc}" ; then + vbimgprot=$(uri_token ${openvz_imagesrc} prot) + vbimgserv=$(uri_token ${openvz_imagesrc} server) + vbimgpath="$(uri_token ${openvz_imagesrc} path)" + fi + if [ -n "${vbimgserv}" ] ; then + # directory where qemu images are expected in + mnttarget=${VIRTDIR} + # mount the openvz image source readonly (ro) + fsmount ${vbimgprot} ${vbimgserv} ${vbimgpath} ${mnttarget} ro + else + [ $DEBUGLEVEL -gt 1 ] && \ + error " * Incomplete information in variable ${openvz_imagesrc}." \ + nonfatal + fi + + # copy virtualization include files to config dir + testmkd ${PLUGINCONFDIR} + cp ${PLUGINDIR}/*.include ${PLUGINCONFDIR} + # copy ${CONFFILE} to ${PLUGINCONFDIR} just in case + cp ${CONFFILE} ${PLUGINCONFDIR} + + # activate init files + + fi +fi diff --git a/os-plugins/plugins/openvz/files/machine.include b/os-plugins/plugins/openvz/files/machine.include new file mode 100644 index 00000000..e69de29b diff --git a/os-plugins/plugins/openvz/files/run-virt.include b/os-plugins/plugins/openvz/files/run-virt.include new file mode 100644 index 00000000..74f26ead --- /dev/null +++ b/os-plugins/plugins/openvz/files/run-virt.include @@ -0,0 +1,37 @@ +# 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 +# +# 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 +# ----------------------------------------------------------------------------- +# run-virt.include +# - Include script for running openVZ on an OpenSLX client via 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 +################################################################################ + +PLUGINCONFXEN="${PLUGINCONFROOT}/${self}" +# create TMPDIR for all users +mkdir -m 1777 /tmp/${self} 2>/dev/null +# dir for configs +confdir="/tmp/${self}/${USER}/${VM_ID}" diff --git a/os-plugins/plugins/openvz/init-hooks/20-nw-bridge-config/bridge.sh b/os-plugins/plugins/openvz/init-hooks/20-nw-bridge-config/bridge.sh new file mode 100755 index 00000000..6aabe8ad --- /dev/null +++ b/os-plugins/plugins/openvz/init-hooks/20-nw-bridge-config/bridge.sh @@ -0,0 +1,30 @@ +#!/bin/ash +# Copyright (c) 2009 - OpenSLX GmbH +# +# This program 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 +# +# Init hook to create a bridge on the active network interface +# (should be kept identical to the files of virtualbox and qemukvm plugins) +############################################################################# + +local bridge=br0 +local brnwif=${nwif} +local nwifmac=${macaddr} + +# bridge 0 already defined or some other problem +brctl addbr ${bridge} || exit 0 +brctl stp ${bridge} 0 +brctl setfd ${bridge} 0.000000000001 +ip link set addr ${nwifmac} ${bridge} +ip link set dev ${nwif} up +brctl addif ${bridge} ${nwif} + +# fixme: sending back the variable to init does not work properly at the +# moment +nwif=${bridge} -- cgit v1.2.3-55-g7522 From edf85a4b946e4153b91054b6cbe868bdc9d1bc65 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Sun, 4 Jul 2010 20:51:46 +0200 Subject: modified copyright years --- os-plugins/plugins/openvz/OpenSLX/OSPlugin/openvz.pm | 3 ++- os-plugins/plugins/openvz/XX_openvz.sh | 4 ++-- os-plugins/plugins/openvz/files/run-virt.include | 4 ++-- os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm | 3 ++- os-plugins/plugins/qemukvm/XX_qemukvm.sh | 1 + os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm | 1 + os-plugins/plugins/virtualbox/XX_virtualbox.sh | 3 ++- .../plugins/vmchooser/init-hooks/80-after-plugins/virtualization.sh | 4 ++-- os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm | 3 ++- os-plugins/plugins/vmgrid/XX_vmgrid.sh | 4 ++-- os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 4 ++-- os-plugins/plugins/vmgrid/files/vmgrid | 4 ++-- .../plugins/vmgrid/init-hooks/80-after-plugins/virtualization.sh | 4 ++-- os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm | 3 ++- os-plugins/plugins/xen/XX_xen.sh | 4 ++-- os-plugins/plugins/xen/files/run-virt.include | 4 ++-- 16 files changed, 30 insertions(+), 23 deletions(-) (limited to 'os-plugins/plugins') diff --git a/os-plugins/plugins/openvz/OpenSLX/OSPlugin/openvz.pm b/os-plugins/plugins/openvz/OpenSLX/OSPlugin/openvz.pm index 71ed6f98..35e12bb2 100644 --- a/os-plugins/plugins/openvz/OpenSLX/OSPlugin/openvz.pm +++ b/os-plugins/plugins/openvz/OpenSLX/OSPlugin/openvz.pm @@ -1,4 +1,5 @@ -# Copyright (c) 2007 - OpenSLX GmbH +# Copyright (c) 2010 - RZ Uni Freiburg +# Copyright (c) 2010 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING diff --git a/os-plugins/plugins/openvz/XX_openvz.sh b/os-plugins/plugins/openvz/XX_openvz.sh index cbaa31c7..721c76a4 100644 --- a/os-plugins/plugins/openvz/XX_openvz.sh +++ b/os-plugins/plugins/openvz/XX_openvz.sh @@ -1,5 +1,5 @@ -# Copyright (c) 2007..2008 - RZ Uni Freiburg -# Copyright (c) 2008 - OpenSLX GmbH +# Copyright (c) 2010 - RZ Uni Freiburg +# Copyright (c) 2010 - OpenSLX GmbH # # This program/file is free software distributed under the GPL version 2. # See http://openslx.org/COPYING diff --git a/os-plugins/plugins/openvz/files/run-virt.include b/os-plugins/plugins/openvz/files/run-virt.include index 74f26ead..53c982c8 100644 --- a/os-plugins/plugins/openvz/files/run-virt.include +++ b/os-plugins/plugins/openvz/files/run-virt.include @@ -1,7 +1,7 @@ # run-virt.include # ----------------------------------------------------------------------------- -# Copyright (c) 2009..2010 - RZ Uni Freiburg -# Copyright (c) 2009..2010 - OpenSLX GmbH +# Copyright (c) 2010 - RZ Uni Freiburg +# Copyright (c) 2010 - OpenSLX GmbH # # This program/file is free software distributed under the GPL version 2. # See http://openslx.org/COPYING diff --git a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm index e4ef657f..14e5917f 100644 --- a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm +++ b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm @@ -1,4 +1,5 @@ -# Copyright (c) 2009 - OpenSLX GmbH +# Copyright (c) 2009..2010 - RZ Uni Freiburg +# Copyright (c) 2009..2010 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING diff --git a/os-plugins/plugins/qemukvm/XX_qemukvm.sh b/os-plugins/plugins/qemukvm/XX_qemukvm.sh index 36ff4f59..8a41ff3b 100644 --- a/os-plugins/plugins/qemukvm/XX_qemukvm.sh +++ b/os-plugins/plugins/qemukvm/XX_qemukvm.sh @@ -1,3 +1,4 @@ +# Copyright (c) 2009..2010 - RZ Uni Freiburg # Copyright (c) 2008..2010 - OpenSLX GmbH # # This program/file is free software distributed under the GPL version 2. diff --git a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm index 22d1d73b..07ec9dc0 100644 --- a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm +++ b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm @@ -1,3 +1,4 @@ +# Copyright (c) 2009..2010 - RZ Uni Freiburg # Copyright (c) 2009..2010 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. diff --git a/os-plugins/plugins/virtualbox/XX_virtualbox.sh b/os-plugins/plugins/virtualbox/XX_virtualbox.sh index 807ef0a8..b54b4bec 100644 --- a/os-plugins/plugins/virtualbox/XX_virtualbox.sh +++ b/os-plugins/plugins/virtualbox/XX_virtualbox.sh @@ -1,4 +1,5 @@ -# Copyright (c) 2009, 2010 - OpenSLX GmbH +# 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 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 23095abf..73a65ac5 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 @@ -1,5 +1,5 @@ -# Copyright (c) 2008..2010 - RZ Uni Freiburg -# Copyright (c) 2008..2010 - OpenSLX GmbH +# Copyright (c) 2010 - RZ Uni Freiburg +# Copyright (c) 2010 - OpenSLX GmbH # # This program/file is free software distributed under the GPL version 2. # See http://openslx.org/COPYING diff --git a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm index d90a6f53..0965b482 100644 --- a/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm +++ b/os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm @@ -1,4 +1,5 @@ -# Copyright (c) 2008, 2010 - OpenSLX GmbH +# Copyright (c) 2010 - RZ Uni Freiburg +# Copyright (c) 2010 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING diff --git a/os-plugins/plugins/vmgrid/XX_vmgrid.sh b/os-plugins/plugins/vmgrid/XX_vmgrid.sh index f75c895d..16f5fbd1 100644 --- a/os-plugins/plugins/vmgrid/XX_vmgrid.sh +++ b/os-plugins/plugins/vmgrid/XX_vmgrid.sh @@ -1,5 +1,5 @@ -# Copyright (c) 2008..2010 - RZ Uni Freiburg -# Copyright (c) 2008..2010 - OpenSLX GmbH +# Copyright (c) 2010 - RZ Uni Freiburg +# Copyright (c) 2010 - OpenSLX GmbH # # This program/file is free software distributed under the GPL version 2. # See http://openslx.org/COPYING diff --git a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh index 376e8182..56cdbfce 100644 --- a/os-plugins/plugins/vmgrid/files/run-vmgrid.sh +++ b/os-plugins/plugins/vmgrid/files/run-vmgrid.sh @@ -1,7 +1,7 @@ #!/bin/bash # ----------------------------------------------------------------------------- -# Copyright (c) 2007..2010 - RZ Uni FR -# Copyright (c) 2007..2010 - OpenSLX GmbH +# Copyright (c) 2010 - RZ Uni FR +# Copyright (c) 2010 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING diff --git a/os-plugins/plugins/vmgrid/files/vmgrid b/os-plugins/plugins/vmgrid/files/vmgrid index 9450ecf7..2bb91481 100644 --- a/os-plugins/plugins/vmgrid/files/vmgrid +++ b/os-plugins/plugins/vmgrid/files/vmgrid @@ -1,7 +1,7 @@ #!/bin/bash # ----------------------------------------------------------------------------- -# Copyright (c) 2007..2010 - RZ Uni FR -# Copyright (c) 2007..2010 - OpenSLX GmbH +# Copyright (c) 2010 - RZ Uni FR +# Copyright (c) 2010 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING 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 23095abf..73a65ac5 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 @@ -1,5 +1,5 @@ -# Copyright (c) 2008..2010 - RZ Uni Freiburg -# Copyright (c) 2008..2010 - OpenSLX GmbH +# Copyright (c) 2010 - RZ Uni Freiburg +# Copyright (c) 2010 - OpenSLX GmbH # # This program/file is free software distributed under the GPL version 2. # See http://openslx.org/COPYING diff --git a/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm b/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm index 8af752b4..12331983 100644 --- a/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm +++ b/os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm @@ -1,4 +1,5 @@ -# Copyright (c) 2007 - OpenSLX GmbH +# Copyright (c) 2010 - RZ Uni Freiburg +# Copyright (c) 2010 - OpenSLX GmbH # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING diff --git a/os-plugins/plugins/xen/XX_xen.sh b/os-plugins/plugins/xen/XX_xen.sh index af3f6cc4..7dddeee0 100644 --- a/os-plugins/plugins/xen/XX_xen.sh +++ b/os-plugins/plugins/xen/XX_xen.sh @@ -1,5 +1,5 @@ -# Copyright (c) 2007..2008 - RZ Uni Freiburg -# Copyright (c) 2008 - OpenSLX GmbH +# Copyright (c) 2010 - RZ Uni Freiburg +# Copyright (c) 2010 - OpenSLX GmbH # # This program/file is free software distributed under the GPL version 2. # See http://openslx.org/COPYING diff --git a/os-plugins/plugins/xen/files/run-virt.include b/os-plugins/plugins/xen/files/run-virt.include index 43213e34..36a1d1f4 100644 --- a/os-plugins/plugins/xen/files/run-virt.include +++ b/os-plugins/plugins/xen/files/run-virt.include @@ -1,7 +1,7 @@ # run-virt.include # ----------------------------------------------------------------------------- -# Copyright (c) 2009..2010 - RZ Uni Freiburg -# Copyright (c) 2009..2010 - OpenSLX GmbH +# Copyright (c) 2010 - RZ Uni Freiburg +# Copyright (c) 2010 - OpenSLX GmbH # # This program/file is free software distributed under the GPL version 2. # See http://openslx.org/COPYING -- cgit v1.2.3-55-g7522