4
. "$dir/xen-hotplug-common.sh"
6
# Claim the lock protecting ${XEN_SCRIPT_DIR}/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
11
# This is pretty horrible, but there's not really a nicer way of solving this.
14
# split backend/DEVCLASS/VMID/DEVID on slashes
15
path_array=( ${XENBUS_PATH//\// } )
17
vm=$(xenstore_read_default "/local/domain/${path_array[2]}/vm" "")
18
# construct /vm/UUID/device/DEVCLASS/DEVID
19
if [ "$vm" != "" ]; then
20
vm_dev="$vm/device/${path_array[1]}/${path_array[3]}"
22
# if the vm path does not exist and the device class is 'vbd' then we may have
24
if [ $(xenstore-read "$vm_dev" 2>/dev/null) != "" ] \
25
&& [ "${path_array[1]}" = "vbd" ]; then
26
vm_dev="$vm/device/tap2/${path_array[3]}"
32
# remove device frontend store entries
34
$(xenstore-read "$XENBUS_PATH/frontend" 2>/dev/null) 2>/dev/null || true
36
# remove device backend store entries
37
xenstore-rm -t "$XENBUS_PATH" 2>/dev/null || true
38
xenstore-rm -t "error/$XENBUS_PATH" 2>/dev/null || true
40
# remove device path from /vm/UUID
41
[ "$vm_dev" != "" ] && xenstore-rm -t "$vm_dev" 2>/dev/null || true