ia64/xen-unstable

view tools/hotplug/Linux/xen-hotplug-cleanup @ 19252:b3774712e654

xend: Fix removing /vm/UUID/device paths when device cannot be disconnected

Change deviceDestroy behavior to remove /vm/UUID/device/...
path only when force was used (as it already does so for both frontend
and backend) and do the removing from xen-hotplug-cleanup script when we
are sure the device is really not attached to the guest any more.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Mar 02 10:34:37 2009 +0000 (2009-03-02)
parents 4bfc67b09e9c
children 131c799580cb
line source
1 #! /bin/bash
3 dir=$(dirname "$0")
4 . "$dir/xen-hotplug-common.sh"
6 # Claim the lock protecting /etc/xen/scripts/block. This stops a race whereby
7 # paths in the store would disappear underneath that script as it attempted to
8 # read from the store checking for device sharing.
9 # Any other scripts that do similar things will have to have their lock
10 # claimed too.
11 # This is pretty horrible, but there's not really a nicer way of solving this.
12 claim_lock "block"
14 # split backend/DEVCLASS/VMID/DEVID on slashes
15 path_array=( ${XENBUS_PATH//\// } )
16 # get /vm/UUID path
17 vm=$(xenstore-read "/local/domain/${path_array[2]}/vm")
18 # construct /vm/UUID/device/DEVCLASS/DEVID
19 vm_dev="$vm/device/${path_array[1]}/${path_array[3]}"
21 # remove device frontend store entries
22 xenstore-rm -t \
23 $(xenstore-read "$XENBUS_PATH/frontend" 2>/dev/null) 2>/dev/null || true
25 # remove device backend store entries
26 xenstore-rm -t "$XENBUS_PATH" 2>/dev/null || true
27 xenstore-rm -t "error/$XENBUS_PATH" 2>/dev/null || true
29 # remove device path from /vm/UUID
30 xenstore-rm -t "$vm_dev" 2>/dev/null || true
32 release_lock "block"