3 # Copyright (c) 2005, XenSource Ltd.
6 . "$dir/xen-hotplug-common.sh"
7 . "$dir/block-common.sh"
12 # check_blktap_sharing file mode
14 # Perform the sharing check for the given blktap and mode.
16 check_blktap_sharing()
21 local base_path="$XENBUS_BASE_PATH/$XENBUS_TYPE"
22 for dom in $(xenstore-list "$base_path")
24 for dev in $(xenstore-list "$base_path/$dom")
26 params=$(xenstore_read "$base_path/$dom/$dev/params" | cut -d: -f2)
27 if [ "$file" = "$params" ]
38 local m=$(xenstore_read "$base_path/$dom/$dev/mode")
39 m=$(canonicalise_mode "$m")
58 t=$(xenstore_read_default "$XENBUS_PATH/type" 'MISSING')
61 p=$(xenstore_read "$XENBUS_PATH/params")
62 # if we have a ':', chew from head including :
63 if echo $p | grep -q \:
68 # some versions of readlink cannot be passed a regular file
70 file=$(readlink -f "$p") || fatal "$p link does not exist."
75 if [ "$command" = 'add' ]
77 [ -e "$file" ] || { fatal $file does not exist; }
79 FRONTEND_ID=$(xenstore_read "$XENBUS_PATH/frontend-id")
80 FRONTEND_UUID=$(xenstore_read "/local/domain/$FRONTEND_ID/vm")
81 mode=$(xenstore_read "$XENBUS_PATH/mode")
82 mode=$(canonicalise_mode "$mode")
86 result=$(check_blktap_sharing "$file" "$mode")
87 [ "$result" = 'ok' ] || ebusy "$file already in use by other domain"