mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
If disk has RECOVERY_SNAPSHOT_FREQ attr, it's a qcow2 backing chain (2). Convert it to a single qcow2 first.
This commit is contained in:
parent
a9739e454e
commit
4a35ca7c71
@ -478,6 +478,7 @@ ssh_forward()
|
||||
}
|
||||
|
||||
#This function executes $2 at $1 host and report error $3 but does not exit
|
||||
#Accept $4 as alternative correct return code
|
||||
function ssh_exec_and_log_no_error
|
||||
{
|
||||
SSH_EXEC_ERR=`$SSH $1 bash -s 2>&1 1>/dev/null <<EOF
|
||||
@ -487,7 +488,7 @@ $2
|
||||
EOF`
|
||||
SSH_EXEC_RC=$?
|
||||
|
||||
if [ $SSH_EXEC_RC -ne 0 ]; then
|
||||
if [ $SSH_EXEC_RC -ne 0 ] && [ $SSH_EXEC_RC != "$4" ]; then
|
||||
log_error "Command \"$2\" failed: $SSH_EXEC_ERR"
|
||||
|
||||
if [ -n "$3" ]; then
|
||||
@ -496,10 +497,9 @@ EOF`
|
||||
error_message "Error executing $2: $SSH_EXEC_ERR"
|
||||
fi
|
||||
|
||||
return $SSH_EXEC_RC
|
||||
fi
|
||||
|
||||
return 0
|
||||
return $SSH_EXEC_RC
|
||||
}
|
||||
|
||||
#This function executes $2 at $1 host and report error $3
|
||||
|
@ -124,7 +124,7 @@ EOF
|
||||
CPDS_CMD_ERR="Error creating export for domain ${DEPLOY_ID} of disk ${DISK_TARGET} at ${SRC_TEMP_PATH}"
|
||||
|
||||
# Always try delete temp export
|
||||
trap "ssh_exec_and_log $SRC_HOST \"$RM ${SRC_TEMP_PATH}\"" EXIT TERM INT HUP
|
||||
trap "ssh_exec_and_log $SRC_HOST \"$RM ${SRC_TEMP_PATH}\"" EXIT
|
||||
|
||||
if ssh_exec_and_log_no_error $SRC_HOST "$CPDS_CMD_EXPORT" "$CPDS_CMD_ERR"; then
|
||||
# Export creation succeeded, point SRC there
|
||||
@ -134,6 +134,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 "Can not convert qcow2 chain $SRC_PATH"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
log "Moving $SRC to datastore as $DST_PATH"
|
||||
|
Loading…
x
Reference in New Issue
Block a user