git://git.onelab.eu
/
tests.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use systemctl instead of service
[tests.git]
/
system
/
template-qemu
/
qemu-bridge-init
diff --git
a/system/template-qemu/qemu-bridge-init
b/system/template-qemu/qemu-bridge-init
index
399907c
..
ff4198c
100755
(executable)
--- a/
system/template-qemu/qemu-bridge-init
+++ b/
system/template-qemu/qemu-bridge-init
@@
-1,7
+1,7
@@
#!/bin/bash
# Thierry Parmentelat <thierry.parmentelat@inria.fr>
#!/bin/bash
# Thierry Parmentelat <thierry.parmentelat@inria.fr>
-# Copyright (C) 2010 INRIA
+# Copyright (C) 2010 INRIA
#
# Establishment of a runtime environment for a
# virtual machine under QEMU, This script allows the host box
#
# Establishment of a runtime environment for a
# virtual machine under QEMU, This script allows the host box
@@
-17,7
+17,7
@@
set -x
# constant
INTERFACE_BRIDGE=br0
# constant
INTERFACE_BRIDGE=br0
-#
Default Value for
INTERFACE_LAN
+#
################### compute
INTERFACE_LAN
# use /proc/net/dev instead of a hard-wired list
function gather_interfaces () {
python <<EOF
# use /proc/net/dev instead of a hard-wired list
function gather_interfaces () {
python <<EOF
@@
-25,31
+25,32
@@
for line in file("/proc/net/dev"):
if ':' not in line: continue
ifname=line.replace(" ","").split(":")[0]
if ifname.find("lo")==0: continue
if ':' not in line: continue
ifname=line.replace(" ","").split(":")[0]
if ifname.find("lo")==0: continue
+ if ifname.find("br")==0: continue
if ifname.find("virbr")==0: continue
if ifname.find("tap")==0: continue
print ifname
EOF
}
if ifname.find("virbr")==0: continue
if ifname.find("tap")==0: continue
print ifname
EOF
}
-
-# let's try to figure out the interface to use - try these in order
+
function discover_interface () {
for ifname in $(gather_interfaces); do
function discover_interface () {
for ifname in $(gather_interfaces); do
- ip link show $ifname | grep -qi 'state UP' && {
INTERFACE_LAN=
$ifname; return; }
+ ip link show $ifname | grep -qi 'state UP' && {
echo
$ifname; return; }
done
# still not found ? that's bad
done
# still not found ? that's bad
-
INTERFACE_LAN=
unknown
+
echo
unknown
}
}
-discover_interface
-echo $INTERFACE_LAN
+INTERFACE_LAN=$(discover_interface)
+echo
Using physical interface
$INTERFACE_LAN
+####################
# Fonction de mise en place du pont
function start () {
echo "========== $COMMAND: entering start - beg"
hostname
uname -a
# Fonction de mise en place du pont
function start () {
echo "========== $COMMAND: entering start - beg"
hostname
uname -a
- i
fconfig
- netstat -rn
+ i
p address show
+ ip route show
echo "========== $COMMAND: entering start - end"
# disable netfilter calls for bridge interface (they cause panick on 2.6.35 anyway)
echo "========== $COMMAND: entering start - end"
# disable netfilter calls for bridge interface (they cause panick on 2.6.35 anyway)
@@
-67,34
+68,34
@@
function start () {
type -p brctl &> /dev/null || { echo "brctl not found, please install bridge-utils" ; exit 1 ; }
#if we have already configured the same host_box no need to do it again
type -p brctl &> /dev/null || { echo "brctl not found, please install bridge-utils" ; exit 1 ; }
#if we have already configured the same host_box no need to do it again
-
/sbin/ifconfig
$INTERFACE_BRIDGE &> /dev/null && {
+
ip address show
$INTERFACE_BRIDGE &> /dev/null && {
echo "Bridge interface $INTERFACE_BRIDGE already set up - $COMMAND start exiting"
exit 0
}
echo "Bridge interface $INTERFACE_BRIDGE already set up - $COMMAND start exiting"
exit 0
}
-
/sbin/ifconfig $INTERFACE_LAN &>
/dev/null || {
+
ip address show $INTERFACE_LAN &>
/dev/null || {
echo "Cannot use interface $INTERFACE_LAN - exiting"
exit 1
}
#Getting host IP/masklen
echo "Cannot use interface $INTERFACE_LAN - exiting"
exit 1
}
#Getting host IP/masklen
- address=$(/sbin/ip addr show $INTERFACE_LAN | grep -v inet6 | grep inet | head --lines=1 | awk '{print $2;}')
+ address=$(/sbin/ip addr
ess
show $INTERFACE_LAN | grep -v inet6 | grep inet | head --lines=1 | awk '{print $2;}')
[ -z "$address" ] && { echo "ERROR: Could not determine IP address for $INTERFACE_LAN" ; exit 1 ; }
[ -z "$address" ] && { echo "ERROR: Could not determine IP address for $INTERFACE_LAN" ; exit 1 ; }
-
- broadcast=$(/sbin/ip addr show $INTERFACE_LAN | grep -v inet6 | grep inet | head --lines=1 | awk '{print $4;}')
+
+ broadcast=$(/sbin/ip addr
ess
show $INTERFACE_LAN | grep -v inet6 | grep inet | head --lines=1 | awk '{print $4;}')
[ -z "$broadcast" ] && echo "WARNING: Could not determine broadcast address for $INTERFACE_LAN"
[ -z "$broadcast" ] && echo "WARNING: Could not determine broadcast address for $INTERFACE_LAN"
- gateway=$(
netstat -rn | grep '^0.0.0.0' | awk '{print $2
;}')
+ gateway=$(
ip route show | grep default | awk '{print $3
;}')
[ -z "$gateway" ] && echo "WARNING: Could not determine gateway IP"
### do it
#Restarting udev
[ -z "$gateway" ] && echo "WARNING: Could not determine gateway IP"
### do it
#Restarting udev
- echo "Starting udev ..."
- /sbin/udevd restart
- if modprobe kqemu &> /dev/null ; then
- echo "(bridge-init) kqemu loaded"
- else
-
echo "(bridge-init) WARNING : Could not modprobe kqemu"
- fi
+
#
echo "Starting udev ..."
+
#
/sbin/udevd restart
+
#
if modprobe kqemu &> /dev/null ; then
+
#
echo "(bridge-init) kqemu loaded"
+
#
else
+
#
echo "(bridge-init) WARNING : Could not modprobe kqemu"
+
#
fi
#Loading the tun/tap model
if modprobe tun ; then
echo "tun loaded"
#Loading the tun/tap model
if modprobe tun ; then
echo "tun loaded"
@@
-112,32
+113,35
@@
function start () {
#brctl stp $INTERFACE_BRIDGE yes
brctl addif $INTERFACE_BRIDGE $INTERFACE_LAN
echo "Activating promiscuous mode INTERFACE_LAN=$INTERFACE_LAN"
#brctl stp $INTERFACE_BRIDGE yes
brctl addif $INTERFACE_BRIDGE $INTERFACE_LAN
echo "Activating promiscuous mode INTERFACE_LAN=$INTERFACE_LAN"
- /sbin/ifconfig $INTERFACE_LAN 0.0.0.0 promisc up
+ ip link set dev $INTERFACE_LAN promisc on
sleep 2
echo "Setting bridge address=$address broadcast=$broadcast"
# static
sleep 2
echo "Setting bridge address=$address broadcast=$broadcast"
# static
- /sbin/ifconfig $INTERFACE_BRIDGE $address broadcast $broadcast up
+ ip address add $address broadcast $broadcast dev $INTERFACE_BRIDGE
+ # turn on bridge interface
+ ip link set dev $INTERFACE_BRIDGE up
+ ip address del $address dev $INTERFACE_LAN
sleep 1
sleep 1
-
+
#Reconfigure the routing table
#Reconfigure the routing table
- echo "
Configuring gateway=$gateway
"
- route add default gw $gateway
+ echo "
Adding default route via gateway=$gateway on dev $INTERFACE_LAN
"
+ ip route add 0.0.0.0/0 via $gateway dev $INTERFACE_BRIDGE
echo "========== $COMMAND: exiting start - beg"
echo "========== $COMMAND: exiting start - beg"
- i
fconfig
- netstat -rn
+ i
p address show
+ ip route show
echo "========== $COMMAND: exiting start - end"
}
echo "========== $COMMAND: exiting start - end"
}
-#Adding a new interface to the bridge: this is used by qemu-ifup
+#Adding a new interface to the bridge: this is used by qemu-ifup
function add () {
[[ -z "$@" ]] && { echo "Usage: $COMMAND add ifname" ; exit 1 ; }
INTERFACE_LAN=$1; shift
echo "========== $COMMAND: entering add - beg"
function add () {
[[ -z "$@" ]] && { echo "Usage: $COMMAND add ifname" ; exit 1 ; }
INTERFACE_LAN=$1; shift
echo "========== $COMMAND: entering add - beg"
- i
fconfig
- netstat -rn
+ i
p address show
+ ip route show
echo "========== $COMMAND: entering add - end"
echo "Activating link for $INTERFACE_LAN..."
echo "========== $COMMAND: entering add - end"
echo "Activating link for $INTERFACE_LAN..."
@@
-161,12
+165,12
@@
function add () {
echo "========== $COMMAND: exiting add - beg"
echo "========== $COMMAND: exiting add - beg"
- i
fconfig
- netstat -rn
+ i
p address show
+ ip route show
echo "Installed iptables"
iptables-save
echo "Installed iptables"
iptables-save
-
+
echo "========== $COMMAND: exiting add - end"
}
echo "========== $COMMAND: exiting add - end"
}
@@
-178,15
+182,15
@@
function stop () {
### Checking
type -p brctl &> /dev/null || { echo "brctl not found, please install bridge-utils" ; exit 1 ; }
### Checking
type -p brctl &> /dev/null || { echo "brctl not found, please install bridge-utils" ; exit 1 ; }
-
/sbin/ifconfig
$INTERFACE_BRIDGE &> /dev/null || {
+
ip address show
$INTERFACE_BRIDGE &> /dev/null || {
echo "Bridge interface $INTERFACE_BRIDGE does not exist - $COMMAND stop exiting"
exit 0
}
echo "Bridge interface $INTERFACE_BRIDGE does not exist - $COMMAND stop exiting"
exit 0
}
+ address=$(/sbin/ip address show $INTERFACE_BRIDGE | grep -v inet6 | grep inet | head --lines=1 | awk '{print $2;}')
brctl delif $INTERFACE_BRIDGE $INTERFACE_LAN
brctl delif $INTERFACE_BRIDGE $INTERFACE_LAN
- /sbin/ifconfig $INTERFACE_BRIDGE down
+ ip address del $address dev $INTERFACE_BRIDGE
brctl delbr $INTERFACE_BRIDGE
brctl delbr $INTERFACE_BRIDGE
- /sbin/service network restart
- /sbin/service iptables restart
+ systemctl NetworkManager restart
}
function main () {
}
function main () {