ia64/xen-unstable

view tools/examples/vif-bridge @ 7595:286946489e5d

From Murillo Fernandes Bernardes <mfb@br.ibm.com>:

The problem is: There is no mechanism to detect block device setup failure

Network devices have the same problem, and are fixed with this too.

I handling this problem in the way suggested by aliguori:
- hotplug scripts write a "hotplug-status" node on store
- Xend DevController.createDevice() check verify this node and return success
or throw an exception on failure.
- If no changes in "hotplug-status" node after DEVICE_CREATE_TIMEOUT seconds
Xend throw an exception showing the problem with hotplug scripts.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Mon Oct 31 17:10:57 2005 +0100 (2005-10-31)
parents 4722eae11abb
children e2e7f47e6f79
line source
1 #!/bin/sh
2 #============================================================================
3 # /etc/xen/vif-bridge
4 #
5 # Script for configuring a vif in bridged mode.
6 # The hotplugging system will call this script if it is specified either in
7 # the device configuration given to Xend, or the default Xend configuration
8 # in /etc/xen/xend-config.sxp. If the script is specified in neither of those
9 # places, then this script is the default.
10 #
11 # Usage:
12 # vif-bridge (up|down)
13 #
14 # Environment vars:
15 # vif vif interface name (required).
16 # XENBUS_PATH path to this device's details in the XenStore (required).
17 #
18 # Read from the store:
19 # bridge bridge to add the vif to (optional). Defaults to searching for the
20 # bridge itself.
21 # ip list of IP networks for the vif, space-separated (optional).
22 #
23 # up:
24 # Enslaves the vif interface to the bridge and adds iptables rules
25 # for its ip addresses (if any).
26 #
27 # down:
28 # Removes the vif interface from the bridge and removes the iptables
29 # rules for its ip addresses (if any).
30 #============================================================================
32 dir=$(dirname "$0")
33 . "$dir/vif-common.sh"
35 bridge=${bridge:-}
36 bridge=$(xenstore_read_default "$XENBUS_PATH/bridge" "$bridge")
38 if [ -z "$bridge" ]
39 then
40 bridge=$(brctl show | cut -d "
41 " -f 2 | cut -f 1)
43 if [ -z "$bridge" ]
44 then
45 fatal "Could not find bridge, and none was specified"
46 fi
47 fi
49 case "$command" in
50 up)
51 if brctl show "$bridge" | grep "$vif" >&/dev/null
52 then
53 log debug "$vif already attached to $bridge"
54 exit 0
55 fi
57 brctl addif "$bridge" "$vif" ||
58 fatal "brctl addif $bridge $vif failed"
60 ifconfig "$vif" up || fatal "ifconfig $vif up failed"
61 success
62 ;;
63 down)
64 # vifs are auto-removed from bridge.
65 ifconfig "$vif" down || fatal "ifconfig $vif down failed"
66 ;;
67 esac
69 handle_iptable
71 log debug "Successful vif-bridge operation for $vif, bridge $bridge."