ia64/xen-unstable

view tools/examples/xen-backend.agent @ 7238:971e7c7411b3

Raise an exception if an error appears on the pipes to our children, and make
sure that the child's pipes are closed even under that exception. Move the
handling of POLLHUP to the end of the loop, so that we guarantee to read any
remaining data from the child if POLLHUP and POLLIN appear at the same time.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@ewan
date Thu Oct 06 10:13:11 2005 +0100 (2005-10-06)
parents 06d84bf87159
children 1b0dbfedc043
line source
1 #! /bin/sh
3 #ACTION=add
4 #DEVPATH=/devices/xen-backend/vif-1-0
5 #PHYSDEVDRIVER=vif
6 #XENBUS_TYPE=vif
8 PATH=/etc/xen/scripts:$PATH
10 case "$ACTION" in
11 add)
12 case "$XENBUS_TYPE" in
13 vbd)
14 t=$(xenstore-read "$XENBUS_PATH"/type)
15 params=$(xenstore-read "$XENBUS_PATH"/params)
16 [ -x /etc/xen/scripts/block-"$t" ] && \
17 /etc/xen/scripts/block-"$t" bind $params
18 ;;
19 esac
20 ;;
21 remove)
22 case "$XENBUS_TYPE" in
23 vbd)
24 t=$(xenstore-read "$XENBUS_PATH"/type)
25 node=$(xenstore-read "$XENBUS_PATH"/node)
26 [ -x /etc/xen/scripts/block-"$t" ] && \
27 /etc/xen/scripts/block-"$t" unbind $node
28 ;;
29 esac
30 # remove device backend store entries
31 xenstore-rm "$XENBUS_PATH"
32 ;;
33 online)
34 case "$PHYSDEVDRIVER" in
35 vif)
36 [ -n "$script" ] && $script up
37 ;;
38 esac
39 ;;
40 offline)
41 ;;
42 esac