-#!/bin/bash
+#!/usr/bin/env bash
#
# Resizing images
#
seq=`basename $0`
echo "QA output created by $seq"
-here=`pwd`
-tmp=/tmp/$$
status=1 # failure is the default!
_cleanup()
. ./common.filter
. ./common.pattern
-_supported_fmt raw qcow2
-_supported_os Linux
+_supported_fmt raw qcow2 qed luks
+_supported_proto file sheepdog rbd nfs
echo "=== Creating image"
echo
echo
echo "=== Resizing image"
-$QEMU_IO $TEST_IMG <<EOF
+$QEMU_IO "$TEST_IMG" <<EOF | _filter_qemu_io
length
truncate $big_size
length
EOF
_check_test_img
+# bdrv_truncate() doesn't zero the new space, so we need to do that explicitly.
+# We still want to test automatic zeroing for other formats even though
+# bdrv_truncate() doesn't guarantee it.
+if [ "$IMGFMT" == "luks" ]; then
+ $QEMU_IO -c "write -z $small_size $((big_size - small_size))" "$TEST_IMG" > /dev/null
+fi
+
echo
echo "=== Verifying image size after reopen"
-$QEMU_IO -c "length" $TEST_IMG
+$QEMU_IO -c "length" "$TEST_IMG"
echo
echo "=== Verifying resized image"