diff options
author | Michael Janczyk | 2010-03-24 20:01:46 +0100 |
---|---|---|
committer | Michael Janczyk | 2010-03-24 20:01:46 +0100 |
commit | 1f031fbafab207fe0879217ae9215caea783ed00 (patch) | |
tree | a1e1f8dcadba4602738cb404f9279b9482bbc790 /os-plugins | |
parent | qemukvm further modifications, first xen runscripts (diff) | |
download | core-1f031fbafab207fe0879217ae9215caea783ed00.tar.gz core-1f031fbafab207fe0879217ae9215caea783ed00.tar.xz core-1f031fbafab207fe0879217ae9215caea783ed00.zip |
new run-virt.include for xen plugin. qemukvm modules now loaded via runlevelscript qemukvm, script added to sudoers as well. better ideas?
Diffstat (limited to 'os-plugins')
-rw-r--r-- | os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm | 27 | ||||
-rw-r--r-- | os-plugins/plugins/qemukvm/XX_qemukvm.sh | 42 | ||||
-rw-r--r-- | os-plugins/plugins/virtualbox/files/run-virt.include | 4 | ||||
-rw-r--r-- | os-plugins/plugins/vmchooser/files/run-virt.sh | 2 | ||||
-rw-r--r-- | os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 36 | ||||
-rw-r--r-- | os-plugins/plugins/xen/XX_xen.sh | 5 | ||||
-rw-r--r-- | os-plugins/plugins/xen/files/hvm.include | 209 | ||||
-rw-r--r-- | os-plugins/plugins/xen/files/machine.include | 114 | ||||
-rw-r--r-- | os-plugins/plugins/xen/files/run-virt.include | 318 |
9 files changed, 403 insertions, 354 deletions
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.*\\\<vmx\\\> /proc/cpuinfo; then + module=kvm_intel + elif grep -q ^flags.*\\\<svm\\\> /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 '<?xml' "${xmlfile}" >/dev/null 2>&1; then writelog \ @@ -143,13 +143,18 @@ if ! grep '<?xml' "${xmlfile}" >/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 '<image_name param=.*"' ${xmlfile} | \ + sed -e "s/&.*;/; /g" | awk -F '"' '{ print $2 }') +if echo ${imgname} 2>/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 <<EOF +# -*- mode: python; -*- +#============================================================================ +# Python configuration setup for 'xm create'. +# This configuration was created through $0 on $(date) +#============================================================================ + +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. +memory = ${mem} + +# 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 = "${vm_name}" + +#----------------------------------------------------------------------------- +# 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' ] +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 <<EOF # -*- 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 configuration was created through $0 on $(date) #============================================================================ #---------------------------------------------------------------------------- # Kernel image file and (optional) ramdisk (initrd). -kernel = "/boot/vmlinuz-xen" -ramdisk = "/boot/initrd-xen" +kernel = "${xen_kernel}" +ramdisk = "${xen_ramdisk}" # 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" +#bootentry = "hda1:/${xen_kernel},/${xen_ramdisk}" +# TODO: check these: +#bootargs="--entry=xvda2:/boot/vmlinuz-xen,/boot/initrd-xen" + +localtime=0 -# The domain build function. Default is 'linux'. -#builder='linux' +# The domain build function. Default is 'linux', HVM domain uses 'hvm'. +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 +memory = ${mem} # 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" +name = "${vm_name}" # 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 +#cpus = "${xen_cpus}" # Number of Virtual CPUS to use, default is 1 -#vcpus = 1 +#vcpus = ${xen_vcpus} #---------------------------------------------------------------------------- # Define network interfaces. -# By default, no network interfaces are configured. You may have one created +# 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 = [ '' ] +vif = [ '${xen_vif}' ] #---------------------------------------------------------------------------- # Define the disk devices you want the domain to have access to, and @@ -64,40 +57,26 @@ vif = [ '' ] # 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' ] +# disk = [ 'phy:hda1,hda1,w' ] +disk = [ '${xen_disk}' ] #---------------------------------------------------------------------------- # 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. @@ -123,16 +102,16 @@ disk = [ 'phy:hda1,hda1,w' ] # variables used by custom rc scripts (e.g. VMID=, usr= ). # Set if you want dhcp to allocate the IP address. -#dhcp="dhcp" +dhcp="${xen_dhcp}" # Set netmask. #netmask= # Set default gateway. #gateway= # Set the hostname. -#hostname= "vm%d" % vmid +hostname= "${hostname}" -# Set root device. -root = "/dev/hda1" +# Set root device (eg. /dev/hda1). +root = "${xen_root}" # Root device for nfs. #root = "/dev/nfs" @@ -142,13 +121,13 @@ root = "/dev/hda1" #nfs_root = '/full/path/to/root/directory' # Extra arguments to pass to the kernel. -extra = "" +# Eg: set runlevel +extra = "${xen_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; @@ -156,34 +135,33 @@ extra = "" # 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: +# 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 = [ 'PDEV, VDEV' ] +#vscsi = [ '/dev/sdx, 0:0:0:0' ] + #============================================================================ +EOF diff --git a/os-plugins/plugins/xen/files/run-virt.include b/os-plugins/plugins/xen/files/run-virt.include index beba0bb6..aeadf68e 100644 --- a/os-plugins/plugins/xen/files/run-virt.include +++ b/os-plugins/plugins/xen/files/run-virt.include @@ -30,261 +30,97 @@ fi ### Declaration of default variables ################################################################################ -exit -#PLUGINCONFVIRTUALBOX="${PLUGINCONFROOT}/${self}" +PLUGINCONFXEN="${PLUGINCONFROOT}/${self}" # create TMPDIR for all users -#mkdir -m 1777 /tmp/${self} 2>/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='<SharedFolder name="share"' -# sharedf="${sharedf} hostPath=\"${rwshare}\" writable=\"true\"/>" -# sed -i "s,</SharedFolders>, ${sharedf}\n </SharedFolders>," \ -# "${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='<ExtraDataItem name="VBoxInternal/Devices' \ -# extradataitem="${extradataitem}/${network_card}/0/LUN#0/Config/ssh/" -# extradataguestport='GuestPort" value="22"/>' -# extradatahostport="HostPort\" value=\"${vmsshport}\"/>" -# extradataprotocol='Protocol" value="TCP"/>' -# sed -i "s,</ExtraData>, ${extradataitem}${extradataguestport}\n\ -# ${extradataitem}${extradatahostport}\n\ -# ${extradataitem}${extradataprotocol}\n\ -# </ExtraData>," "${machconfig}" -# writelog "\tGuest SSH port:\t\t${vmsshport}" -#fi -# -#cat ${OPENSLX_DEFAULT_DIR}/plugin-repo/virtualbox/empty-diff.vdi.gz | \ -# gunzip > "${snapshotdir}/{${snapshotuuid}}.vdi" -# + +. ${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}" |