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
60b86de2ca
commit
68b5a71add
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user