summaryrefslogtreecommitdiffstats
path: root/os-plugins/plugins/qemukvm
diff options
context:
space:
mode:
authorDirk von Suchodoletz2009-03-05 15:06:08 +0100
committerDirk von Suchodoletz2009-03-05 15:06:08 +0100
commit474e19aacc78a4f9dec99f9f7cba71fd2f87ab81 (patch)
tree3cb3a9c3f3bc70b7756dab8636cfc640439c54ef /os-plugins/plugins/qemukvm
parentFix for transportation of init variables into hooks and back again. (diff)
downloadcore-474e19aacc78a4f9dec99f9f7cba71fd2f87ab81.tar.gz
core-474e19aacc78a4f9dec99f9f7cba71fd2f87ab81.tar.xz
core-474e19aacc78a4f9dec99f9f7cba71fd2f87ab81.zip
Developing the qemukvm plugin (stage4 stuff) ...
git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2668 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins/plugins/qemukvm')
-rw-r--r--os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm7
-rw-r--r--os-plugins/plugins/qemukvm/XX_qemukvm.sh68
-rw-r--r--os-plugins/plugins/qemukvm/files/qemu-ifup20
-rw-r--r--os-plugins/plugins/qemukvm/files/qemu-ifup.sudo45
4 files changed, 138 insertions, 2 deletions
diff --git a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm
index 2af56f72..bf05976c 100644
--- a/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm
+++ b/os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm
@@ -120,7 +120,12 @@ sub installationPhase
# 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
+ copyFile("$self->{openslxBasePath}/lib/plugins/qemukvm/files/qemu-ifup",
+ "$self->{pluginRepositoryPath}/");
+ # Copy the sudo stuff wrapped in /etc/qemu-ifup
+ copyFile("$self->{openslxBasePath}/lib/plugins/qemukvm/files/qemu-ifup.sudo",
+ "$self->{pluginRepositoryPath}/");
return;
}
diff --git a/os-plugins/plugins/qemukvm/XX_qemukvm.sh b/os-plugins/plugins/qemukvm/XX_qemukvm.sh
index 445405dc..54ee0d74 100644
--- a/os-plugins/plugins/qemukvm/XX_qemukvm.sh
+++ b/os-plugins/plugins/qemukvm/XX_qemukvm.sh
@@ -8,9 +8,61 @@
#
# General information about OpenSLX can be found at http://openslx.org
#
-# script is included from init via the "." load function - thus it has all
+# Script is included from init via the "." load function - thus it has all
# variables and functions available
+write_udhcpd_conf ()
+{
+local cfgfile=$1
+echo "
+# udhcpd configuration file written by $0 during OpenSLX stage3 configuration
+
+# The start and end of the IP lease block
+start 192.168.101.20
+end 192.168.101.100
+
+# The interface that udhcpd will use
+interface NWIF
+
+# How long an offered address is reserved (leased) in seconds
+offer_time 6000
+
+# The location of the leases file
+lease_file /var/lib/misc/udhcpd.leases
+
+# The location of the pid file
+pidfile /var/run/udhcpd.pid
+
+opt dns $domain_name_servers
+option subnet 255.255.255.0
+opt router 192.168.10.2
+opt wins 192.168.10.10
+option domain $domain_name
+
+# Currently supported options, for more info, see options.c
+#subnet
+#timezone
+#router
+#timesvr
+#namesvr
+#dns
+#logsvr
+#cookiesvr
+#lprsvr
+#bootsize
+#domain
+#swapsvr
+#rootpath
+#ipttl
+#mtu
+#broadcast
+#wins
+#lease
+#ntpsrv
+#tftp
+#bootfile
+" >$file
+}
# check if the configuration file is available
if [ -e /initramfs/plugin-conf/qemukvm.conf ]; then
@@ -64,6 +116,20 @@ ${qemukvm_imagesrc}." nonfatal
testmkd /mnt/etc/opt/openslx
cp /mnt/opt/openslx/plugin-repo/qemukvm/run-virt.include \
/mnt/etc/opt/openslx/run-qemukvm.include
+ # create a template udhcpd configuration file
+ write_udhcpd_conf /mnt/etc/opt/openslx/udhcpd.qemukvm
+
+ # for the busybox dhcp server
+ testmkd /mnt/var/lib/misc
+ touch /mnt/var/lib/misc/udhcpd.leases
+
+ # copy the /etc/qemu-ifup script
+ cp /mnt/opt/openslx/plugin-repo/qemukvm/qemu-ifup /mnt/etc/qemu-ifup
+ cp /mnt/opt/openslx/plugin-repo/qemukvm/qemu-ifup.sudo \
+ /mnt/etc/opt/openslx
+ chmod u+x /mnt/etc/opt/openslx/qemu-ifup.sudo
+ echo "%users ALL=NOPASSWD: /etc/opt/openslx/qemu-ifup.sudo" \
+ >>/mnt/etc/sudoers
fi
else
[ $DEBUGLEVEL -gt 0 ] && echo " * Configuration of qemukvm plugin failed"
diff --git a/os-plugins/plugins/qemukvm/files/qemu-ifup b/os-plugins/plugins/qemukvm/files/qemu-ifup
new file mode 100644
index 00000000..26707b8b
--- /dev/null
+++ b/os-plugins/plugins/qemukvm/files/qemu-ifup
@@ -0,0 +1,20 @@
+#!/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
+# - Wrapper script for running certain stuff priviledged
+# -----------------------------------------------------------------------------
+
+# Run the real action script with sudo - this script should have been added
+# during SLX stage3 to the sudoers list.
+
+sudo /etc/opt/openslx/qemu-ifup.sudo
+
diff --git a/os-plugins/plugins/qemukvm/files/qemu-ifup.sudo b/os-plugins/plugins/qemukvm/files/qemu-ifup.sudo
new file mode 100644
index 00000000..0c9187b5
--- /dev/null
+++ b/os-plugins/plugins/qemukvm/files/qemu-ifup.sudo
@@ -0,0 +1,45 @@
+#!/bin/bash
+# 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.sudo
+# - Script used for network setup of qemukvm in Stage4
+# -----------------------------------------------------------------------------
+
+# Use the udhcpcd as DHCP server and brctl as provided by default in OpenSLX
+# environments.
+brctlcmd="LD_LIBRARY_PATH=/opt/openslx/uclib-rootfs/lib\
+ /opt/openslx/uclib-rootfs/usr/sbin/brctl"
+dhcpdcmd="LD_LIBRARY_PATH=/opt/openslx/uclib-rootfs/lib\
+ /opt/openslx/uclib-rootfs/usr/sbin/udhcpd"
+
+# 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
+ eval $brctlcmd addif br0 tap0
+ ;;
+ tap1)
+ # Configuring DHCP on host tap1 interface and enable IP masquerading
+ mkdir /var/lib/qemu
+ sed "s,NWIF,tap1,;s,/misc,/qemu," /etc/opt/openslx/udhcpd.qemukvm \
+ >/var/lib/qemu/udhcpd.conf
+ eval $dhcpdcmd /var/lib/qemu/udhcpd.conf
+ echo "1" >/proc/sys/net/ipv4/conf/br0/forwarding
+ echo "1" >/proc/sys/net/ipv4/conf/tap1/forwarding
+ iptables -t nat -A POSTROUTING -i tap1 -o br0 -j MASQUERADE
+ ;;
+ tap2)
+ :
+ ;;
+esac
+
+