* [Qemu-devel] [PATCH] iotests: Make 150 use qemu-img map instead of du
@ 2016-03-29 16:24 Max Reitz
2016-04-08 10:30 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Max Reitz @ 2016-03-29 16:24 UTC (permalink / raw)
To: qemu-block; +Cc: Kevin Wolf, qemu-devel, Max Reitz
The actual on-disk size of a file does not only depend on factors qemu
can control. Thus, we should not depend on this to determine whether a
file has indeed been fully allocated. Instead, use qemu-img map and hope
that if an area is referenced, it is indeed allocated, too.
Also, limit the supported image formats to raw and qcow2 because the
actual qemu-img map output may depend on the image format.
Signed-off-by: Max Reitz <mreitz@redhat.com>
---
tests/qemu-iotests/150 | 41 +++++------------------------------------
tests/qemu-iotests/150.out | 13 +++++--------
2 files changed, 10 insertions(+), 44 deletions(-)
diff --git a/tests/qemu-iotests/150 b/tests/qemu-iotests/150
index 97d2a35..665373d 100755
--- a/tests/qemu-iotests/150
+++ b/tests/qemu-iotests/150
@@ -38,65 +38,34 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
. ./common.rc
. ./common.filter
-_supported_fmt generic
+_supported_fmt raw qcow2
_supported_proto file
_supported_os Linux
-on_disk_size()
-{
- du "$@" | sed -e 's/\t\+.*//'
-}
-
-
img_size=1048576
echo
-echo '=== Comparing empty image against sparse conversion ==='
+echo '=== Mapping sparse conversion ==='
echo
-_make_test_img $img_size
-
-empty_size=$(on_disk_size "$TEST_IMG")
-
-
$QEMU_IMG_PROG convert -O "$IMGFMT" -S 512 \
"json:{ 'driver': 'null-co', 'size': $img_size, 'read-zeroes': true }" \
"$TEST_IMG"
-sparse_convert_size=$(on_disk_size "$TEST_IMG")
-
-
-if [ "$empty_size" -eq "$sparse_convert_size" ]; then
- echo 'Equal image size'
-else
- echo 'Different image size'
-fi
+$QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map
echo
-echo '=== Comparing full image against non-sparse conversion ==='
+echo '=== Mapping non-sparse conversion ==='
echo
-_make_test_img $img_size
-$QEMU_IO -c "write 0 $img_size" "$TEST_IMG" | _filter_qemu_io
-
-full_size=$(on_disk_size "$TEST_IMG")
-
-
$QEMU_IMG convert -O "$IMGFMT" -S 0 \
"json:{ 'driver': 'null-co', 'size': $img_size, 'read-zeroes': true }" \
"$TEST_IMG"
-non_sparse_convert_size=$(on_disk_size "$TEST_IMG")
-
-
-if [ "$full_size" -eq "$non_sparse_convert_size" ]; then
- echo 'Equal image size'
-else
- echo 'Different image size'
-fi
+$QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map
# success, all done
diff --git a/tests/qemu-iotests/150.out b/tests/qemu-iotests/150.out
index 2d29da1..2a54e8d 100644
--- a/tests/qemu-iotests/150.out
+++ b/tests/qemu-iotests/150.out
@@ -1,14 +1,11 @@
QA output created by 150
-=== Comparing empty image against sparse conversion ===
+=== Mapping sparse conversion ===
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
-Equal image size
+Offset Length File
-=== Comparing full image against non-sparse conversion ===
+=== Mapping non-sparse conversion ===
-Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
-wrote 1048576/1048576 bytes at offset 0
-1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-Equal image size
+Offset Length File
+0 0x100000 TEST_DIR/t.IMGFMT
*** done
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] iotests: Make 150 use qemu-img map instead of du
2016-03-29 16:24 [Qemu-devel] [PATCH] iotests: Make 150 use qemu-img map instead of du Max Reitz
@ 2016-04-08 10:30 ` Paolo Bonzini
2016-04-08 11:07 ` Kevin Wolf
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2016-04-08 10:30 UTC (permalink / raw)
To: Max Reitz, qemu-block; +Cc: Kevin Wolf, qemu-devel
On 29/03/2016 18:24, Max Reitz wrote:
> The actual on-disk size of a file does not only depend on factors qemu
> can control. Thus, we should not depend on this to determine whether a
> file has indeed been fully allocated. Instead, use qemu-img map and hope
> that if an area is referenced, it is indeed allocated, too.
>
> Also, limit the supported image formats to raw and qcow2 because the
> actual qemu-img map output may depend on the image format.
>
> Signed-off-by: Max Reitz <mreitz@redhat.com>
> ---
> tests/qemu-iotests/150 | 41 +++++------------------------------------
> tests/qemu-iotests/150.out | 13 +++++--------
> 2 files changed, 10 insertions(+), 44 deletions(-)
>
> diff --git a/tests/qemu-iotests/150 b/tests/qemu-iotests/150
> index 97d2a35..665373d 100755
> --- a/tests/qemu-iotests/150
> +++ b/tests/qemu-iotests/150
> @@ -38,65 +38,34 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
> . ./common.rc
> . ./common.filter
>
> -_supported_fmt generic
> +_supported_fmt raw qcow2
> _supported_proto file
> _supported_os Linux
>
>
> -on_disk_size()
> -{
> - du "$@" | sed -e 's/\t\+.*//'
> -}
> -
> -
> img_size=1048576
>
>
> echo
> -echo '=== Comparing empty image against sparse conversion ==='
> +echo '=== Mapping sparse conversion ==='
> echo
>
> -_make_test_img $img_size
> -
> -empty_size=$(on_disk_size "$TEST_IMG")
> -
> -
> $QEMU_IMG_PROG convert -O "$IMGFMT" -S 512 \
> "json:{ 'driver': 'null-co', 'size': $img_size, 'read-zeroes': true }" \
> "$TEST_IMG"
>
> -sparse_convert_size=$(on_disk_size "$TEST_IMG")
> -
> -
> -if [ "$empty_size" -eq "$sparse_convert_size" ]; then
> - echo 'Equal image size'
> -else
> - echo 'Different image size'
> -fi
> +$QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map
>
>
> echo
> -echo '=== Comparing full image against non-sparse conversion ==='
> +echo '=== Mapping non-sparse conversion ==='
> echo
>
> -_make_test_img $img_size
> -$QEMU_IO -c "write 0 $img_size" "$TEST_IMG" | _filter_qemu_io
> -
> -full_size=$(on_disk_size "$TEST_IMG")
> -
> -
> $QEMU_IMG convert -O "$IMGFMT" -S 0 \
> "json:{ 'driver': 'null-co', 'size': $img_size, 'read-zeroes': true }" \
> "$TEST_IMG"
>
> -non_sparse_convert_size=$(on_disk_size "$TEST_IMG")
> -
> -
> -if [ "$full_size" -eq "$non_sparse_convert_size" ]; then
> - echo 'Equal image size'
> -else
> - echo 'Different image size'
> -fi
> +$QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map
>
>
> # success, all done
> diff --git a/tests/qemu-iotests/150.out b/tests/qemu-iotests/150.out
> index 2d29da1..2a54e8d 100644
> --- a/tests/qemu-iotests/150.out
> +++ b/tests/qemu-iotests/150.out
> @@ -1,14 +1,11 @@
> QA output created by 150
>
> -=== Comparing empty image against sparse conversion ===
> +=== Mapping sparse conversion ===
>
> -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
> -Equal image size
> +Offset Length File
>
> -=== Comparing full image against non-sparse conversion ===
> +=== Mapping non-sparse conversion ===
>
> -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576
> -wrote 1048576/1048576 bytes at offset 0
> -1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> -Equal image size
> +Offset Length File
> +0 0x100000 TEST_DIR/t.IMGFMT
> *** done
>
Tested-by: Paolo Bonzini <pbonzini@redhat.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] iotests: Make 150 use qemu-img map instead of du
2016-04-08 10:30 ` Paolo Bonzini
@ 2016-04-08 11:07 ` Kevin Wolf
0 siblings, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2016-04-08 11:07 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: Max Reitz, qemu-block, qemu-devel
Am 08.04.2016 um 12:30 hat Paolo Bonzini geschrieben:
>
>
> On 29/03/2016 18:24, Max Reitz wrote:
> > The actual on-disk size of a file does not only depend on factors qemu
> > can control. Thus, we should not depend on this to determine whether a
> > file has indeed been fully allocated. Instead, use qemu-img map and hope
> > that if an area is referenced, it is indeed allocated, too.
> >
> > Also, limit the supported image formats to raw and qcow2 because the
> > actual qemu-img map output may depend on the image format.
> >
> > Signed-off-by: Max Reitz <mreitz@redhat.com>
>
> Tested-by: Paolo Bonzini <pbonzini@redhat.com>
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-04-08 11:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-29 16:24 [Qemu-devel] [PATCH] iotests: Make 150 use qemu-img map instead of du Max Reitz
2016-04-08 10:30 ` Paolo Bonzini
2016-04-08 11:07 ` Kevin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).