From 372a3be71066e7a0a5797a26e91b9ef26254b1d1 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 16 Nov 2023 11:14:45 +0100 Subject: [PATCH] B #-: Fix replica migration 6.8 uses full disk paths in domain definitions for KVM. This commits fixes some issues to adapt the migrate script in this case. --- src/vmm_mad/remotes/kvm/migrate | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/vmm_mad/remotes/kvm/migrate b/src/vmm_mad/remotes/kvm/migrate index 8d51749421..58a7ebb93b 100755 --- a/src/vmm_mad/remotes/kvm/migrate +++ b/src/vmm_mad/remotes/kvm/migrate @@ -41,7 +41,7 @@ get_size_and_format_of_disk_img() { local QEMU_IMG_PATH="$1" local PARAM="$2" - if [[ "$TARGET" =~ disk.[0-9]*.snap/ ]]; then + if [[ "$QEMU_IMG_PATH" =~ disk.[0-9]*.snap/ ]]; then #Disk lives in snap dir it is a link (includes replica) echo unknown qcow2-symlink return @@ -165,16 +165,22 @@ else fi # copy disk snapshots - if [ -d "${DISK_PATH}.snap" ] || [ -L "${DISK_PATH}.snap" ]; then - multiline_exec_and_log "$TAR -cSf - $DISK_PATH.snap | $SSH $DEST_HOST '$TAR -xSf - -C / '" \ - "Failed to rsync disk snapshot ${DISK_PATH}.snap to $DEST_HOST" + if [[ "$DISK_PATH" =~ (disk\.[0-9]*\.snap)/. ]]; then + SNAP_DIR="$VM_DIR/${BASH_REMATCH[1]}" + elif [ -d "${DISK_PATH}.snap" ]; then #it should be included in the clause above + SNAP_DIR="${DISK_PATH}.snap" + fi + + if [ -n "${SNAP_DIR}" ]; then + multiline_exec_and_log "$TAR -cSf - ${SNAP_DIR} | $SSH $DEST_HOST '$TAR -xSf - -C / '" \ + "Failed to rsync disk snapshot ${SNAP_DIR} to $DEST_HOST" fi # recreate symlinks if [ -L "$DISK_PATH" ]; then TARGET=$(readlink $DISK_PATH) LNAME=$DISK_PATH - elif [[ "$DISK_PATH" =~ (disk.([0-9]*).snap/[0-9]*) ]]; then + elif [[ "$DISK_PATH" =~ (disk\.([0-9]*)\.snap/.*) ]]; then TARGET=${BASH_REMATCH[1]} LNAME="disk.${BASH_REMATCH[2]}" else