From 5415a70a1fcb043ef3757a514cd6045a2504c880 Mon Sep 17 00:00:00 2001 From: Jose Angel Garrido Montoya Date: Thu, 6 Sep 2018 12:04:36 +0200 Subject: [PATCH] F #2320 Migrate images to/from KVM / vCenter DS (#2396) * F #2320 Migrate images to/from KVM / vCenter DS * Update downloader.sh * Update downloader.sh (cherry picked from commit 8ca5a4b7b422901ec1a84643eaf5bb7e87a73fa5) --- src/datastore_mad/remotes/downloader.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/datastore_mad/remotes/downloader.sh b/src/datastore_mad/remotes/downloader.sh index 7a45b80307..66daf438fa 100755 --- a/src/datastore_mad/remotes/downloader.sh +++ b/src/datastore_mad/remotes/downloader.sh @@ -224,7 +224,7 @@ function get_rbd_cmd echo "ssh '$(esc_sq "$DST_HOST")' \"$RBD export '$(esc_sq "$SOURCE")' -\"" } -TEMP=`getopt -o m:s:l:c:n -l md5:,sha1:,limit:,max-size:,nodecomp -- "$@"` +TEMP=`getopt -o m:s:l:c:n -l md5:,sha1:,limit:,max-size:,convert:,nodecom -- "$@"` if [ $? != 0 ] ; then echo "Arguments error" >&2 @@ -428,9 +428,13 @@ if [ ! -z "$CONVERT" ]; then original_type=$(get_original_type) convert_type=$CONVERT - convert="qemu-img convert -f "$original_type" -O "$convert_type" "$TO" "$tmpimage"" + # if the type of the image differs from the target type we need to convert the image + if [ "$original_type" != "$convert_type" ]; then + convert="qemu-img convert -f "$original_type" -O "$convert_type" "$TO" "$tmpimage"" + eval "$convert" - # Move tmp image to get the final image - mvcommand="mv "$tmpimage" "$TO"" - eval "$mvcommand" -fi \ No newline at end of file + # Move tmp image to get the final image + mvcommand="mv "$tmpimage" "$TO"" + eval "$mvcommand" + fi +fi