[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Added error logging to the block hotplug script, and support facilities for



# HG changeset patch
# User emellor@ewan
# Node ID 0e7c48861e95b738fdf96d4a4df6b0ba90a8423d
# Parent  fe4c1d44e8994794fa7377546061a2c37558f79a
Added error logging to the block hotplug script, and support facilities for
that.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

diff -r fe4c1d44e899 -r 0e7c48861e95 tools/examples/Makefile
--- a/tools/examples/Makefile   Sun Oct  9 11:20:12 2005
+++ b/tools/examples/Makefile   Mon Oct 10 13:42:38 2005
@@ -24,6 +24,7 @@
 XEN_SCRIPTS += network-nat vif-nat
 XEN_SCRIPTS += block
 XEN_SCRIPTS += block-enbd
+XEN_SCRIPTS += xen-hotplug-common.sh
 
 XEN_HOTPLUG_DIR = /etc/hotplug
 XEN_HOTPLUG_SCRIPTS = xen-backend.agent
diff -r fe4c1d44e899 -r 0e7c48861e95 tools/examples/block
--- a/tools/examples/block      Sun Oct  9 11:20:12 2005
+++ b/tools/examples/block      Mon Oct 10 13:42:38 2005
@@ -1,8 +1,7 @@
 #!/bin/sh
 
-set -e
-
-export PATH=/sbin:/bin:/usr/bin:/usr/sbin:$PATH
+dir=$(dirname "$0")
+. "$dir/xen-hotplug-common.sh"
 
 expand_dev() {
   local dev
@@ -25,15 +24,15 @@
   major=$(stat -L -c %t "$1")
   minor=$(stat -L -c %T "$1")
   pdev=$(printf "0x%02x%02x" 0x$major 0x$minor)
-  xenstore-write "$XENBUS_PATH"/physical-device $pdev \
+  xenstore_write "$XENBUS_PATH"/physical-device $pdev \
       "$XENBUS_PATH"/node $1
 }
 
-t=$(xenstore-read "$XENBUS_PATH"/type)
+t=$(xenstore_read "$XENBUS_PATH"/type || true)
 
 case $1 in 
   bind)
-    p=$(xenstore-read "$XENBUS_PATH"/params)
+    p=$(xenstore_read "$XENBUS_PATH"/params)
     case $t in 
       phy)
         dev=$(expand_dev $p)
@@ -60,7 +59,7 @@
     ;;
 
   unbind)
-    node=$(xenstore-read "$XENBUS_PATH"/node)
+    node=$(xenstore_read "$XENBUS_PATH"/node)
     case $t in 
       phy)
        exit 0
diff -r fe4c1d44e899 -r 0e7c48861e95 tools/examples/xen-hotplug-common.sh
--- /dev/null   Sun Oct  9 11:20:12 2005
+++ b/tools/examples/xen-hotplug-common.sh      Mon Oct 10 13:42:38 2005
@@ -0,0 +1,26 @@
+set -e
+
+export PATH=/sbin:/bin:/usr/bin:/usr/sbin:$PATH
+
+log() {
+  local level="$1"
+  shift
+  logger -p "daemon.$level" -- "$0:" "$@" || echo "$0 $@" >&2
+}
+
+xenstore_read() {
+  local v=$(xenstore-read "$XENBUS_PATH"/type || true)
+  if [ "$v" == "" ]
+  then
+    log error "xenstore-read $XENBUS_PATH/type failed."
+    exit 1
+  fi
+  echo "$v"
+}
+
+xenstore_write() {
+  log debug "Writing $@ to xenstore."
+  xenstore-write "$@" || log error "Writing $@ to xenstore failed."
+}
+
+log debug "$@" "XENBUS_PATH=$XENBUS_PATH"

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.