diff options
Diffstat (limited to 'os-plugins/plugins')
| -rw-r--r-- | os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm | 38 | ||||
| -rw-r--r-- | os-plugins/plugins/qemukvm/XX_qemukvm.sh | 30 | ||||
| -rw-r--r-- | os-plugins/plugins/qemukvm/files/ifdown (renamed from os-plugins/plugins/qemukvm/files/qemu-ifdown) | 0 | ||||
| -rw-r--r-- | os-plugins/plugins/qemukvm/files/ifup (renamed from os-plugins/plugins/qemukvm/files/qemu-ifup) | 27 | ||||
| -rw-r--r-- | os-plugins/plugins/qemukvm/files/run-virt.include | 50 | ||||
| -rwxr-xr-x | os-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh | 11 | ||||
| -rw-r--r-- | os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm | 9 | ||||
| -rw-r--r-- | os-plugins/plugins/vmgrid/OpenSLX/OSPlugin/vmgrid.pm | 2 | ||||
| -rw-r--r-- | os-plugins/plugins/vmgrid/files/run-vmgrid.sh | 2 | ||||
| -rw-r--r-- | os-plugins/plugins/vmgrid/files/vmgrid | 2 |
10 files changed, 97 insertions, 74 deletions
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 <<EOF\ +ALL ALL=NOPASSWD: ${killall} udhcpd +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 fi else [ $DEBUGLEVEL -gt 0 ] && echo " * Configuration of 'qemukvm' plugin failed" diff --git a/os-plugins/plugins/qemukvm/files/qemu-ifdown b/os-plugins/plugins/qemukvm/files/ifdown index 8c52d76f..8c52d76f 100644 --- a/os-plugins/plugins/qemukvm/files/qemu-ifdown +++ b/os-plugins/plugins/qemukvm/files/ifdown diff --git a/os-plugins/plugins/qemukvm/files/qemu-ifup b/os-plugins/plugins/qemukvm/files/ifup index 1f1e0cc6..ed4a277d 100644 --- a/os-plugins/plugins/qemukvm/files/qemu-ifup +++ b/os-plugins/plugins/qemukvm/files/ifup @@ -9,14 +9,14 @@ # # General information about OpenSLX can be found at http://openslx.org/ # ----------------------------------------------------------------------------- -# qemu-ifup +# 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 +QKTMPDIR=/tmp/qemukvm/$USER/$$ # Use the udhcpcd as DHCP server and brctl as provided by default in OpenSLX # environments via uclibc-wrapper. @@ -31,33 +31,32 @@ case "$1" in ;; tap1) # Configuring DHCP on host tap1 interface and enable IP masquerading - [ -d /tmp/qemu-$USER ] || mkdir -p /tmp/qemu-$USER + [ -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,/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 + -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 /tmp/qemu-$USER/udhcpd.conf + -S ${QKTMPDIR}/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 + [ -d ${QKTMPDIR} ] || 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 + ${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 /tmp/qemu-$USER/udhcpd.conf + -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 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 <<EOF\ # general udhcpd configuration file for virtual machines written by # $0 during OpenSLX stage3 configuration @@ -53,4 +57,5 @@ option domain virtual.site ${domain_name} #wins #lease #ntpsrv #tftp #bootfile -" >/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" |
