dom0: Use /var/run/xen-hotplug to store information needed for block devices cleanup.
Libxl removes xenstore entries before udev (+scripts) have chance to read it.
This commit is contained in:
parent
197ccb2e2c
commit
f1f98d47df
@ -7,6 +7,8 @@
|
|||||||
dir=$(dirname "$0")
|
dir=$(dirname "$0")
|
||||||
. "$dir/block-common.sh"
|
. "$dir/block-common.sh"
|
||||||
|
|
||||||
|
HOTPLUG_STORE="/var/run/xen-hotplug/${XENBUS_PATH//\//-}"
|
||||||
|
|
||||||
get_dev() {
|
get_dev() {
|
||||||
dev=$1
|
dev=$1
|
||||||
|
|
||||||
@ -89,7 +91,6 @@ create_dm_snapshot_origin() {
|
|||||||
|
|
||||||
t=$(xenstore_read_default "$XENBUS_PATH/type" 'MISSING')
|
t=$(xenstore_read_default "$XENBUS_PATH/type" 'MISSING')
|
||||||
|
|
||||||
|
|
||||||
case "$command" in
|
case "$command" in
|
||||||
add)
|
add)
|
||||||
case $t in
|
case $t in
|
||||||
@ -117,14 +118,20 @@ case "$command" in
|
|||||||
if [ "$t" == "snapshot" ]; then
|
if [ "$t" == "snapshot" ]; then
|
||||||
#that's all for snapshot, store name of prepared device
|
#that's all for snapshot, store name of prepared device
|
||||||
xenstore_write "$XENBUS_PATH/node" "/dev/mapper/$dm_devname"
|
xenstore_write "$XENBUS_PATH/node" "/dev/mapper/$dm_devname"
|
||||||
|
echo "/dev/mapper/$dm_devname" > "$HOTPLUG_STORE-node"
|
||||||
write_dev /dev/mapper/$dm_devname
|
write_dev /dev/mapper/$dm_devname
|
||||||
elif [ "$t" == "origin" ]; then
|
elif [ "$t" == "origin" ]; then
|
||||||
# for origin - prepare snapshot-origin device and store its name
|
# for origin - prepare snapshot-origin device and store its name
|
||||||
dm_devname=origin-$(stat -c '%D:%i' "$base")
|
dm_devname=origin-$(stat -c '%D:%i' "$base")
|
||||||
create_dm_snapshot_origin $dm_devname "$base"
|
create_dm_snapshot_origin $dm_devname "$base"
|
||||||
xenstore_write "$XENBUS_PATH/node" "/dev/mapper/$dm_devname"
|
xenstore_write "$XENBUS_PATH/node" "/dev/mapper/$dm_devname"
|
||||||
|
echo "/dev/mapper/$dm_devname" > "$HOTPLUG_STORE-node"
|
||||||
write_dev /dev/mapper/$dm_devname
|
write_dev /dev/mapper/$dm_devname
|
||||||
fi
|
fi
|
||||||
|
# Save domain name for template commit on device remove
|
||||||
|
domid=$(xenstore_read "$XENBUS_PATH/frontend-id")
|
||||||
|
domain=$(xl domname $domid)
|
||||||
|
echo $domain > "$HOTPLUG_STORE-domain"
|
||||||
|
|
||||||
release_lock "block"
|
release_lock "block"
|
||||||
exit 0
|
exit 0
|
||||||
@ -134,7 +141,7 @@ case "$command" in
|
|||||||
remove)
|
remove)
|
||||||
case $t in
|
case $t in
|
||||||
snapshot|origin)
|
snapshot|origin)
|
||||||
node=$(xenstore_read "$XENBUS_PATH/node")
|
node=$(cat "$HOTPLUG_STORE-node")
|
||||||
|
|
||||||
if [ -z "$node" ]; then
|
if [ -z "$node" ]; then
|
||||||
fatal "No device node to remove"
|
fatal "No device node to remove"
|
||||||
@ -175,7 +182,7 @@ case "$command" in
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
# Commit template changes
|
# Commit template changes
|
||||||
domain=$(xenstore_read "$XENBUS_PATH/domain")
|
domain=$(cat "$HOTPLUG_STORE-domain")
|
||||||
if [ "$domain" ]; then
|
if [ "$domain" ]; then
|
||||||
# Dont stop on errors
|
# Dont stop on errors
|
||||||
/usr/bin/qvm-template-commit "$domain" || true
|
/usr/bin/qvm-template-commit "$domain" || true
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
HOTPLUG_STORE="/var/run/xen-hotplug/${XENBUS_PATH//\//-}"
|
||||||
|
|
||||||
hd_arr[10]=a
|
hd_arr[10]=a
|
||||||
hd_arr[11]=b
|
hd_arr[11]=b
|
||||||
hd_arr[12]=c
|
hd_arr[12]=c
|
||||||
@ -38,6 +40,8 @@ process()
|
|||||||
xenstore-write "$XENBUS_PATH/node" "$dev" \
|
xenstore-write "$XENBUS_PATH/node" "$dev" \
|
||||||
"$XENBUS_PATH/physical-device" "7:"$HEXNUMBER \
|
"$XENBUS_PATH/physical-device" "7:"$HEXNUMBER \
|
||||||
"$XENBUS_PATH/hotplug-status" connected
|
"$XENBUS_PATH/hotplug-status" connected
|
||||||
|
echo "$dev" > "$HOTPLUG_STORE-node"
|
||||||
|
echo "file" > "$HOTPLUG_STORE-type"
|
||||||
}
|
}
|
||||||
|
|
||||||
#exec 2>>/tmp/block.$$
|
#exec 2>>/tmp/block.$$
|
||||||
|
Loading…
Reference in New Issue
Block a user