mirror of
https://github.com/OpenNebula/one.git
synced 2025-04-01 06:50:25 +03:00
B #2189: Safety check not to overwrite snapshot, fix wrong error_message use
This commit is contained in:
parent
e2e88946f7
commit
e165c3fe6b
@ -101,7 +101,7 @@ if ! virsh -c ${LIBVIRT_URI} blockcopy ${DEPLOY_ID} ${DISK_TARGET} ${DST_PATH} -
|
||||
elif virsh -c ${LIBVIRT_URI} suspend ${DEPLOY_ID}; then
|
||||
trap "virsh -c ${LIBVIRT_URI} resume ${DEPLOY_ID}" EXIT TERM INT HUP
|
||||
else
|
||||
error_message "Could not domfsfreeze or suspend domain"
|
||||
echo "Could not domfsfreeze or suspend domain" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -86,6 +86,12 @@ mkdir -p "${SNAP_DIR}"
|
||||
PREVIOUS_SNAP=\$(readlink $SYSTEM_DS_DISK_PATH)
|
||||
|
||||
cd "${SNAP_DIR}"
|
||||
|
||||
if [ -e "${SNAP_PATH}" ]; then
|
||||
echo "Snapshot file ${SNAP_PATH} already exists." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
qemu-img create -f qcow2 -o backing_fmt=qcow2 -b "\${PREVIOUS_SNAP}" "${SNAP_PATH}"
|
||||
ln -sf $SNAP_PATH_SHORT $SYSTEM_DS_DISK_PATH
|
||||
EOT
|
||||
|
@ -140,7 +140,7 @@ if virsh -c $LIBVIRT_URI domfsfreeze $DEPLOY_ID ; then
|
||||
elif virsh -c $LIBVIRT_URI suspend $DEPLOY_ID; then
|
||||
trap "virsh -c $LIBVIRT_URI resume $DEPLOY_ID" EXIT TERM INT HUP
|
||||
else
|
||||
error_message "Could not domfsfreeze or suspend domain"
|
||||
echo "Could not domfsfreeze or suspend domain" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -148,6 +148,11 @@ fi
|
||||
# to be resolvable from the current directory
|
||||
cd "${SNAP_DIR}"
|
||||
|
||||
if [ -e "${SNAP_PATH}" ]; then
|
||||
echo "Snapshot file ${SNAP_PATH} already exists." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
$QEMU_IMG create -o backing_fmt=qcow2 -b "\${PREVIOUS_SNAP}" \
|
||||
-f qcow2 ${QCOW2_OPTIONS} "${SNAP_PATH}"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user