The test checks fulfilling qcow2 requirements for the compression
type feature and zstd compression type operability.
Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
---
tests/qemu-iotests/287 | 146 +++++++++++++++++++++++++++++++++++++
tests/qemu-iotests/287.out | 67 +++++++++++++++++
tests/qemu-iotests/group | 1 +
3 files changed, 214 insertions(+)
create mode 100755 tests/qemu-iotests/287
create mode 100644 tests/qemu-iotests/287.out
diff --git a/tests/qemu-iotests/287 b/tests/qemu-iotests/287
new file mode 100755
index 0000000000..156acc40ad
--- /dev/null
+++ b/tests/qemu-iotests/287
@@ -0,0 +1,146 @@
+#!/usr/bin/env bash
+#
+# Test case for an image using zstd compression
+#
+# Copyright (c) 2020 Virtuozzo International GmbH
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+# creator
+owner=dplotnikov@virtuozzo.com
+
+seq="$(basename $0)"
+echo "QA output created by $seq"
+
+status=1 # failure is the default!
+
+# standard environment
+. ./common.rc
+. ./common.filter
+
+# This tests qocw2-specific low-level functionality
+_supported_fmt qcow2
+_supported_proto file
+_supported_os Linux
+
+COMPR_IMG="$TEST_IMG.compressed"
+RAND_FILE="$TEST_DIR/rand_data"
+
+_cleanup()
+{
+ _cleanup_test_img
+ rm -f "$COMPR_IMG"
+ rm -f "$RAND_FILE"
+}
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+# for all the cases
+CLUSTER_SIZE=65536
+
+# Check if we can run this test.
+if IMGOPTS='compression_type=zstd' _make_test_img 64M |
+ grep "Invalid parameter 'zstd'"; then
+ _notrun "ZSTD is disabled"
+fi
+
+echo
+echo "=== Testing compression type incompatible bit setting for zlib ==="
+echo
+IMGOPTS='compression_type=zlib' _make_test_img 64M
+$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
+
+echo
+echo "=== Testing compression type incompatible bit setting for zstd ==="
+echo
+IMGOPTS='compression_type=zstd' _make_test_img 64M
+$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
+
+echo
+echo "=== Testing zlib with incompatible bit set ==="
+echo
+IMGOPTS='compression_type=zlib' _make_test_img 64M
+$PYTHON qcow2.py "$TEST_IMG" set-feature-bit incompatible 3
+# to make sure the bit was actually set
+$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
+
+if $QEMU_IMG info "$TEST_IMG" >/dev/null 2>&1 ; then
+ echo "Error: The image opened successfully. The image must not be opened."
+fi
+
+echo
+echo "=== Testing zstd with incompatible bit unset ==="
+echo
+IMGOPTS='compression_type=zstd' _make_test_img 64M
+$PYTHON qcow2.py "$TEST_IMG" set-header incompatible_features 0
+# to make sure the bit was actually unset
+$PYTHON qcow2.py "$TEST_IMG" dump-header | grep incompatible_features
+
+if $QEMU_IMG info "$TEST_IMG" >/dev/null 2>&1 ; then
+ echo "Error: The image opened successfully. The image must not be opened."
+fi
+
+echo
+echo "=== Testing compression type values ==="
+echo
+# zlib=0
+IMGOPTS='compression_type=zlib' _make_test_img 64M
+peek_file_be "$TEST_IMG" 104 1
+echo
+
+# zstd=1
+IMGOPTS='compression_type=zstd' _make_test_img 64M
+peek_file_be "$TEST_IMG" 104 1
+echo
+
+echo
+echo "=== Testing simple reading and writing with zstd ==="
+echo
+IMGOPTS='compression_type=zstd' _make_test_img 64M
+$QEMU_IO -c "write -c -P 0xAC 64K 64K " "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c "read -P 0xAC 64K 64K " "$TEST_IMG" | _filter_qemu_io
+# read on the cluster boundaries
+$QEMU_IO -c "read -v 131070 8 " "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c "read -v 65534 8" "$TEST_IMG" | _filter_qemu_io
+
+echo
+echo "=== Testing adjacent clusters reading and writing with zstd ==="
+echo
+IMGOPTS='compression_type=zstd' _make_test_img 64M
+$QEMU_IO -c "write -c -P 0xAB 0 64K " "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c "write -c -P 0xAC 64K 64K " "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c "write -c -P 0xAD 128K 64K " "$TEST_IMG" | _filter_qemu_io
+
+$QEMU_IO -c "read -P 0xAB 0 64k " "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c "read -P 0xAC 64K 64k " "$TEST_IMG" | _filter_qemu_io
+$QEMU_IO -c "read -P 0xAD 128K 64k " "$TEST_IMG" | _filter_qemu_io
+
+echo
+echo "=== Testing incompressible cluster processing with zstd ==="
+echo
+# create a 2M image and fill it with 1M likely incompressible data
+# and 1M compressible data
+dd if=/dev/urandom of="$RAND_FILE" bs=1M count=1 seek=1
+QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS_NO_FMT" \
+$QEMU_IO -f raw -c "write -P 0xFA 0 1M" "$RAND_FILE" | _filter_qemu_io
+$QEMU_IMG convert -f raw -O $IMGFMT -c "$RAND_FILE" "$TEST_IMG" | _filter_qemu_io
+
+$QEMU_IMG convert -O $IMGFMT -c -o compression_type=zstd \
+ "$TEST_IMG" "$COMPR_IMG"
+$QEMU_IMG compare "$TEST_IMG" "$COMPR_IMG"
+
+# success, all done
+echo "*** done"
+rm -f $seq.full
+status=0
diff --git a/tests/qemu-iotests/287.out b/tests/qemu-iotests/287.out
new file mode 100644
index 0000000000..6b9dfb4af0
--- /dev/null
+++ b/tests/qemu-iotests/287.out
@@ -0,0 +1,67 @@
+QA output created by 287
+
+=== Testing compression type incompatible bit setting for zlib ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
+incompatible_features []
+
+=== Testing compression type incompatible bit setting for zstd ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
+incompatible_features [3]
+
+=== Testing zlib with incompatible bit set ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
+incompatible_features [3]
+
+=== Testing zstd with incompatible bit unset ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
+incompatible_features []
+
+=== Testing compression type values ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
+ 0
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
+ 1
+
+=== Testing simple reading and writing with zstd ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
+wrote 65536/65536 bytes at offset 65536
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 65536/65536 bytes at offset 65536
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+0001fffe: ac ac 00 00 00 00 00 00 ........
+read 8/8 bytes at offset 131070
+8 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+0000fffe: 00 00 ac ac ac ac ac ac ........
+read 8/8 bytes at offset 65534
+8 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+=== Testing adjacent clusters reading and writing with zstd ===
+
+Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=67108864
+wrote 65536/65536 bytes at offset 0
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 65536/65536 bytes at offset 65536
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+wrote 65536/65536 bytes at offset 131072
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 65536/65536 bytes at offset 0
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 65536/65536 bytes at offset 65536
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+read 65536/65536 bytes at offset 131072
+64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+
+=== Testing incompressible cluster processing with zstd ===
+
+1+0 records in
+1+0 records out
+wrote 1048576/1048576 bytes at offset 0
+1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Images are identical.
+*** done
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
index 435dccd5af..3bbe02c88d 100644
--- a/tests/qemu-iotests/group
+++ b/tests/qemu-iotests/group
@@ -294,6 +294,7 @@
283 auto quick
284 rw
286 rw quick
+287 auto quick
288 quick
289 rw quick
290 rw auto quick
--
2.17.0
On 21.04.20 10:11, Denis Plotnikov wrote:
> The test checks fulfilling qcow2 requirements for the compression
> type feature and zstd compression type operability.
>
> Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
> ---
> tests/qemu-iotests/287 | 146 +++++++++++++++++++++++++++++++++++++
> tests/qemu-iotests/287.out | 67 +++++++++++++++++
> tests/qemu-iotests/group | 1 +
> 3 files changed, 214 insertions(+)
> create mode 100755 tests/qemu-iotests/287
> create mode 100644 tests/qemu-iotests/287.out
>
> diff --git a/tests/qemu-iotests/287 b/tests/qemu-iotests/287
> new file mode 100755
> index 0000000000..156acc40ad
> --- /dev/null
> +++ b/tests/qemu-iotests/287
> @@ -0,0 +1,146 @@
> +#!/usr/bin/env bash
> +#
> +# Test case for an image using zstd compression
> +#
> +# Copyright (c) 2020 Virtuozzo International GmbH
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
> +#
> +
> +# creator
> +owner=dplotnikov@virtuozzo.com
> +
> +seq="$(basename $0)"
> +echo "QA output created by $seq"
> +
> +status=1 # failure is the default!
> +
> +# standard environment
> +. ./common.rc
> +. ./common.filter
> +
> +# This tests qocw2-specific low-level functionality
> +_supported_fmt qcow2
> +_supported_proto file
> +_supported_os Linux
This test doesn’t work with compat=0.10 (because we can’t store a
non-default compression type there) or data_file (because those don’t
support compression), so those options should be marked as unsupported.
(It does seem to work with any refcount_bits, though.)
> +
> +COMPR_IMG="$TEST_IMG.compressed"
> +RAND_FILE="$TEST_DIR/rand_data"
> +
> +_cleanup()
> +{
> + _cleanup_test_img
> + rm -f "$COMPR_IMG"
Using _rm_test_img() would be nicer. There shouldn’t be a functional
difference here because there’d only be one with external data files (I
think), which won’t work with this test, but still.
> + rm -f "$RAND_FILE"
> +}
> +trap "_cleanup; exit \$status" 0 1 2 3 15
> +
> +# for all the cases
> +CLUSTER_SIZE=65536
> +
> +# Check if we can run this test.
> +if IMGOPTS='compression_type=zstd' _make_test_img 64M |
> + grep "Invalid parameter 'zstd'"; then
> + _notrun "ZSTD is disabled"
> +fi
> +
> +echo
> +echo "=== Testing compression type incompatible bit setting for zlib ==="
> +echo
> +IMGOPTS='compression_type=zlib' _make_test_img 64M
Please use -o so user options are still considered.
(i.e., _make_test_img -o compression_type=zlib)
[...]
> +echo
> +echo "=== Testing incompressible cluster processing with zstd ==="
> +echo
> +# create a 2M image and fill it with 1M likely incompressible data
> +# and 1M compressible data
> +dd if=/dev/urandom of="$RAND_FILE" bs=1M count=1 seek=1
> +QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS_NO_FMT" \
> +$QEMU_IO -f raw -c "write -P 0xFA 0 1M" "$RAND_FILE" | _filter_qemu_io
> +$QEMU_IMG convert -f raw -O $IMGFMT -c "$RAND_FILE" "$TEST_IMG" | _filter_qemu_io
> +
> +$QEMU_IMG convert -O $IMGFMT -c -o compression_type=zstd \
> + "$TEST_IMG" "$COMPR_IMG"
Again, it would be nice to not discard the user-supplied options here,
and maybe it would also be nicer to explicitly pass the compression type
for the first convert, too. So we’d use
-o "$(_optstr_add "$IMGOPTS" "compression_type=zlib")"
for the first convert, and
-o "$(_optstr_add "$IMGOPTS" "compression_type=zstd")"
for the second one.
Max
On 27.04.2020 16:29, Max Reitz wrote:
> On 21.04.20 10:11, Denis Plotnikov wrote:
>> The test checks fulfilling qcow2 requirements for the compression
>> type feature and zstd compression type operability.
>>
>> Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
>> ---
>> tests/qemu-iotests/287 | 146 +++++++++++++++++++++++++++++++++++++
>> tests/qemu-iotests/287.out | 67 +++++++++++++++++
>> tests/qemu-iotests/group | 1 +
>> 3 files changed, 214 insertions(+)
>> create mode 100755 tests/qemu-iotests/287
>> create mode 100644 tests/qemu-iotests/287.out
>>
>> diff --git a/tests/qemu-iotests/287 b/tests/qemu-iotests/287
>> new file mode 100755
>> index 0000000000..156acc40ad
>> --- /dev/null
>> +++ b/tests/qemu-iotests/287
>> @@ -0,0 +1,146 @@
>> +#!/usr/bin/env bash
>> +#
>> +# Test case for an image using zstd compression
>> +#
>> +# Copyright (c) 2020 Virtuozzo International GmbH
>> +#
>> +# This program is free software; you can redistribute it and/or modify
>> +# it under the terms of the GNU General Public License as published by
>> +# the Free Software Foundation; either version 2 of the License, or
>> +# (at your option) any later version.
>> +#
>> +# This program is distributed in the hope that it will be useful,
>> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
>> +# GNU General Public License for more details.
>> +#
>> +# You should have received a copy of the GNU General Public License
>> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
>> +#
>> +
>> +# creator
>> +owner=dplotnikov@virtuozzo.com
>> +
>> +seq="$(basename $0)"
>> +echo "QA output created by $seq"
>> +
>> +status=1 # failure is the default!
>> +
>> +# standard environment
>> +. ./common.rc
>> +. ./common.filter
>> +
>> +# This tests qocw2-specific low-level functionality
>> +_supported_fmt qcow2
>> +_supported_proto file
>> +_supported_os Linux
> This test doesn’t work with compat=0.10 (because we can’t store a
> non-default compression type there) or data_file (because those don’t
> support compression), so those options should be marked as unsupported.
>
> (It does seem to work with any refcount_bits, though.)
Could I ask how to achieve that?
I can't find any _supported_* related.
Denis
>
>> +
>> +COMPR_IMG="$TEST_IMG.compressed"
>> +RAND_FILE="$TEST_DIR/rand_data"
>> +
>> +_cleanup()
>> +{
>> + _cleanup_test_img
>> + rm -f "$COMPR_IMG"
> Using _rm_test_img() would be nicer. There shouldn’t be a functional
> difference here because there’d only be one with external data files (I
> think), which won’t work with this test, but still.
>
>> + rm -f "$RAND_FILE"
>> +}
>> +trap "_cleanup; exit \$status" 0 1 2 3 15
>> +
>> +# for all the cases
>> +CLUSTER_SIZE=65536
>> +
>> +# Check if we can run this test.
>> +if IMGOPTS='compression_type=zstd' _make_test_img 64M |
>> + grep "Invalid parameter 'zstd'"; then
>> + _notrun "ZSTD is disabled"
>> +fi
>> +
>> +echo
>> +echo "=== Testing compression type incompatible bit setting for zlib ==="
>> +echo
>> +IMGOPTS='compression_type=zlib' _make_test_img 64M
> Please use -o so user options are still considered.
>
> (i.e., _make_test_img -o compression_type=zlib)
>
> [...]
>
>> +echo
>> +echo "=== Testing incompressible cluster processing with zstd ==="
>> +echo
>> +# create a 2M image and fill it with 1M likely incompressible data
>> +# and 1M compressible data
>> +dd if=/dev/urandom of="$RAND_FILE" bs=1M count=1 seek=1
>> +QEMU_IO_OPTIONS="$QEMU_IO_OPTIONS_NO_FMT" \
>> +$QEMU_IO -f raw -c "write -P 0xFA 0 1M" "$RAND_FILE" | _filter_qemu_io
>> +$QEMU_IMG convert -f raw -O $IMGFMT -c "$RAND_FILE" "$TEST_IMG" | _filter_qemu_io
>> +
>> +$QEMU_IMG convert -O $IMGFMT -c -o compression_type=zstd \
>> + "$TEST_IMG" "$COMPR_IMG"
> Again, it would be nice to not discard the user-supplied options here,
> and maybe it would also be nicer to explicitly pass the compression type
> for the first convert, too. So we’d use
> -o "$(_optstr_add "$IMGOPTS" "compression_type=zlib")"
> for the first convert, and
> -o "$(_optstr_add "$IMGOPTS" "compression_type=zstd")"
> for the second one.
>
> Max
>
On 28.04.20 13:41, Denis Plotnikov wrote: > > > On 27.04.2020 16:29, Max Reitz wrote: >> On 21.04.20 10:11, Denis Plotnikov wrote: >>> The test checks fulfilling qcow2 requirements for the compression >>> type feature and zstd compression type operability. >>> >>> Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com> >>> --- >>> tests/qemu-iotests/287 | 146 +++++++++++++++++++++++++++++++++++++ >>> tests/qemu-iotests/287.out | 67 +++++++++++++++++ >>> tests/qemu-iotests/group | 1 + >>> 3 files changed, 214 insertions(+) >>> create mode 100755 tests/qemu-iotests/287 >>> create mode 100644 tests/qemu-iotests/287.out >>> >>> diff --git a/tests/qemu-iotests/287 b/tests/qemu-iotests/287 >>> new file mode 100755 >>> index 0000000000..156acc40ad >>> --- /dev/null >>> +++ b/tests/qemu-iotests/287 >>> @@ -0,0 +1,146 @@ >>> +#!/usr/bin/env bash >>> +# >>> +# Test case for an image using zstd compression >>> +# >>> +# Copyright (c) 2020 Virtuozzo International GmbH >>> +# >>> +# This program is free software; you can redistribute it and/or modify >>> +# it under the terms of the GNU General Public License as published by >>> +# the Free Software Foundation; either version 2 of the License, or >>> +# (at your option) any later version. >>> +# >>> +# This program is distributed in the hope that it will be useful, >>> +# but WITHOUT ANY WARRANTY; without even the implied warranty of >>> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >>> +# GNU General Public License for more details. >>> +# >>> +# You should have received a copy of the GNU General Public License >>> +# along with this program. If not, see <http://www.gnu.org/licenses/>. >>> +# >>> + >>> +# creator >>> +owner=dplotnikov@virtuozzo.com >>> + >>> +seq="$(basename $0)" >>> +echo "QA output created by $seq" >>> + >>> +status=1 # failure is the default! >>> + >>> +# standard environment >>> +. ./common.rc >>> +. ./common.filter >>> + >>> +# This tests qocw2-specific low-level functionality >>> +_supported_fmt qcow2 >>> +_supported_proto file >>> +_supported_os Linux >> This test doesn’t work with compat=0.10 (because we can’t store a >> non-default compression type there) or data_file (because those don’t >> support compression), so those options should be marked as unsupported. >> >> (It does seem to work with any refcount_bits, though.) > > Could I ask how to achieve that? > I can't find any _supported_* related. It’s _unsupported_imgopts. Max
On 4/28/20 7:55 AM, Max Reitz wrote: >>>> +# This tests qocw2-specific low-level functionality >>>> +_supported_fmt qcow2 >>>> +_supported_proto file >>>> +_supported_os Linux >>> This test doesn’t work with compat=0.10 (because we can’t store a >>> non-default compression type there) or data_file (because those don’t >>> support compression), so those options should be marked as unsupported. >>> >>> (It does seem to work with any refcount_bits, though.) >> >> Could I ask how to achieve that? >> I can't find any _supported_* related. > > > It’s _unsupported_imgopts. Test 036 is an example of this. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
On 28.04.2020 16:01, Eric Blake wrote: > On 4/28/20 7:55 AM, Max Reitz wrote: > >>>>> +# This tests qocw2-specific low-level functionality >>>>> +_supported_fmt qcow2 >>>>> +_supported_proto file >>>>> +_supported_os Linux >>>> This test doesn’t work with compat=0.10 (because we can’t store a >>>> non-default compression type there) or data_file (because those don’t >>>> support compression), so those options should be marked as >>>> unsupported. >>>> >>>> (It does seem to work with any refcount_bits, though.) >>> >>> Could I ask how to achieve that? >>> I can't find any _supported_* related. >> >> >> It’s _unsupported_imgopts. > > Test 036 is an example of this. Max, Eric Thanks! Denis > >
21.04.2020 11:11, Denis Plotnikov wrote: > The test checks fulfilling qcow2 requirements for the compression > type feature and zstd compression type operability. > > Signed-off-by: Denis Plotnikov<dplotnikov@virtuozzo.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Tested-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> -- Best regards, Vladimir
© 2016 - 2026 Red Hat, Inc.