Skip to content

Commit

Permalink
B #6363: Preserve shared flag
Browse files Browse the repository at this point in the history
  • Loading branch information
dann1 committed Oct 25, 2023
1 parent 2cb4c09 commit 236aea3
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/vmm_mad/remotes/kvm/migrate
Original file line number Diff line number Diff line change
Expand Up @@ -248,19 +248,21 @@ if [ $RC -ne 0 ]; then
fi

# redefine potential snapshots after live migration
UUID=$(virsh --connect $QEMU_PROTOCOL://$DEST_HOST/system dominfo $DEPLOY_ID | awk '/UUID:/ {print $2}')
DISK_PATH=$(virsh --connect $QEMU_PROTOCOL://$DEST_HOST/system domblklist $DEPLOY_ID | awk '/disk.0/ {print $2}')
DISK_DIR=$(dirname $DISK_PATH)
if [ "$SHARED" = "YES" ] && [ -n "$SNAP_CUR" ]; then
UUID=$(virsh --connect $QEMU_PROTOCOL://$DEST_HOST/system dominfo $DEPLOY_ID | awk '/UUID:/ {print $2}')
DISK_PATH=$(virsh --connect $QEMU_PROTOCOL://$DEST_HOST/system domblklist $DEPLOY_ID | awk '/disk.0/ {print $2}')
DISK_DIR=$(dirname $DISK_PATH)

for SNAPSHOT_MD_XML in $(ls -v ${DISK_DIR}/snap-*.xml 2>/dev/null); do
# replace uuid in the snapshot metadata xml
sed -i "s%<uuid>[[:alnum:]-]*</uuid>%<uuid>$UUID</uuid>%" $SNAPSHOT_MD_XML
for SNAPSHOT_MD_XML in $(ls -v ${DISK_DIR}/snap-*.xml 2>/dev/null); do
# replace uuid in the snapshot metadata xml
sed -i "s%<uuid>[[:alnum:]-]*</uuid>%<uuid>$UUID</uuid>%" $SNAPSHOT_MD_XML

# redefine the snapshot using the xml metadata file
virsh --connect $QEMU_PROTOCOL://$DEST_HOST/system snapshot-create $DEPLOY_ID $SNAPSHOT_MD_XML --redefine > /dev/null || true
done
# redefine the snapshot using the xml metadata file
virsh --connect $QEMU_PROTOCOL://$DEST_HOST/system snapshot-create $DEPLOY_ID $SNAPSHOT_MD_XML --redefine > /dev/null || true
done

[ -n "$SNAP_CUR" ] && virsh --connect $QEMU_PROTOCOL://$DEST_HOST/system snapshot-current $DEPLOY_ID $SNAP_CUR
[ -n "$SNAP_CUR" ] && virsh --connect $QEMU_PROTOCOL://$DEST_HOST/system snapshot-current $DEPLOY_ID $SNAP_CUR
fi

# Synchronize VM time on background on remote host
if [ "$SYNC_TIME" = "yes" ]; then
Expand Down

0 comments on commit 236aea3

Please sign in to comment.