diff --git a/src/tm_mad/ssh/cpds b/src/tm_mad/ssh/cpds index f8765640e7..061d51aa6b 100755 --- a/src/tm_mad/ssh/cpds +++ b/src/tm_mad/ssh/cpds @@ -122,6 +122,33 @@ EOF log_error "Exporting failed" exit 1 fi +else + # if SRC is qcow2 with backing chain, convert it to tmp path + CPDS_CMD_EXPORT=$(cat <<EOF + set -e -o pipefail + if [ -L $SRC_PATH ] && file -L $SRC_PATH | grep -q 'has backing file'; then + $QEMU_IMG convert -O qcow2 $SRC_PATH $SRC_TEMP_PATH; + exit 42; + fi +EOF +) + + ssh_exec_and_log_no_error $SRC_HOST "$CPDS_CMD_EXPORT" "$CPDS_CMD_ERR" "100" + RC=$? + if [ $RC = 0 ]; then + # no export needed + true + elif [ $RC = 42 ]; then + # qcow2 detected and exported, re-point SRC and other vars + SRC="${SRC_HOST}:${SRC_TEMP_PATH}" + set_src_dst_vars + + # Always try delete temp export + trap "ssh_exec_and_log $SRC_HOST \"$RM ${SRC_TEMP_PATH}\"" EXIT + else + error_message "cpds: Can not convert qcow2 chain $SRC_PATH" + exit 1 + fi fi log "Moving $SRC to datastore as $DST"