qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [Qemu-devel] [PATCH v2 09/11] iotests: Convert to preal


From: Max Reitz
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v2 09/11] iotests: Convert to preallocated encrypted qcow2
Date: Thu, 25 Jul 2019 18:27:17 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2

On 25.07.19 17:30, Maxim Levitsky wrote:
> On Wed, 2019-07-24 at 19:12 +0200, Max Reitz wrote:
>> Add a test case for converting an empty image (which only returns zeroes
>> when read) to a preallocated encrypted qcow2 image.
>> qcow2_has_zero_init() should return 0 then, thus forcing qemu-img
>> convert to create zero clusters.
>>
>> Signed-off-by: Max Reitz <address@hidden>
>> Acked-by: Stefano Garzarella <address@hidden>
>> Tested-by: Stefano Garzarella <address@hidden>
>> ---
>>  tests/qemu-iotests/188     | 20 +++++++++++++++++++-
>>  tests/qemu-iotests/188.out |  4 ++++
>>  2 files changed, 23 insertions(+), 1 deletion(-)
>>
>> diff --git a/tests/qemu-iotests/188 b/tests/qemu-iotests/188
>> index be7278aa65..afca44df54 100755
>> --- a/tests/qemu-iotests/188
>> +++ b/tests/qemu-iotests/188
>> @@ -48,7 +48,7 @@ SECRETALT="secret,id=sec0,data=platypus"
>>  
>>  _make_test_img --object $SECRET -o 
>> "encrypt.format=luks,encrypt.key-secret=sec0,encrypt.iter-time=10" $size
>>  
>> -IMGSPEC="driver=$IMGFMT,file.filename=$TEST_IMG,encrypt.key-secret=sec0"
>> +IMGSPEC="driver=$IMGFMT,encrypt.key-secret=sec0,file.filename=$TEST_IMG"
> This change I think doesn't change anything
> 
>>  
>>  QEMU_IO_OPTIONS=$QEMU_IO_OPTIONS_NO_FMT
>>  
>> @@ -68,6 +68,24 @@ echo
>>  echo "== verify open failure with wrong password =="
>>  $QEMU_IO --object $SECRETALT -c "read -P 0xa 0 $size" --image-opts $IMGSPEC 
>> | _filter_qemu_io | _filter_testdir
>>  
>> +_cleanup_test_img
>> +
>> +echo
>> +echo "== verify that has_zero_init returns false when preallocating =="
>> +
>> +# Empty source file
>> +if [ -n "$TEST_IMG_FILE" ]; then
>> +    TEST_IMG_FILE="${TEST_IMG_FILE}.orig" _make_test_img $size
>> +else
>> +    TEST_IMG="${TEST_IMG}.orig" _make_test_img $size
>> +fi
> 
> I wonder why do we have TEST_IMG_FILE and TEST_IMG, I don't know iotests well 
> enough
> From the quick look at the code, the TEST_IMG_FILE is an actual file, while 
> TEST_IMG can
> be various URL like address.

In theory, $TEST_IMG is what you give to the various qemu commands for
what you want to test.  It can be a URL, a plain path, or even in option
syntax (think file.filename=$TEST_IMG_FILE).  $TEST_IMG_FILE points to
the actual file on the local filesystem.

In practice, $TEST_IMG_FILE can be empty and then you only have
$TEST_IMG to work with.  Also, many tests only support the file protocol
anyway, which is exactly one such case, so they just use $TEST_IMG all
the time.

Max

>> +
>> +$QEMU_IMG convert -O "$IMGFMT" --object $SECRET \
>> +    -o 
>> "encrypt.format=luks,encrypt.key-secret=sec0,encrypt.iter-time=10,preallocation=metadata"
>>  \
>> +    "${TEST_IMG}.orig" "$TEST_IMG"
>> +
>> +$QEMU_IMG compare --object $SECRET --image-opts "${IMGSPEC}.orig" "$IMGSPEC"
>> +
>>  
>>  # success, all done
>>  echo "*** done"
>> diff --git a/tests/qemu-iotests/188.out b/tests/qemu-iotests/188.out
>> index 97b1402671..c568ef3701 100644
>> --- a/tests/qemu-iotests/188.out
>> +++ b/tests/qemu-iotests/188.out
>> @@ -15,4 +15,8 @@ read 16777216/16777216 bytes at offset 0
>>  
>>  == verify open failure with wrong password ==
>>  qemu-io: can't open: Invalid password, cannot unlock any keyslot
>> +
>> +== verify that has_zero_init returns false when preallocating ==
>> +Formatting 'TEST_DIR/t.IMGFMT.orig', fmt=IMGFMT size=16777216
>> +Images are identical.
>>  *** done
> 
> Reviewed-by: Maxim Levitsky <address@hidden>
> Best regards,
>       Maxim Levitsky
> 


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]