From 994aa36c095470f1c163e32b28fa324f7376f127 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Sun, 21 Mar 2010 19:50:12 +0100 Subject: qemukvm angepasst... geht noch nicht :( --- .../plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm | 3 +- os-plugins/plugins/qemukvm/XX_qemukvm.sh | 87 +++++---- os-plugins/plugins/qemukvm/files/kvm.cmdline | 196 +++++++++++++++++++++ os-plugins/plugins/qemukvm/files/qemu-ifup | 12 +- os-plugins/plugins/qemukvm/files/run-virt.include | 34 +++- 5 files changed, 281 insertions(+), 51 deletions(-) create mode 100644 os-plugins/plugins/qemukvm/files/kvm.cmdline (limited to 'os-plugins/plugins/qemukvm') diff --git a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm index ee4b3417..52255116 100644 --- a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm +++ b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm @@ -136,7 +136,8 @@ sub installationPhase $initFile->setName("qemukvm"); $initFile->setDesc("Setup environment for QEMU/KVM"); - $initFile->addToBlock('head','. /etc/opt/openslx/network.qemukvm'); + $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 for i in 0 1 2; do diff --git a/os-plugins/plugins/qemukvm/XX_qemukvm.sh b/os-plugins/plugins/qemukvm/XX_qemukvm.sh index a63af161..47d2689f 100644 --- a/os-plugins/plugins/qemukvm/XX_qemukvm.sh +++ b/os-plugins/plugins/qemukvm/XX_qemukvm.sh @@ -11,39 +11,51 @@ # 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/qemukvm.conf" +PLUGINCONFDIR=/mnt/${OPENSLX_DEFAULT_CONFDIR}/plugins/qemukvm +PLUGINDIR=${OPENSLX_DEFAULT_DIR}/plugin-repo/qemukvm +VIRTDIR=/mnt/${OPENSLX_DEFAULT_VIRTDIR}/qemukvm +LOGDIR=/mnt/${OPENSLX_DEFAULT_LOGDIR} + # check if the configuration file is available -if [ -e /initramfs/plugin-conf/qemukvm.conf ]; then +if [ -e ${CONFFILE} ]; then - # 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 - [ $DEBUGLEVEL -gt 0 ] && echo " * Loaded kvm_intel module" - 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 - exit 1 - fi - # load the tunnel device module - modprobe tun 2>/dev/null - # load needed variables - . /initramfs/plugin-conf/qemukvm.conf + . ${CONFFILE} # Test if this plugin is activated... more or less useless with the # new plugin system - if [ $qemukvm_active -ne 0 ]; then - + if [ ${qemukvm_active} -ne 0 2>/dev/null ]; then [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'qemukvm' os-plugin ..."; + # load general configuration . /initramfs/machine-setup + # load needed variables + . /initramfs/plugin-conf/qemukvm.conf + + # 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 + [ $DEBUGLEVEL -gt 0 ] && echo " * Loaded kvm_intel module" + 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 + exit 1 + fi + + # 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 @@ -60,29 +72,29 @@ qemu(-kvm)\n makes not much sense." nonfatal [ $DEBUGLEVEL -gt 1 ] && error " * Incomplete information in variable \ ${qemukvm_imagesrc}." nonfatal fi - # copy version depending files - the vmchooser expects for every virtua- - # lization plugin a file named after it (here run-qemukvm.include) - testmkd /mnt/etc/opt/openslx/plugins/qemukvm - cp /mnt/opt/openslx/plugin-repo/qemukvm/run-virt.include \ - /mnt/etc/opt/openslx/plugins/qemukvm/run-qemukvm.include + + # 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" honetwork="192.168.102" echo -e "nataddress=${natnetwork}.254/24\nhoaddress=${honetwork}.254/24" \ - >/mnt/etc/opt/openslx/plugins/qemukvm/network.qemukvm + >${PLUGINCONFDIR}/network.conf # copy the runlevel script (proper place for all distros??) - cp /mnt/opt/openslx/plugin-repo/qemukvm/qemukvm /mnt/etc/init.d + cp /mnt/${PLUGINDIR}/qemukvm /mnt/etc/init.d chmod 0755 /mnt/etc/init.d/qemukvm rllinker "qemukvm" 22 2 # copy the /etc/qemu-ifup script and enable extended rights for running # the emulator and certain network commands via sudo - ln -sf /opt/openslx/plugin-repo/qemukvm/qemu-ifup /mnt/etc/qemu-ifup - ln -sf /opt/openslx/plugin-repo/qemukvm/qemu-ifdown /mnt/etc/qemu-ifdown - ln -sf /opt/openslx/plugin-repo/qemukvm/qemu-ifup /mnt/etc/kvm-ifup - ln -sf /opt/openslx/plugin-repo/qemukvm/qemu-ifdown /mnt/etc/kvm-ifdown + 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 for qemubin in qemu kvm ; do qemu="$(binfinder ${qemubin})" @@ -93,8 +105,9 @@ ${qemukvm_imagesrc}." nonfatal #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\ -ALL ALL=NOPASSWD: killall udhcpd" >>/mnt/etc/sudoers +# TODO: killall nur mit fullpath!!! +ALL ALL=NOPASSWD: /usr/bin/killall udhcpd" >>/mnt/etc/sudoers fi else - [ $DEBUGLEVEL -gt 0 ] && echo " * Configuration of qemukvm plugin failed" + [ $DEBUGLEVEL -gt 0 ] && echo " * Configuration of 'qemukvm' plugin failed" fi diff --git a/os-plugins/plugins/qemukvm/files/kvm.cmdline b/os-plugins/plugins/qemukvm/files/kvm.cmdline new file mode 100644 index 00000000..b3352cb5 --- /dev/null +++ b/os-plugins/plugins/qemukvm/files/kvm.cmdline @@ -0,0 +1,196 @@ +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 +-curses use a curses/ncurses interface instead of SDL +-no-frame open SDL window without a frame and window decorations +-alt-grab use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt) +-no-quit disable SDL window close capability +-sdl enable SDL +-portrait rotate graphical output 90 deg left (only PXA LCD) +-vga [std|cirrus|vmware|none] + select video card type +-full-screen start in full screen +-vnc display start a VNC server on display +-name string set the name of the guest +-uuid %08x-%04x-%04x-%04x-%012x specify machine UUID + +Network options: +-net nic[,vlan=n][,macaddr=addr][,model=type][,name=str] + create a new Network Interface Card and connect it to VLAN 'n' +-net user[,vlan=n][,name=str][,hostname=host] + connect the user mode network stack to VLAN 'n' and send + hostname 'host' to DHCP clients +-net tap[,vlan=n][,name=str][,fd=h][,ifname=name][,script=file][,downscript=dfile] + connect the host TAP network interface to VLAN 'n' and use the + network scripts 'file' (default=/etc/kvm-ifup) + and 'dfile' (default=/etc/kvm-ifdown); + use '[down]script=no' to disable script execution; + use 'fd=h' to connect to an already opened TAP interface +-net socket[,vlan=n][,name=str][,fd=h][,listen=[host]:port][,connect=host:port] + connect the vlan 'n' to another VLAN using a socket connection +-net socket[,vlan=n][,name=str][,fd=h][,mcast=maddr:port] + connect the vlan 'n' to multicast maddr and port +-net none use it alone to have zero network devices; if no -net option + is provided, the default is '-net nic -net user' +-tftp dir allow tftp access to files in dir [-net user] +-bootp file advertise file in BOOTP replies +-smb dir allow SMB access to files in 'dir' [-net user] +-redir [tcp|udp]:host-port:[guest-host]:guest-port + redirect TCP or UDP connections from host to guest [-net user] + +-bt hci,null dumb bluetooth HCI - doesn't respond to commands +-bt hci,host[:id] + use host's HCI with the given name +-bt hci[,vlan=n] + emulate a standard HCI in virtual scatternet 'n' +-bt vhci[,vlan=n] + add host computer to virtual scatternet 'n' using VHCI +-bt device:dev[,vlan=n] + emulate a bluetooth device 'dev' in scatternet 'n' + + +i386 target only: +-win2k-hack use it when installing Windows 2000 to avoid a disk full bug +-rtc-td-hack use it to fix time drift in Windows ACPI HAL +-no-fd-bootchk disable boot signature checking for floppy disks +-no-acpi disable ACPI +-no-hpet disable HPET +Linux boot specific: +-kernel bzImage use 'bzImage' as kernel image +-append cmdline use 'cmdline' as kernel command line +-initrd file use 'file' as initial ram disk + +Debug/Expert options: +-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' +-S freeze CPU at startup (use 'c' to start execution) +-s wait gdb connection to port +-p port set gdb connection port [default=1234] +-d item1,... output log to /tmp/qemu.log (use -d ? for a list of log items) +-hdachs c,h,s[,t] + force hard disk 0 physical geometry and the optional BIOS + translation (t=none or lba) (usually qemu can guess them) +-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 +-no-kvm-irqchip disable KVM kernel mode PIC/IOAPIC/LAPIC +-no-kvm-pit disable KVM kernel mode PIT +-no-kvm-pit-reinjection disable KVM kernel mode PIT interrupt reinjection +-enable-nesting enable support for running a VM inside the VM (AMD only) +-pcidevice host=bus:dev.func[,dma=none][,name=string] + expose a PCI device to the guest OS. + dma=none: don't perform any dma translations (default is to use an iommu) + 'string' is used in log output. +-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 +-tdf inject timer interrupts that got lost +-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 +-clock force the use of the given methods for timer alarm. + To see what timers are available use -clock ? +-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 +-tb-size n set TB size +-incoming p prepare for incoming migration, listen on port p + +During emulation, the following keys are useful: +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 diff --git a/os-plugins/plugins/qemukvm/files/qemu-ifup b/os-plugins/plugins/qemukvm/files/qemu-ifup index 6a25ad29..1f1e0cc6 100644 --- a/os-plugins/plugins/qemukvm/files/qemu-ifup +++ b/os-plugins/plugins/qemukvm/files/qemu-ifup @@ -13,10 +13,14 @@ # - 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. - -. /etc/opt/openslx/plugin-repo/qemukvm/network.qemukvm +. ${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. @@ -32,7 +36,7 @@ case "$1" in 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," \ - /etc/opt/openslx/plugin-repo/qemukvm/udhcpd.conf \ + ${PLUGINDIR}/udhcpd.conf \ >/tmp/qemu-$USER/udhcpd.conf touch /tmp/qemu-$USER/udhcpd.leases # ip link set tap1 up @@ -45,7 +49,7 @@ case "$1" in # 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.qemukvm >/tmp/qemu-$USER/udhcpd.conf + /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 diff --git a/os-plugins/plugins/qemukvm/files/run-virt.include b/os-plugins/plugins/qemukvm/files/run-virt.include index b1f76535..8d6d442b 100644 --- a/os-plugins/plugins/qemukvm/files/run-virt.include +++ b/os-plugins/plugins/qemukvm/files/run-virt.include @@ -1,6 +1,7 @@ -# qemukvm.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,13 +10,26 @@ # send your feedback to feedback@openslx.org # # General information about OpenSLX can be found at http://openslx.org -# -# Include script for running the QEMU/Linux KVM virtual machine on an OpenSLX -# client via the run-virt.sh. The stuff is copied to /etc/opt/openslx/run- -# qemukvm.include during stage3. +# ----------------------------------------------------------------------------- +# run-virt.include +# - Include script for running the QEMU/Linux KVM virtual machine 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" + # TODO: exit wenn conf wichtig + #exit 1 +fi -# include general configuration from vmchooser -. /etc/opt/openslx/run-virt.include +################################################################################ +### Pepare and configure virtual machine and disk image +################################################################################ permem=50 mem=$(expr ${totalmem} / 100 \* ${permem}) @@ -72,6 +86,8 @@ for tool in kvm qemu-kvm qemu; do VIRTCMD=$(which ${tool} 2>/dev/null) [ "x$VIRTCMD" != "x" ] && break done + [ -z $VIRTCMD ] && { writelog "No qemu/kvm tool found."; exit 1; } + VIRTCMD="sudo $VIRTCMD" VIRTCMDOPTS="${VIRTCMDOPTS} -boot c -alt-grab ${diskfile}" -- 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/qemukvm') 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/qemukvm') 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/qemukvm') 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/qemukvm') 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 46fbdd6d0a6dd5896a2b798deb95aa61a089a355 Mon Sep 17 00:00:00 2001 From: Michael Janczyk Date: Thu, 1 Apr 2010 21:35:54 +0200 Subject: xen nfs boot, xen boot --- initramfs/stage3-stuff/bin/hwautocfg | 4 +- os-plugins/plugins/qemukvm/files/run-virt.include | 43 +++++++++---- .../virtualbox/OpenSLX/OSPlugin/virtualbox.pm | 8 ++- .../plugins/virtualbox/files/machine.include | 4 +- .../plugins/virtualbox/files/run-virt.include | 71 ++++++++++++---------- .../plugins/virtualbox/files/virtualbox.include | 2 +- os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 24 ++++---- os-plugins/plugins/xen/OpenSLX/OSPlugin/xen.pm | 55 ++++++++++++++++- os-plugins/plugins/xen/XX_xen.sh | 48 +++++++++++++-- os-plugins/plugins/xen/files/run-virt.include | 48 +++++++++++---- .../xen/init-hooks/10-have-nw-modules/xennet.sh | 4 ++ 11 files changed, 230 insertions(+), 81 deletions(-) create mode 100644 os-plugins/plugins/xen/init-hooks/10-have-nw-modules/xennet.sh (limited to 'os-plugins/plugins/qemukvm') diff --git a/initramfs/stage3-stuff/bin/hwautocfg b/initramfs/stage3-stuff/bin/hwautocfg index 9cd0f8a4..fee54a16 100755 --- a/initramfs/stage3-stuff/bin/hwautocfg +++ b/initramfs/stage3-stuff/bin/hwautocfg @@ -29,7 +29,9 @@ echo "0 0 0 0" >/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/qemukvm') 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/qemukvm') 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 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/qemukvm') 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 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/qemukvm') 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 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/qemukvm') 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