ia64/xen-unstable

changeset 9055:b30564f40914

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>
author emellor@leeni.uk.xensource.com
date Mon Feb 27 17:16:04 2006 +0100 (2006-02-27)
parents 38d9f4cbbc1e
children b6af6ab53c67
files tools/examples/Makefile tools/examples/xen-backend.agent tools/examples/xen-backend.rules tools/examples/xen-hotplug-cleanup
line diff
     1.1 --- a/tools/examples/Makefile	Mon Feb 27 16:29:03 2006 +0100
     1.2 +++ b/tools/examples/Makefile	Mon Feb 27 17:16:04 2006 +0100
     1.3 @@ -27,6 +27,7 @@ XEN_SCRIPTS += network-nat vif-nat
     1.4  XEN_SCRIPTS += block
     1.5  XEN_SCRIPTS += block-enbd block-nbd
     1.6  XEN_SCRIPTS += vtpm vtpm-delete
     1.7 +XEN_SCRIPTS += xen-hotplug-cleanup
     1.8  XEN_SCRIPT_DATA = xen-script-common.sh locking.sh logging.sh
     1.9  XEN_SCRIPT_DATA += xen-hotplug-common.sh xen-network-common.sh vif-common.sh
    1.10  XEN_SCRIPT_DATA += block-common.sh vtpm-common.sh vtpm-hotplug-common.sh
     2.1 --- a/tools/examples/xen-backend.agent	Mon Feb 27 16:29:03 2006 +0100
     2.2 +++ b/tools/examples/xen-backend.agent	Mon Feb 27 17:16:04 2006 +0100
     2.3 @@ -18,7 +18,7 @@ case "$ACTION" in
     2.4    add)
     2.5      ;;
     2.6    remove)
     2.7 -    /etc/xen/scripts/xen-hotplug-cleanup.sh
     2.8 +    /etc/xen/scripts/xen-hotplug-cleanup
     2.9      ;;
    2.10    online)
    2.11      ;;
     3.1 --- a/tools/examples/xen-backend.rules	Mon Feb 27 16:29:03 2006 +0100
     3.2 +++ b/tools/examples/xen-backend.rules	Mon Feb 27 17:16:04 2006 +0100
     3.3 @@ -2,6 +2,4 @@ SUBSYSTEM=="xen-backend", KERNEL=="vbd*"
     3.4  SUBSYSTEM=="xen-backend", KERNEL=="vtpm*", RUN+="/etc/xen/scripts/vtpm $env{ACTION}"
     3.5  SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="online", RUN+="$env{script} online"
     3.6  SUBSYSTEM=="xen-backend", KERNEL=="vif*", ACTION=="offline", RUN+="$env{script} offline"
     3.7 -SUBSYSTEM=="xen-backend", ACTION=="remove", RUN+="/bin/bash -c '/usr/bin/xenstore-rm -t $$(/usr/bin/xenstore-read $env{XENBUS_PATH}/frontend)'"
     3.8 -SUBSYSTEM=="xen-backend", ACTION=="remove", RUN+="/usr/bin/xenstore-rm -t $env{XENBUS_PATH}"
     3.9 -SUBSYSTEM=="xen-backend", ACTION=="remove", RUN+="/usr/bin/xenstore-rm -t error/$env{XENBUS_PATH}"
    3.10 +SUBSYSTEM=="xen-backend", ACTION=="remove", RUN+="/etc/xen/scripts/xen-hotplug-cleanup"
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/tools/examples/xen-hotplug-cleanup	Mon Feb 27 17:16:04 2006 +0100
     4.3 @@ -0,0 +1,21 @@
     4.4 +#! /bin/sh
     4.5 +
     4.6 +dir=$(dirname "$0")
     4.7 +. "$dir/xen-hotplug-common.sh"
     4.8 +
     4.9 +# Claim the lock protecting /etc/xen/scripts/block.  This stops a race whereby
    4.10 +# paths in the store would disappear underneath that script as it attempted to
    4.11 +# read from the store checking for device sharing.
    4.12 +# Any other scripts that do similar things will have to have their lock
    4.13 +# claimed too.
    4.14 +# This is pretty horrible, but there's not really a nicer way of solving this.
    4.15 +claim_lock "block"
    4.16 +
    4.17 +# remove device frontend store entries
    4.18 +xenstore-rm -t $(xenstore-read "$XENBUS_PATH/frontend") || true
    4.19 +
    4.20 +# remove device backend store entries
    4.21 +xenstore-rm -t "$XENBUS_PATH"       || true
    4.22 +xenstore-rm -t "error/$XENBUS_PATH" || true
    4.23 +
    4.24 +release_lock "block"