From 2cb4c093671067caa312827f321c844563d1b7e7 Mon Sep 17 00:00:00 2001 From: Daniel Clavijo Coca Date: Tue, 24 Oct 2023 08:15:08 -0600 Subject: [PATCH] B OpenNebula/one#6363: 64 patch --- src/vmm_mad/remotes/kvm/migrate | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/vmm_mad/remotes/kvm/migrate b/src/vmm_mad/remotes/kvm/migrate index e0297e4bf6c..c25b404818e 100755 --- a/src/vmm_mad/remotes/kvm/migrate +++ b/src/vmm_mad/remotes/kvm/migrate @@ -248,20 +248,19 @@ if [ $RC -ne 0 ]; then fi # redefine potential snapshots after live migration -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) +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 ${DISK_DIR}/snap-*.xml 2>/dev/null); do - # replace uuid in the snapshot metadata xml - sed -i "s%[[:alnum:]-]*%$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%[[:alnum:]-]*%$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 - virsh --connect $QEMU_PROTOCOL://$DEST_HOST/system snapshot-current $DEPLOY_ID $SNAP_CUR -fi + # 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 # Synchronize VM time on background on remote host if [ "$SYNC_TIME" = "yes" ]; then