1
0
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:
Vlastimil Holer 2018-07-04 18:59:52 +02:00 committed by Ruben S. Montero
parent e2e88946f7
commit e165c3fe6b
3 changed files with 13 additions and 2 deletions

View File

@ -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

View File

@ -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

View File

@ -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}"