File qemu-ifup of Package qemu


# sample bridge qemu-ifup script

echo 'configuring qemu network with bridge for' $*

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

# 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.
if [ ! -e "/sys/class/net/${bridge}/bridge" ]
   echo "WARNING! ${bridge} is not a bridge.  qemu-ifup exiting.  VM may not have a functioning networking stack."
   exit 0

/sbin/ip link set $1 up
/sbin/brctl addif $bridge $1 || true