#!/bin/bash echo -c 'config qemu network with xen bridge for ' echo $* logger -- "$0 $*" # Initialise a dummy MAC address. We choose the numerically # largest non-broadcast address to prevent the address getting # stolen by an Ethernet bridge for STP purposes. # (FE:FF:FF:FF:FF:FF) ip link set $1 address fe:ff:ff:ff:ff:ff || true ifconfig $1 0.0.0.0 up # If the bridge is in format brX.Y, strip Y from the bridge # and use it as VLAN tag. (following code works only in BASH) vif=$1 bridge=$2 if [[ $bridge =~ \.[[:digit:]]{1,4}$ ]]; then tag=$(echo ${bridge} | cut -d "." -f 2) bridge=$(echo ${bridge} | cut -d "." -f 1) fi if [ -z $tag ]; then ovs-vsctl -- --may-exist add-port ${bridge} ${vif} else ovs-vsctl -- --may-exist add-port ${bridge} ${vif} tag=${tag} fi