From cada917eb07bc486bf33fce5acb61369baa9419d Mon Sep 17 00:00:00 2001 From: Daman Arora Date: Wed, 25 Nov 2026 12:52:38 -0500 Subject: [PATCH] fail template creation when qemu-img or cp fails in createtmplt.sh --- scripts/storage/qcow2/createtmplt.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/storage/qcow2/createtmplt.sh b/scripts/storage/qcow2/createtmplt.sh index de7010b0a25e..ccd7966ae287 100755 --- a/scripts/storage/qcow2/createtmplt.sh +++ b/scripts/storage/qcow2/createtmplt.sh @@ -88,18 +88,28 @@ create_from_file() { local tmpltfs=$1 local tmpltimg="$2" local tmpltname=$3 + local rc=0 if [ -b $tmpltimg ]; then $qemu_img convert -f raw -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname + rc=$? else # if backing image exists, we need to combine them, otherwise # copy the image to preserve snapshots/compression if $qemu_img info "$tmpltimg" | grep -q backing; then $qemu_img convert -f qcow2 -O qcow2 "$tmpltimg" /$tmpltfs/$tmpltname >& /dev/null + rc=$? else cp -f $tmpltimg /$tmpltfs/$tmpltname + rc=$? fi fi + if [ $rc -ne 0 ] + then + printf "Failed to create template /$tmpltfs/$tmpltname from $tmpltimg " + exit 4 + fi + if [ "$cleanup" == "true" ] then rm -f "$tmpltimg"