summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDirk2011-07-12 18:20:33 +0200
committerDirk2011-07-12 18:20:33 +0200
commit4802a95195614a238c80bbdaf9b51535049b8572 (patch)
tree4bda9b03eefe4a919576d85d723830726832da62 /src
parentCleanup ... (diff)
downloadcore-4802a95195614a238c80bbdaf9b51535049b8572.tar.gz
core-4802a95195614a238c80bbdaf9b51535049b8572.tar.xz
core-4802a95195614a238c80bbdaf9b51535049b8572.zip
More virt/emu stuff ...
Diffstat (limited to 'src')
-rw-r--r--src/os-plugins/plugins/qemukvm/XX_qemukvm.sh4
-rw-r--r--src/os-plugins/plugins/qemukvm/files/ifdown16
-rw-r--r--src/os-plugins/plugins/qemukvm/files/ifup23
3 files changed, 21 insertions, 22 deletions
diff --git a/src/os-plugins/plugins/qemukvm/XX_qemukvm.sh b/src/os-plugins/plugins/qemukvm/XX_qemukvm.sh
index a239d034..3f952241 100644
--- a/src/os-plugins/plugins/qemukvm/XX_qemukvm.sh
+++ b/src/os-plugins/plugins/qemukvm/XX_qemukvm.sh
@@ -103,9 +103,9 @@ ALL ALL=NOPASSWD: /opt/openslx/rootfs/usr/sbin/brctl addif br0 tap*
ALL ALL=NOPASSWD: /opt/openslx/rootfs/bin/ip link set dev tap* *
ALL ALL=NOPASSWD: /opt/openslx/rootfs/bin/ip addr add * dev tap*
ALL ALL=NOPASSWD: /opt/openslx/rootfs/usr/sbin/udhcpd -S /tmp/qemukvm/*/udhcpd.conf
-ALL ALL=NOPASSWD: /opt/openslx/rootfs/bin/cp /tmp/qemukvm/*/forwarding /proc/sys/net/ipv4/conf/tap*/forwarding
-ALL ALL=NOPASSWD: /opt/openslx/rootfs/bin/cp /tmp/qemukvm/*/forwarding /proc/sys/net/ipv4/conf/br*/forwarding
+ALL ALL=NOPASSWD: /sbin/sysctl -q -w net.ipv4.conf.*.forwarding=?
ALL ALL=NOPASSWD: /opt/openslx/rootfs/usr/bin/killall -9 udhcpd
+ALL ALL=NOPASSWD: /sbin/iptables -t nat -? POSTROUTING -s 192.168.1*.0/24 -o br0 -j MASQUERADE
EOF
fi
else
diff --git a/src/os-plugins/plugins/qemukvm/files/ifdown b/src/os-plugins/plugins/qemukvm/files/ifdown
index f740cd42..b56be1df 100644
--- a/src/os-plugins/plugins/qemukvm/files/ifdown
+++ b/src/os-plugins/plugins/qemukvm/files/ifdown
@@ -14,11 +14,21 @@
# -----------------------------------------------------------------------------
# get VM_ID through tap name
-#VM_ID=$(echo $1 | grep -oE "0[0-4]$")
+VM_ID=$(echo $1 | grep -oE "0[0-4]$")
#QKTMPDIR=/tmp/qemukvm/${USER}/${VM_ID}
# not optimal if multiple machines run
-sudo /opt/openslx/rootfs/usr/bin/killall -9 udhcpd || exit 0
-sudo /opt/openslx/rootfs/bin/ip link set dev $1 down || exit 0
+case "$1" in
+ tapbridge0*)
+ sudo /sbin/sysctl -q -w net.ipv4.conf.$1.forwarding=0 || failed=1
+ ;;
+ tapnat0*)
+ sudo /sbin/sysctl -q -w net.ipv4.conf.$1.forwarding=0 || failed=1
+ sudo /sbin/iptables -t nat -D POSTROUTING -s 192.168.1${VM_ID}.0/24 -o br0 \
+ -j MASQUERADE || failed=1
+ ;;
+esac
+sudo /opt/openslx/rootfs/usr/bin/killall -9 udhcpd || failed=1
+sudo /opt/openslx/rootfs/bin/ip link set dev $1 down || failed=1
# Produce a clean exit status
exit 0
diff --git a/src/os-plugins/plugins/qemukvm/files/ifup b/src/os-plugins/plugins/qemukvm/files/ifup
index 2052903d..d061fe0b 100644
--- a/src/os-plugins/plugins/qemukvm/files/ifup
+++ b/src/os-plugins/plugins/qemukvm/files/ifup
@@ -32,10 +32,8 @@ case "$1" in
sudo /opt/openslx/rootfs/bin/ip link set dev $1 up
# TODO: forwarding?, where needed
echo "1" >${QKTMPDIR}/forwarding
- sudo /opt/openslx/rootfs/bin/cp ${QKTMPDIR}/forwarding \
- /proc/sys/net/ipv4/conf/br0/forwarding
- sudo /opt/openslx/rootfs/bin/cp ${QKTMPDIR}/forwarding \
- /proc/sys/net/ipv4/conf/$1/forwarding
+ sudo /sbin/sysctl -q -w net.ipv4.conf.br0.forwarding=1
+ sudo /sbin/sysctl -q -w net.ipv4.conf.$1.forwarding=1
;;
tapnat0*)
# Configuring DHCP on host tapnat interface and enable IP masquerading
@@ -43,12 +41,9 @@ case "$1" in
sudo /opt/openslx/rootfs/bin/ip addr add 192.168.1${VM_ID}.1/24 dev $1
sudo /opt/openslx/rootfs/bin/ip link set dev $1 up
# TODO: forwarding?, where needed
- echo "1" >${QKTMPDIR}/forwarding
- sudo /opt/openslx/rootfs/bin/cp ${QKTMPDIR}/forwarding \
- /proc/sys/net/ipv4/conf/br0/forwarding
- sudo /opt/openslx/rootfs/bin/cp ${QKTMPDIR}/forwarding \
- /proc/sys/net/ipv4/conf/$1/forwarding
- # TODO: we use here atatic address, maybe change later
+ sudo /sbin/sysctl -q -w net.ipv4.conf.br0.forwarding=1
+ sudo /sbin/sysctl -q -w net.ipv4.conf.$1.forwarding=1
+ # TODO: we use here static address, maybe change later
sed -e "s,NWIF,$1,;s,CNETWORK,192.168.1${VM_ID}," \
-e "s,PIDFILE,${QKTMPDIR}/udhcpd.pid," \
-e "s,LEASEFILE,${QKTMPDIR}/udhcpd.leases," \
@@ -57,19 +52,13 @@ case "$1" in
touch ${QKTMPDIR}/udhcpd.leases
sudo /opt/openslx/rootfs/usr/sbin/udhcpd \
-S ${QKTMPDIR}/udhcpd.conf
- # iptables -t nat -A POSTROUTING -o br0 -j MASQUERADE
+ sudo /sbin/iptables -t nat -A POSTROUTING -s 192.168.1${VM_ID}.0/24 -o br0 -j MASQUERADE
;;
taphost0*)
# Configuring DHCP on host taphost interface
# Fixme: sudo /opt/openslx/rootfs/bin/ip addr add ${hoaddress} dev $1
sudo /opt/openslx/rootfs/bin/ip addr add 192.168.1${VM_ID}.1/24 dev $1
sudo /opt/openslx/rootfs/bin/ip link set dev $1 up
- # TODO: forwarding?, where needed
- echo "1" >${QKTMPDIR}/forwarding
- sudo /opt/openslx/rootfs/bin/cp ${QKTMPDIR}/forwarding \
- /proc/sys/net/ipv4/conf/br0/forwarding
- sudo /opt/openslx/rootfs/bin/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," \