1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-16 22:50:10 +03:00

M #-: Cleanup files if unknown format for qemu cp (#2199)

(cherry picked from commit f01b28e763ea94e7b3fb4cc44e350b340c996842)
This commit is contained in:
Pavel Czerný 2022-06-29 11:59:24 +02:00 committed by Ruben S. Montero
parent 3d19709d94
commit f59f1b4cf1
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
3 changed files with 9 additions and 3 deletions

View File

@ -175,6 +175,12 @@ else
fi
FORMAT=$($QEMU_IMG info $DST | grep "^file format:" | awk '{print $3}' || :)
if [ -z $FORMAT ]; then
rm -rf $DST
log_error "Unknown image format src=$SRC"
exit -1
fi
fi
[[ "$FORMAT" = "luks" ]] && FORMAT="raw"

View File

@ -63,7 +63,7 @@ if [ -n "$BRIDGE_LIST" ]; then
"Error deleting $SRC in $DST_HOST"
else
BASENAME_SRC=`basename "${SRC##$REMOTE_RM_CMD}"`
if [ -f "$SRC" -a `dirname "$SRC"` = "$BASE_PATH" -a -n "$BASENAME_SRC" ]
if [ -e "$SRC" -a `dirname "$SRC"` = "$BASE_PATH" -a -n "$BASENAME_SRC" ]
then
log "Removing $SRC from the image repository"

View File

@ -103,6 +103,8 @@ void ImageManager::_cp(unique_ptr<image_msg_t> msg)
goto error;
}
image->set_source(source);
is >> format;
if (is.fail() || format.empty())
@ -111,8 +113,6 @@ void ImageManager::_cp(unique_ptr<image_msg_t> msg)
goto error_common;
}
image->set_source(source);
image->set_format(format);
image->set_state_unlock();