On 17.03.20 19:16, Alberto Garcia wrote:
> Signed-off-by: Alberto Garcia <be...@igalia.com>
> ---
>  tests/qemu-iotests/271     | 359 +++++++++++++++++++++++++++++++++++++
>  tests/qemu-iotests/271.out | 244 +++++++++++++++++++++++++
>  tests/qemu-iotests/group   |   1 +
>  3 files changed, 604 insertions(+)
>  create mode 100755 tests/qemu-iotests/271
>  create mode 100644 tests/qemu-iotests/271.out
> 
> diff --git a/tests/qemu-iotests/271 b/tests/qemu-iotests/271
> new file mode 100755
> index 0000000000..48f4d8d8ce
> --- /dev/null
> +++ b/tests/qemu-iotests/271

[...]

> +# Compare the bitmap of an extended L2 entry against an expected value
> +_verify_l2_bitmap()
> +{
> +    entry_no="$1"        # L2 entry number, starting from 0
> +    expected_alloc="$2"  # Space-separated list of allocated subcluster 
> indexes
> +    expected_zero="$3"   # Space-separated list of zero subcluster indexes
> +
> +    offset=$(($l2_offset + $entry_no * 16))
> +    entry=`peek_file_be "$TEST_IMG" $offset 8`
> +    offset=$(($offset + 8))
> +    bitmap=`peek_file_be "$TEST_IMG" $offset 8`
> +
> +    expected_bitmap=0
> +    for bit in $expected_alloc; do
> +        expected_bitmap=$(($expected_bitmap | (1 << $bit)))
> +    done
> +    for bit in $expected_zero; do
> +        expected_bitmap=$(($expected_bitmap | (1 << (32 + $bit))))
> +    done
> +    expected_bitmap=`printf "%llu" $expected_bitmap`
> +
> +    printf "L2 entry #%d: 0x%016lx %016lx\n" "$entry_no" "$entry" "$bitmap"
> +    if [ "$bitmap" != "$expected_bitmap" ]; then
> +        printf "ERROR: expecting bitmap       0x%016lx\n" "$expected_bitmap"
> +    fi
> +}

Thanks! :)

[...]

> +# Test that writing to an image with subclusters produces the expected
> +# results, in images with and without backing files
> +for use_backing_file in yes no; do

[...]

> +    ### Write subcluster #31-#34 (cluster overlap) ###

#31-#34, I think.

> +    alloc="`seq 0 9` 16 31"; zero=""
> +    _test_write 'write -q -P 8 63k 4k' "$alloc" "$zero"
> +    alloc="0 1" ; zero=""
> +    _verify_l2_bitmap 1 "$alloc" "$zero"

[...]

> +    ### Partially zeroize an unallocated cluster (#3)
> +    if [ "$use_backing_file" = "yes" ]; then
> +        alloc="`seq 0 15`"; zero=""

Isn’t this a TODO?  (I.e., ideally we’d want the first 16 subclusters to
be zero, and the last 16 subclusters to be unallocated, right?)

(I’m asking because you did raise a TODO for the “Zero subcluster #1” test)

> +    else
> +        alloc=""; zero="`seq 0 31`"
> +    fi
> +    _test_write 'write -q -z 192k 32k' "$alloc" "$zero" 3
> +done

[...]

> +# Test that corrupted L2 entries are detected in both read and write
> +# operations
> +for corruption_test_cmd in read write; do

[...]

> +    echo
> +    echo "### Compressed cluster with subcluster bitmap != 0 - 
> $corruption_test_cmd test ###"
> +    echo
> +    # We actually don't consider this a corrupted image.
> +    # The bitmap in compressed clusters is unused so QEMU should just ignore 
> it.
> +    _make_test_img 1M
> +    $QEMU_IO -c 'write -q -P 11 -c 0 64k' "$TEST_IMG"
> +    poke_file "$TEST_IMG" $(($l2_offset+11)) "\x01\x01"
> +    alloc="24"; zero="0"
> +    _verify_l2_bitmap 0 "$alloc" "$zero"
> +    $QEMU_IO -c "$corruption_test_cmd -P 11 0 64k" "$TEST_IMG" | 
> _filter_qemu_io

It might be interesting to see the bitmap after the write, i.e., that
it’s just been ignored.  Not necessary, though; the fact that the read
worked without error tells for sure that qemu ignores the bitmap.

> +done
> +
> +echo
> +echo "### Image creation options ###"
> +echo
> +echo "# cluster_size < 16k"
> +IMGOPTS="extended_l2=on,cluster_size=8k" _make_test_img 1M
> +
> +echo "# backing file and preallocation=metadata"
> +IMGOPTS="extended_l2=on,preallocation=metadata" _make_test_img -b 
> "$TEST_IMG.backing" 1M

TODO?

> +
> +echo "# backing file and preallocation=falloc"
> +IMGOPTS="extended_l2=on,preallocation=falloc" _make_test_img -b 
> "$TEST_IMG.backing" 1M
> +
> +echo "# backing file and preallocation=full"
> +IMGOPTS="extended_l2=on,preallocation=full" _make_test_img -b 
> "$TEST_IMG.backing" 1M
> +
> +echo
> +echo "### qemu-img measure ###"
> +echo
> +echo "# 512MB, extended_l2=off" # This needs one L2 table
> +$QEMU_IMG measure --size 512M -O qcow2 -o extended_l2=off
> +echo "# 512MB, extended_l2=on"  # This needs two L2 tables
> +$QEMU_IMG measure --size 512M -O qcow2 -o extended_l2=on
> +
> +echo "# 16K clusters, 64GB, extended_l2=off" # This needs one L1 table

You mean one full L1 table cluster?

> +$QEMU_IMG measure --size 64G -O qcow2 -o cluster_size=16k,extended_l2=off
> +echo "# 16K clusters, 64GB, extended_l2=on"  # This needs two L2 tables

And two full L1 table clusters?

Max

> +$QEMU_IMG measure --size 64G -O qcow2 -o cluster_size=16k,extended_l2=on
> +
> +echo "# 8k clusters" # This should fail
> +$QEMU_IMG measure --size 1M -O qcow2 -o cluster_size=8k,extended_l2=on
> +
> +echo "# 1024 TB" # Maximum allowed size with extended_l2=on and 64K clusters
> +$QEMU_IMG measure --size 1024T -O qcow2 -o extended_l2=on
> +echo "# 1025 TB" # This should fail
> +$QEMU_IMG measure --size 1025T -O qcow2 -o extended_l2=on
> +
> +# success, all done
> +echo "*** done"
> +rm -f $seq.full
> +status=0
> +

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to