WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Added error logging to the block hotplug script, and sup

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Added error logging to the block hotplug script, and support facilities for
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 10 Oct 2005 14:02:11 +0000
Delivery-date: Mon, 10 Oct 2005 13:59:42 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# 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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Added error logging to the block hotplug script, and support facilities for, Xen patchbot -unstable <=