This patch modifies xen3's /etc/xen/scripts/vif-bridge so you don't have to worry about where to define new bridges, just refer to them in a domU's config file vif statement, and if the bridge doesn't exist already, it will be added dynamically as the domU is created. Note: This patch doesn't help if you intend to automatically attach any of dom0 virtual ethernet cables (vif0.#<->veth#) to this bridge at boot time, since the bridge will need to be defined before the dom0 vif0.# interface can attached to it. In those cases, what you need to do instead is customize /etc/xen/scripts/network-bridge (or whatever file the (network-script filename) setting in xend-config.sxp points to. This patch only makes it easier if you want to create additional bridges for communciation between multiple domUs, for example HA heartbeat networks, or backend database networks. to apply this patch: - save this file (for example, as ~/dynamic-vif-bridge.patch) don't worry about editing out these comments - change your working directory to where the xen3 scripts are located: cd /etc/xen/scripts - save backup copy of unmodified vif-bridge file: cp vif-bridge vif-bridge.orig - apply patch (check for any errors): patch -p0 < ~/dynamic-vif-bridge.patch *** vif-bridge.orig 2006-02-09 08:19:48.957791999 -0500 --- vif-bridge 2006-02-09 08:24:55.697791999 -0500 *************** *** 20,30 **** # bridge itself. # ip list of IP networks for the vif, space-separated (optional). # ! # up: # Enslaves the vif interface to the bridge and adds iptables rules # for its ip addresses (if any). # ! # down: # Removes the vif interface from the bridge and removes the iptables # rules for its ip addresses (if any). #============================================================================ --- 20,30 ---- # bridge itself. # ip list of IP networks for the vif, space-separated (optional). # ! # online: # Enslaves the vif interface to the bridge and adds iptables rules # for its ip addresses (if any). # ! # offline: # Removes the vif interface from the bridge and removes the iptables # rules for its ip addresses (if any). #============================================================================ *************** *** 35,40 **** --- 35,41 ---- bridge=${bridge:-} bridge=$(xenstore_read_default "$XENBUS_PATH/bridge" "$bridge") + # blindly search for first bridge displayed by brctl show if [ -z "$bridge" ] then bridge=$(brctl show | cut -d " *************** *** 54,59 **** --- 55,70 ---- exit 0 fi + if ! brctl show | grep -q "^$bridge" + then + log debug "dynamically creating bridge $bridge" + brctl addbr $bridge || + fatal "brctl addbr $bridge failed" + brctl setfd $bridge 0 + brctl stp $bridge off + ip link set $bridge up + fi + brctl addif "$bridge" "$vif" || fatal "brctl addif $bridge $vif failed"