From bc9e4d1fe554ebd7df7aa033b1fb1fdfccc7adaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sun, 22 Feb 2015 14:44:09 +0100 Subject: [PATCH] linux/block-snapshot: improve support for HVM domain Handle stubdomains (the same device will be removed twice). Use target domain name instead of stubdomain name for committing template changes. --- linux/system-config/block-snapshot | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/linux/system-config/block-snapshot b/linux/system-config/block-snapshot index fb41856e..7822a07e 100755 --- a/linux/system-config/block-snapshot +++ b/linux/system-config/block-snapshot @@ -135,11 +135,10 @@ case "$command" in write_dev /dev/mapper/$dm_devname fi # Save domain name for template commit on device remove - domain=$(xenstore_read_default "$XENBUS_PATH/domain" '') - if [ -z "$domain" ]; then - domid=$(xenstore_read "$XENBUS_PATH/frontend-id") - domain=$(xl domname $domid) - fi + domid=$(xenstore_read "$XENBUS_PATH/frontend-id") + # Store name of target domain in case of stubdom + domid=$(xenstore_read_default "/local/domain/$domid/target" "$domid") + domain=$(xl domname $domid) echo $domain > "$HOTPLUG_STORE-domain" release_lock "block" @@ -212,7 +211,13 @@ case "$command" in claim_lock "block" - use_count=$(dmsetup info $node|grep Open|awk '{print $3}') + use_count=$(dmsetup info $node 2>/dev/null|grep Open|awk '{print $3}') + + if [ -z "$use_count" ]; then + log info "Device $node already removed" + release_lock "block" + exit 0 + fi # do not remove snapshot if snapshot origin is still present if [ "${node/snapshot/}" != "$node" -a -e "/dev/mapper/origin-$(echo $node|cut -d- -f2)" ]; then