summaryrefslogtreecommitdiffstats
path: root/os-plugins/plugins/qemukvm
diff options
context:
space:
mode:
authorMichael Janczyk2010-04-02 20:50:29 +0200
committerMichael Janczyk2010-04-02 20:50:29 +0200
commit5dd09617cd77f2a616c770152c4cd8319803a05f (patch)
tree09f9a8d21be95907c0ce8cebeb2d47456a291778 /os-plugins/plugins/qemukvm
parentxen nfs boot, xen boot (diff)
downloadcore-5dd09617cd77f2a616c770152c4cd8319803a05f.tar.gz
core-5dd09617cd77f2a616c770152c4cd8319803a05f.tar.xz
core-5dd09617cd77f2a616c770152c4cd8319803a05f.zip
qemu tap coniguration hell
Diffstat (limited to 'os-plugins/plugins/qemukvm')
-rw-r--r--os-plugins/plugins/qemukvm/OpenSLX/OSPlugin/qemukvm.pm35
-rw-r--r--os-plugins/plugins/qemukvm/files/ifup47
-rw-r--r--os-plugins/plugins/qemukvm/files/run-virt.include34
-rwxr-xr-xos-plugins/plugins/qemukvm/init-hooks/60-have-servconfig/vm-dhcpd.sh10
4 files changed, 75 insertions, 51 deletions
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.*\\\<svm\\\> /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