#!/bin/bash #============================================================================ # /etc/xen/scripts/vlan-bridge # # Script for configuring a vif in bridged mode, supporting vlans. # The hotplugging system will call this script if it is specified either in # the device configuration given to Xend, or the default Xend configuration # in /etc/xen/xend-config.sxp. # # Usage: # vlan-bridge (add|remove|online|offline) # # Environment vars: # vif vif interface name (required). # XENBUS_PATH path to this device's details in the XenStore (required). # # Read from the store: # bridge bridge to add the vif to (optional). Defaults to searching for the # bridge itself. # ip list of IP networks for the vif, space-separated (optional). # # up: # Adds a vlan if required, then a bridge with the real network interface, # migrating the IP address. Then adds the vif to the bridge. # # down: # Removes the vif interface from the bridge. Removes the bridge # and migrates the IP address back to the real interface, if bridge is # otherwise empty. # # warning: If the real network interface is a bond device, adding # a new vlan may cause the current active slave interface to become # disabled. Try stopping haldaemon and/or avahi-daemon. #============================================================================ PATH=/usr/bin:/bin:/usr/sbin:/sbin dir=$(dirname "$0") . "$dir/vif-common.sh" . "$dir/xen-network-common.sh" . "$dir/vlan-bridge-common.sh" set +e export LANG=C LC_ALL=C bridge=$(xenstore_read_default "$XENBUS_PATH/bridge" "$bridge") if [ -z "$bridge" ]; then bridge=$(brctl show | awk 'FNR == 2 { print $1 }') [ -n "$bridge" ] || fatal "Could not find bridge, and none was specified" fi bridge="${bridge//[^0-9]/}" case "$command" in online) vlanadd $bridge $vif ;; offline) vlandel $bridge $vif ;; esac log debug "Successful vif-bridge $command for $vif, bridge $bridge." if [ "$command" == "online" ] then success fi