summaryrefslogtreecommitdiff
path: root/packaging/qemu-ifup
blob: f556ec7e5def1c44dde4dc52d02ecba63cc75b61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

echo 'config qemu network with bridge for ' $*

# If bridge is not specified, try device with default route.
bridge=$2
if [ -z "$bridge" ]; then
    bridge=$(ip route list | awk '/^default / { print $NF }')
fi

# Exit if $bridge is not a bridge.  Exit with 0 status
# so qemu-dm process is not terminated.  No networking in
# vm is bad but not catastrophic.  The vm could still run
# cpu and disk IO workloads.
# Include an useful error message in qemu-dm log file.
if [ ! -e "/sys/class/net/${bridge}/bridge" ]
then
   echo "WARNING! ${bridge} is not a bridge.  qemu-ifup exiting.  VM may not have a functioning networking stack."
   exit 0
fi

ifconfig $1 0.0.0.0 up
brctl addif $bridge $1 || true