aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authoremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>2006-02-27 17:16:04 +0100
committeremellor@leeni.uk.xensource.com <emellor@leeni.uk.xensource.com>2006-02-27 17:16:04 +0100
commitf32e156c0e2405de3ec89e8f3bbf66b1e4a8254c (patch)
tree85f51f0e1bab15675b0eaf425334d0ffdc84e7ab /tools
parent1b2fcd85a00f328a5f71aacd7d99e1085440617b (diff)
downloadxen-f32e156c0e2405de3ec89e8f3bbf66b1e4a8254c.tar.gz
xen-f32e156c0e2405de3ec89e8f3bbf66b1e4a8254c.tar.bz2
xen-f32e156c0e2405de3ec89e8f3bbf66b1e4a8254c.zip
Break out the hotplug cleanup code into xen-hotplug-cleanup. Claim the block
script's lock before doing the cleanup, to avoid a race that causes the message "xenstore-list: could not list path backend/vbd/40" in /var/log/hotplug.log, with a subsequent refusal to create the domain, after a domain reboot. Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/examples/Makefile1
-rwxr-xr-xtools/examples/xen-backend.agent2
-rw-r--r--tools/examples/xen-backend.rules4
-rw-r--r--tools/examples/xen-hotplug-cleanup21
4 files changed, 24 insertions, 4 deletions
diff --git a/tools/examples/Makefile b/tools/examples/Makefile
index 8ffd794972..6e71f563bf 100644
--- a/tools/examples/Makefile
+++ b/tools/examples/Makefile
@@ -27,6 +27,7 @@ XEN_SCRIPTS += network-nat vif-nat
XEN_SCRIPTS += block
XEN_SCRIPTS += block-enbd block-nbd
XEN_SCRIPTS += vtpm vtpm-delete
+XEN_SCRIPTS += xen-hotplug-cleanup
XEN_SCRIPT_DATA = xen-script-common.sh locking.sh logging.sh
XEN_SCRIPT_DATA += xen-hotplug-common.sh xen-network-common.sh vif-common.sh
XEN_SCRIPT_DATA += block-common.sh vtpm-common.sh vtpm-hotplug-common.sh
diff --git a/tools/examples/xen-backend.agent b/tools/examples/xen-backend.agent
index 670c24b775..72bbafda21 100755
--- a/tools/examples/xen-backend.agent
+++ b/tools/examples/xen-backend.agent
@@ -18,7 +18,7 @@ case "$ACTION" in
add)
;;
remove)
- /etc/xen/scripts/xen-hotplug-cleanup.sh
+ /etc/xen/scripts/xen-hotplug-cleanup
;;
online)
;;
diff --git a/tools/examples/xen-backend.rules b/tools/examples/xen-backend.rules
index aec5c46121..91f0b06107 100644
--- a/tools/examples/xen-backend.rules
+++ b/tools/examples/xen-backend.rules
@@ -2,6 +2,4 @@ SUBSYSTEM=="xen-backend", KERNEL=="vbd*", RUN+="/etc/xen/scripts/block $env{ACTI
SUBSYSTEM=="xen-backend", KERNEL=="vtpm*", RUN+="/etc/xen/scripts/vtpm $env{ACTION}"
SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="online", RUN+="$env{script} online"
SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="offline", RUN+="$env{script} offline"
-SUBSYSTEM=="xen-backend", ACTION=="remove", RUN+="/bin/bash -c '/usr/bin/xenstore-rm -t $$(/usr/bin/xenstore-read $env{XENBUS_PATH}/frontend)'"
-SUBSYSTEM=="xen-backend", ACTION=="remove", RUN+="/usr/bin/xenstore-rm -t $env{XENBUS_PATH}"
-SUBSYSTEM=="xen-backend", ACTION=="remove", RUN+="/usr/bin/xenstore-rm -t error/$env{XENBUS_PATH}"
+SUBSYSTEM=="xen-backend", ACTION=="remove", RUN+="/etc/xen/scripts/xen-hotplug-cleanup"
diff --git a/tools/examples/xen-hotplug-cleanup b/tools/examples/xen-hotplug-cleanup
new file mode 100644
index 0000000000..4e9c0ca735
--- /dev/null
+++ b/tools/examples/xen-hotplug-cleanup
@@ -0,0 +1,21 @@
+#! /bin/sh
+
+dir=$(dirname "$0")
+. "$dir/xen-hotplug-common.sh"
+
+# Claim the lock protecting /etc/xen/scripts/block. This stops a race whereby
+# paths in the store would disappear underneath that script as it attempted to
+# read from the store checking for device sharing.
+# Any other scripts that do similar things will have to have their lock
+# claimed too.
+# This is pretty horrible, but there's not really a nicer way of solving this.
+claim_lock "block"
+
+# remove device frontend store entries
+xenstore-rm -t $(xenstore-read "$XENBUS_PATH/frontend") || true
+
+# remove device backend store entries
+xenstore-rm -t "$XENBUS_PATH" || true
+xenstore-rm -t "error/$XENBUS_PATH" || true
+
+release_lock "block"