direct-io.hg
changeset 7283:0e7c48861e95
Added error logging to the block hotplug script, and support facilities for
that.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
that.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
author | emellor@ewan |
---|---|
date | Mon Oct 10 14:42:38 2005 +0100 (2005-10-10) |
parents | fe4c1d44e899 |
children | 1ac39c7a0435 |
files | tools/examples/Makefile tools/examples/block tools/examples/xen-hotplug-common.sh |
line diff
1.1 --- a/tools/examples/Makefile Sun Oct 09 12:20:12 2005 +0100 1.2 +++ b/tools/examples/Makefile Mon Oct 10 14:42:38 2005 +0100 1.3 @@ -24,6 +24,7 @@ XEN_SCRIPTS += network-route vif-route 1.4 XEN_SCRIPTS += network-nat vif-nat 1.5 XEN_SCRIPTS += block 1.6 XEN_SCRIPTS += block-enbd 1.7 +XEN_SCRIPTS += xen-hotplug-common.sh 1.8 1.9 XEN_HOTPLUG_DIR = /etc/hotplug 1.10 XEN_HOTPLUG_SCRIPTS = xen-backend.agent
2.1 --- a/tools/examples/block Sun Oct 09 12:20:12 2005 +0100 2.2 +++ b/tools/examples/block Mon Oct 10 14:42:38 2005 +0100 2.3 @@ -1,8 +1,7 @@ 2.4 #!/bin/sh 2.5 2.6 -set -e 2.7 - 2.8 -export PATH=/sbin:/bin:/usr/bin:/usr/sbin:$PATH 2.9 +dir=$(dirname "$0") 2.10 +. "$dir/xen-hotplug-common.sh" 2.11 2.12 expand_dev() { 2.13 local dev 2.14 @@ -25,15 +24,15 @@ write_dev() { 2.15 major=$(stat -L -c %t "$1") 2.16 minor=$(stat -L -c %T "$1") 2.17 pdev=$(printf "0x%02x%02x" 0x$major 0x$minor) 2.18 - xenstore-write "$XENBUS_PATH"/physical-device $pdev \ 2.19 + xenstore_write "$XENBUS_PATH"/physical-device $pdev \ 2.20 "$XENBUS_PATH"/node $1 2.21 } 2.22 2.23 -t=$(xenstore-read "$XENBUS_PATH"/type) 2.24 +t=$(xenstore_read "$XENBUS_PATH"/type || true) 2.25 2.26 case $1 in 2.27 bind) 2.28 - p=$(xenstore-read "$XENBUS_PATH"/params) 2.29 + p=$(xenstore_read "$XENBUS_PATH"/params) 2.30 case $t in 2.31 phy) 2.32 dev=$(expand_dev $p) 2.33 @@ -60,7 +59,7 @@ case $1 in 2.34 ;; 2.35 2.36 unbind) 2.37 - node=$(xenstore-read "$XENBUS_PATH"/node) 2.38 + node=$(xenstore_read "$XENBUS_PATH"/node) 2.39 case $t in 2.40 phy) 2.41 exit 0
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/tools/examples/xen-hotplug-common.sh Mon Oct 10 14:42:38 2005 +0100 3.3 @@ -0,0 +1,26 @@ 3.4 +set -e 3.5 + 3.6 +export PATH=/sbin:/bin:/usr/bin:/usr/sbin:$PATH 3.7 + 3.8 +log() { 3.9 + local level="$1" 3.10 + shift 3.11 + logger -p "daemon.$level" -- "$0:" "$@" || echo "$0 $@" >&2 3.12 +} 3.13 + 3.14 +xenstore_read() { 3.15 + local v=$(xenstore-read "$XENBUS_PATH"/type || true) 3.16 + if [ "$v" == "" ] 3.17 + then 3.18 + log error "xenstore-read $XENBUS_PATH/type failed." 3.19 + exit 1 3.20 + fi 3.21 + echo "$v" 3.22 +} 3.23 + 3.24 +xenstore_write() { 3.25 + log debug "Writing $@ to xenstore." 3.26 + xenstore-write "$@" || log error "Writing $@ to xenstore failed." 3.27 +} 3.28 + 3.29 +log debug "$@" "XENBUS_PATH=$XENBUS_PATH"