2014-02-13 14:36:37 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2017-03-15 20:38:55 +01:00
|
|
|
# sample bridge qemu-ifup script
|
|
|
|
|
|
|
|
echo 'configuring qemu network with bridge for' $*
|
2014-02-13 14:36:37 +01:00
|
|
|
|
|
|
|
# If bridge is not specified, try device with default route.
|
|
|
|
bridge=$2
|
|
|
|
if [ -z "$bridge" ]; then
|
2018-03-02 18:01:56 +01:00
|
|
|
bridge=$(/usr/sbin/ip route list | /usr/bin/awk '/^default / { print $5 }')
|
2014-02-13 14:36:37 +01:00
|
|
|
fi
|
|
|
|
|
2017-03-15 20:38:55 +01:00
|
|
|
# Exit if $bridge is not a bridge. Exit with 0 status
|
|
|
|
# so qemu process is not terminated and provide message
|
|
|
|
# about failure to setup network.
|
2014-02-13 14:36:37 +01:00
|
|
|
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
|
|
|
|
|
2018-03-02 18:01:56 +01:00
|
|
|
/usr/sbin/ip link set $1 up
|
|
|
|
/usr/sbin/ip link set $1 master $bridge || true
|