Re: [RFC 4/4] iotests: test the zoned format feature for qcow2 file
On Mon, Jun 05, 2023 at 06:41:08PM +0800, Sam Li wrote: > The zoned format feature can be tested by: > $ tests/qemu-iotests/check zoned-qcow2 > > Signed-off-by: Sam Li > --- > tests/qemu-iotests/tests/zoned-qcow2 | 110 +++ > tests/qemu-iotests/tests/zoned-qcow2.out | 87 ++ > 2 files changed, 197 insertions(+) > create mode 100755 tests/qemu-iotests/tests/zoned-qcow2 > create mode 100644 tests/qemu-iotests/tests/zoned-qcow2.out > > diff --git a/tests/qemu-iotests/tests/zoned-qcow2 > b/tests/qemu-iotests/tests/zoned-qcow2 > new file mode 100755 > index 00..6aa5ab3a03 > --- /dev/null > +++ b/tests/qemu-iotests/tests/zoned-qcow2 > @@ -0,0 +1,110 @@ > +#!/usr/bin/env bash > +# > +# Test zone management operations for qcow2 file. > +# > + > +seq="$(basename $0)" > +echo "QA output created by $seq" > +status=1 # failure is the default! > + > +file_name="zbc.qcow2" Please use $TEST_IMG_FILE instead of defining your own variable here. (TEST_IMG_FILE is already defined in common.rc.) > +_cleanup() > +{ > + _cleanup_test_img > + _rm_test_img "$file_name" > +} > +trap "_cleanup; exit \$status" 0 1 2 3 15 > + > +# get standard environment, filters and checks > +. ../common.rc > +. ../common.filter > +. ../common.qemu > + > +# This test only runs on Linux hosts with qcow2 image files. Then you need to add: _supported_fmt qcow2 > +_supported_proto file > +_supported_os Linux Is this test really Linux-specific? > + > +echo > +echo "=== Initial image setup ===" > +echo > + > +$QEMU_IMG create -f qcow2 $file_name -o size=768M -o zone_size=64M \ > +-o zone_capacity=64M -o zone_nr_conv=0 -o max_append_sectors=512 \ > +-o max_open_zones=0 -o max_active_zones=0 -o zoned_profile=zbc > + > +IMG="--image-opts -n driver=qcow2,file.driver=file,file.filename=$file_name" > +QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT > + > +echo > +echo "=== Testing a qcow2 img with zoned format ===" > +echo > +echo "case 1: if the operations work" > + > +echo "(1) report the first zone:" > +$QEMU_IO $IMG -c "zrp 0 1" > +echo > +echo "report the first 10 zones" > +$QEMU_IO $IMG -c "zrp 0 10" > +echo > +echo "report the last zone:" > +$QEMU_IO $IMG -c "zrp 0x2C00 2" # 0x2C00 / 512 = 0x16 > +echo > +echo > +echo "(2) opening the first zone" > +$QEMU_IO $IMG -c "zo 0 0x400" # 0x400 / 512 = 0x2 > +echo "report after:" > +$QEMU_IO $IMG -c "zrp 0 1" > +echo > +echo "opening the second zone" > +$QEMU_IO $IMG -c "zo 0x400 0x400" > +echo "report after:" > +$QEMU_IO $IMG -c "zrp 0x400 1" > +echo > +echo "opening the last zone" > +$QEMU_IO $IMG -c "zo 0x2C00 0x400" > +echo "report after:" > +$QEMU_IO $IMG -c "zrp 0x2C00 2" > +echo > +echo > +echo "(3) closing the first zone" > +$QEMU_IO $IMG -c "zc 0 0x400" > +echo "report after:" > +$QEMU_IO $IMG -c "zrp 0 1" > +echo > +echo "closing the last zone" > +$QEMU_IO $IMG -c "zc 0x3e7000 0x400" > +echo "report after:" > +$QEMU_IO $IMG -c "zrp 0x3e7000 2" > +echo > +echo > +echo "(4) finishing the second zone" > +$QEMU_IO $IMG -c "zf 0x400 0x400" > +echo "After finishing a zone:" > +$QEMU_IO $IMG -c "zrp 0x400 1" > +echo > +echo > +echo "(5) resetting the second zone" > +$QEMU_IO $IMG -c "zrs 0x400 0x400" > +echo "After resetting a zone:" > +$QEMU_IO $IMG -c "zrp 0x400 1" > +echo > +echo > +echo "(6) append write" # the physical block size of the device is 4096 > +$QEMU_IO $IMG -c "zrp 0 1" > +$QEMU_IO $IMG -c "zap -p 0 0x1000 0x2000" > +echo "After appending the first zone firstly:" > +$QEMU_IO $IMG -c "zrp 0 1" > +$QEMU_IO $IMG -c "zap -p 0 0x1000 0x2000" > +echo "After appending the first zone secondly:" > +$QEMU_IO $IMG -c "zrp 0 1" > +$QEMU_IO $IMG -c "zap -p 0x400 0x1000 0x2000" > +echo "After appending the second zone firstly:" > +$QEMU_IO $IMG -c "zrp 0x400 1" > +$QEMU_IO $IMG -c "zap -p 0x400 0x1000 0x2000" > +echo "After appending the second zone secondly:" > +$QEMU_IO $IMG -c "zrp 0x400 1" > + > +# success, all done > +echo "*** done" > +rm -f $seq.full > +status=0 > diff --git a/tests/qemu-iotests/tests/zoned-qcow2.out > b/tests/qemu-iotests/tests/zoned-qcow2.out > new file mode 100644 > index 00..288bceffc4 > --- /dev/null > +++ b/tests/qemu-iotests/tests/zoned-qcow2.out > @@ -0,0 +1,87 @@ > +QA output created by zoned-qcow2 > + > +=== Initial image setup === > + > +Formatting 'zbc.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off > compression_type=zlib zoned_profile=zbc zone_size=67108864 > zone_capacity=67108864 zone_nr_conv=0 max_append_sectors=512 > max_active_zones=0 max_open_zones=0 size=805306368 lazy_refcounts=off > refcount_bits=16 > + > +=== Testing a qcow2 img with zoned format === > + > +case 1: if the operations work > +(1) report the first zone: > +start: 0x0, len 0x2, cap 0x2, wptr 0x0, zcond:1, [type: 2] > + > +report the first 10 zones > +start: 0x0, len 0x2, cap 0x2, wptr 0x0, zcond:1, [type:
[RFC 4/4] iotests: test the zoned format feature for qcow2 file
The zoned format feature can be tested by: $ tests/qemu-iotests/check zoned-qcow2 Signed-off-by: Sam Li --- tests/qemu-iotests/tests/zoned-qcow2 | 110 +++ tests/qemu-iotests/tests/zoned-qcow2.out | 87 ++ 2 files changed, 197 insertions(+) create mode 100755 tests/qemu-iotests/tests/zoned-qcow2 create mode 100644 tests/qemu-iotests/tests/zoned-qcow2.out diff --git a/tests/qemu-iotests/tests/zoned-qcow2 b/tests/qemu-iotests/tests/zoned-qcow2 new file mode 100755 index 00..6aa5ab3a03 --- /dev/null +++ b/tests/qemu-iotests/tests/zoned-qcow2 @@ -0,0 +1,110 @@ +#!/usr/bin/env bash +# +# Test zone management operations for qcow2 file. +# + +seq="$(basename $0)" +echo "QA output created by $seq" +status=1 # failure is the default! + +file_name="zbc.qcow2" +_cleanup() +{ + _cleanup_test_img + _rm_test_img "$file_name" +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ../common.rc +. ../common.filter +. ../common.qemu + +# This test only runs on Linux hosts with qcow2 image files. +_supported_proto file +_supported_os Linux + +echo +echo "=== Initial image setup ===" +echo + +$QEMU_IMG create -f qcow2 $file_name -o size=768M -o zone_size=64M \ +-o zone_capacity=64M -o zone_nr_conv=0 -o max_append_sectors=512 \ +-o max_open_zones=0 -o max_active_zones=0 -o zoned_profile=zbc + +IMG="--image-opts -n driver=qcow2,file.driver=file,file.filename=$file_name" +QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT + +echo +echo "=== Testing a qcow2 img with zoned format ===" +echo +echo "case 1: if the operations work" + +echo "(1) report the first zone:" +$QEMU_IO $IMG -c "zrp 0 1" +echo +echo "report the first 10 zones" +$QEMU_IO $IMG -c "zrp 0 10" +echo +echo "report the last zone:" +$QEMU_IO $IMG -c "zrp 0x2C00 2" # 0x2C00 / 512 = 0x16 +echo +echo +echo "(2) opening the first zone" +$QEMU_IO $IMG -c "zo 0 0x400" # 0x400 / 512 = 0x2 +echo "report after:" +$QEMU_IO $IMG -c "zrp 0 1" +echo +echo "opening the second zone" +$QEMU_IO $IMG -c "zo 0x400 0x400" +echo "report after:" +$QEMU_IO $IMG -c "zrp 0x400 1" +echo +echo "opening the last zone" +$QEMU_IO $IMG -c "zo 0x2C00 0x400" +echo "report after:" +$QEMU_IO $IMG -c "zrp 0x2C00 2" +echo +echo +echo "(3) closing the first zone" +$QEMU_IO $IMG -c "zc 0 0x400" +echo "report after:" +$QEMU_IO $IMG -c "zrp 0 1" +echo +echo "closing the last zone" +$QEMU_IO $IMG -c "zc 0x3e7000 0x400" +echo "report after:" +$QEMU_IO $IMG -c "zrp 0x3e7000 2" +echo +echo +echo "(4) finishing the second zone" +$QEMU_IO $IMG -c "zf 0x400 0x400" +echo "After finishing a zone:" +$QEMU_IO $IMG -c "zrp 0x400 1" +echo +echo +echo "(5) resetting the second zone" +$QEMU_IO $IMG -c "zrs 0x400 0x400" +echo "After resetting a zone:" +$QEMU_IO $IMG -c "zrp 0x400 1" +echo +echo +echo "(6) append write" # the physical block size of the device is 4096 +$QEMU_IO $IMG -c "zrp 0 1" +$QEMU_IO $IMG -c "zap -p 0 0x1000 0x2000" +echo "After appending the first zone firstly:" +$QEMU_IO $IMG -c "zrp 0 1" +$QEMU_IO $IMG -c "zap -p 0 0x1000 0x2000" +echo "After appending the first zone secondly:" +$QEMU_IO $IMG -c "zrp 0 1" +$QEMU_IO $IMG -c "zap -p 0x400 0x1000 0x2000" +echo "After appending the second zone firstly:" +$QEMU_IO $IMG -c "zrp 0x400 1" +$QEMU_IO $IMG -c "zap -p 0x400 0x1000 0x2000" +echo "After appending the second zone secondly:" +$QEMU_IO $IMG -c "zrp 0x400 1" + +# success, all done +echo "*** done" +rm -f $seq.full +status=0 diff --git a/tests/qemu-iotests/tests/zoned-qcow2.out b/tests/qemu-iotests/tests/zoned-qcow2.out new file mode 100644 index 00..288bceffc4 --- /dev/null +++ b/tests/qemu-iotests/tests/zoned-qcow2.out @@ -0,0 +1,87 @@ +QA output created by zoned-qcow2 + +=== Initial image setup === + +Formatting 'zbc.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib zoned_profile=zbc zone_size=67108864 zone_capacity=67108864 zone_nr_conv=0 max_append_sectors=512 max_active_zones=0 max_open_zones=0 size=805306368 lazy_refcounts=off refcount_bits=16 + +=== Testing a qcow2 img with zoned format === + +case 1: if the operations work +(1) report the first zone: +start: 0x0, len 0x2, cap 0x2, wptr 0x0, zcond:1, [type: 2] + +report the first 10 zones +start: 0x0, len 0x2, cap 0x2, wptr 0x0, zcond:1, [type: 2] +start: 0x2, len 0x2, cap 0x2, wptr 0x2, zcond:1, [type: 2] +start: 0x4, len 0x2, cap 0x2, wptr 0x4, zcond:1, [type: 2] +start: 0x6, len 0x2, cap 0x2, wptr 0x6, zcond:1, [type: 2] +start: 0x8, len 0x2, cap 0x2, wptr 0x8, zcond:1, [type: 2] +start: 0xa, len 0x2, cap 0x2, wptr 0xa, zcond:1, [type: 2] +start: 0xc, len 0x2, cap 0x2, wptr 0xc, zcond:1, [type: 2] +start: 0xe, len 0x2, cap 0x2, wptr 0xe, zcond:1, [type: 2] +start: 0x10, len 0x2,