ia64/xen-unstable

view tools/examples/block-common.sh @ 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 98fd1359eecd
children e2e7f47e6f79
line source
1 #
2 # Copyright (c) 2005 XenSource Ltd.
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of version 2.1 of the GNU Lesser General Public
6 # License as published by the Free Software Foundation.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 #
19 dir=$(dirname "$0")
20 . "$dir/xen-hotplug-common.sh"
22 command="$1"
24 if [ "$command" != "bind" ] && [ "$command" != "unbind" ]
25 then
26 log err "Invalid command: $command"
27 exit 1
28 fi
31 XENBUS_PATH="${XENBUS_PATH:?}"
34 ##
35 # Write physical-device = 0xMMmm and node = device to the store, where MM
36 # and mm are the major and minor numbers of device.
37 #
38 # @param device The device from which major and minor numbers are read, which
39 # will be written into the store.
40 #
41 write_dev() {
42 local major
43 local minor
44 local pdev
46 major=$(stat -L -c %t "$1")
47 minor=$(stat -L -c %T "$1")
49 if [ -z $major -o -z $minor ]; then
50 fatal "Backend device does not exist"
51 fi
53 pdev=$(printf "0x%02x%02x" "0x$major" "0x$minor")
54 xenstore_write "$XENBUS_PATH"/physical-device "$pdev" \
55 "$XENBUS_PATH"/node "$1"
57 success
58 }