reviewed list options parsing
[tests.git] / system / template-qemu / qemu-bridge-init
index 5c03280..cf21f81 100755 (executable)
@@ -1,5 +1,8 @@
 #!/bin/bash
 
+# Thierry Parmentelat <thierry.parmentelat@inria.fr>
+# Copyright (C) 2010 INRIA 
+#
 # Establishment of a runtime environment for a
 # virtual  machine  under QEMU, This script allows the host box
 # to share its network connection with qemu-based guests
@@ -21,6 +24,13 @@ INTERFACE_LAN=eth0
 # Fonction de mise en place du pont
 start () {
 
+    echo "========== $COMMAND: entering start - beg"
+    hostname
+    uname -a
+    ifconfig
+    netstat -rn
+    echo "========== $COMMAND: entering start - end"
+
     # take extra arg for ifname, if provided
     [ -n "$1" ] && { INTERFACE_LAN=$1; shift ; }
 
@@ -29,7 +39,7 @@ start () {
 
     #if we have already configured the same host_box no need to do it again
     /sbin/ifconfig $INTERFACE_BRIDGE &> /dev/null && {
-       echo "Interface bridge $INTERFACE_BRIDGE already exist."
+       echo "Bridge interface $INTERFACE_BRIDGE already set up - $COMMAND start exiting"
        exit 0
     }
     /sbin/ifconfig $INTERFACE_LAN &>/dev/null || {
@@ -52,9 +62,9 @@ start () {
     echo "Starting udev ..."
     /sbin/udevd restart
     if modprobe kqemu &> /dev/null ; then
-       echo "kqemu loadded"
+       echo "(bridge-init) kqemu loaded"
     else
-       echo "WARNING : Could not modprobe kqemu"
+       echo "(bridge-init) WARNING : Could not modprobe kqemu"
     fi
     #Loading the tun/tap model
     if modprobe tun ; then
@@ -84,6 +94,10 @@ start () {
     echo "Configuring gateway=$gateway"
     route add default gw $gateway
 
+    echo "========== $COMMAND: exiting start - beg"
+    ifconfig
+    netstat -rn
+    echo "========== $COMMAND: exiting start - end"
 }
 
 #Adding a new interface to the bridge: this is used by qemu-ifup 
@@ -92,6 +106,11 @@ add () {
     [[ -z "$@" ]] && { echo "Usage: $COMMAND add ifname" ; exit 1 ; }
     INTERFACE_LAN=$1; shift
 
+    echo "========== $COMMAND: entering add - beg"
+    ifconfig
+    netstat -rn
+    echo "========== $COMMAND: entering add - end"
+
     echo "Activating link for $INTERFACE_LAN..."
     /sbin/ip link set $INTERFACE_LAN up
     sleep 1
@@ -111,9 +130,15 @@ add () {
     ./iptables.py iptables.pre iptables.post $IP
     iptables-restore < iptables.post
 
+    echo "========== $COMMAND: exiting add - beg"
+
+    ifconfig
+    netstat -rn
+
     echo "Installed iptables"
     iptables-save
     
+    echo "========== $COMMAND: exiting add - end"
 }
 
 #Stop the bridge and restore the original setting
@@ -125,7 +150,7 @@ stop () {
     type -p brctl &> /dev/null || { echo "brctl not found, please install bridge-utils" ; exit 1 ; }
 
     /sbin/ifconfig $INTERFACE_BRIDGE &> /dev/null || {
-       echo "Interface bridge $INTERFACE_BRIDGE does not exist."
+       echo "Bridge interface $INTERFACE_BRIDGE does not exist - $COMMAND stop exiting"
        exit 0
     }
     brctl delif $INTERFACE_BRIDGE $INTERFACE_LAN