X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=system%2Ftemplate-qemu%2Fqemu-bridge-init;h=1749d6f38b6ba2c6599d4e34e6c3f6c3b92ffcd2;hb=1e54ec8a2c934652468c089c171f478fb2e8123d;hp=005944e98a30441af76c9d0e3ce8a0f8cbf30ffd;hpb=e13e2b70fbfddfc134d5b1eba989f4ee0ccb67b6;p=tests.git diff --git a/system/template-qemu/qemu-bridge-init b/system/template-qemu/qemu-bridge-init index 005944e..1749d6f 100755 --- a/system/template-qemu/qemu-bridge-init +++ b/system/template-qemu/qemu-bridge-init @@ -7,8 +7,6 @@ # virtual machine under QEMU, This script allows the host box # to share its network connection with qemu-based guests # -# Author: Amine chaoui -# COMMAND=$(basename $0) cd $(dirname $0) @@ -18,11 +16,22 @@ set -x # constant INTERFACE_BRIDGE=br0 -# Default Value -INTERFACE_LAN=eth0 + +# Default Value for INTERFACE_LAN +# let's try to figure out the interface to use - try these in order +IFNAMES="eth0 eth1 eth2 eth3" +function discover_interface () { + for ifname in $IFNAMES; do + ip link show $ifname | grep -q UP && { INTERFACE_LAN=$ifname; return; } + done + # still not found ? that's bad + INTERFACE_LAN=unknown +} +discover_interface +echo $INTERFACE_LAN # Fonction de mise en place du pont -start () { +function start () { echo "========== $COMMAND: entering start - beg" hostname @@ -31,7 +40,13 @@ start () { netstat -rn echo "========== $COMMAND: entering start - end" -# -A FORWARD -m physdev --physdev-is-bridged -j ACCEPT + # disable netfilter calls for bridge interface (they cause panick on 2.6.35 anyway) + # + # another option would be to accept the all forward packages for + # bridged interface like: -A FORWARD -m physdev --physdev-is-bridged -j ACCEPT + sysctl net.bridge.bridge-nf-call-iptables=0 + sysctl net.bridge.bridge-nf-call-ip6tables=0 + sysctl net.bridge.bridge-nf-call-arptables=0 # take extra arg for ifname, if provided [ -n "$1" ] && { INTERFACE_LAN=$1; shift ; } @@ -103,7 +118,7 @@ start () { } #Adding a new interface to the bridge: this is used by qemu-ifup -add () { +function add () { [[ -z "$@" ]] && { echo "Usage: $COMMAND add ifname" ; exit 1 ; } INTERFACE_LAN=$1; shift @@ -144,7 +159,7 @@ add () { } #Stop the bridge and restore the original setting -stop () { +function stop () { # take extra arg for ifname, if provided [ -n "$1" ] && { INTERFACE_LAN=$1; shift ; }