qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 3/3] iotests: Add test for external image tru


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v3 3/3] iotests: Add test for external image truncation
Date: Wed, 22 Oct 2014 10:50:23 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

On 10/22/2014 09:57 AM, Max Reitz wrote:
> It should not be happening, but it is possible to truncate an image
> outside of qemu while qemu is running (or any of the qemu tools using
> the block layer. raw_co_get_block_status() should not break then.
> 
> Signed-off-by: Max Reitz <address@hidden>
> ---
>  tests/qemu-iotests/102     | 15 +++++++++++++++
>  tests/qemu-iotests/102.out |  9 +++++++++
>  2 files changed, 24 insertions(+)
> 
> diff --git a/tests/qemu-iotests/102 b/tests/qemu-iotests/102
> index 34b363f..027198b 100755
> --- a/tests/qemu-iotests/102
> +++ b/tests/qemu-iotests/102
> @@ -58,6 +58,21 @@ truncate -s $((5 * 64 * 1024)) "$TEST_IMG"
>  $QEMU_IO -c map "$TEST_IMG"
>  $QEMU_IMG map "$TEST_IMG"
>  
> +echo
> +echo '=== Testing map on an image file truncated outside of qemu ==='
> +echo
> +
> +# Same as above, only now we concurrently truncate and map the image
> +_make_test_img $IMG_SIZE
> +$QEMU_IO -c 'write 0 64k' "$TEST_IMG" | _filter_qemu_io
> +
> +(sleep 0.2; $QEMU_IO -c map "$TEST_IMG"; $QEMU_IMG map "$TEST_IMG") &

Should you use '&&' instead of ';' between the three operations, to
ensure that you can detect failure of the overall background subshell? [1]

Fractional sleep is a GNU extension, and won't work on BSD.  It adds .8
seconds to make this sleep 1, but the extra portability may be worth it.
 It also makes the test more robust, and less likely to fail a race in a
heavily-loaded tester.  Then again, it is not the first use of
fractional sleep in the testsuite.

Hmm - does the blkdebug driver allow us to pause qemu operation to
reliably allow an external action callback, and then resume qemu?  That
might be less prone to race failure, as well as reducing the need to
blindly sleep for a fixed amount of time.

> +truncate -s $((5 * 64 * 1024)) "$TEST_IMG"

truncate is a GNU program, not necessarily available on all platforms;
but this is not the first test using it.

> +# To be sure the image has been truncated before $QEMU_IO and $QEMU_IMG run
> +echo '--- truncated ---'
> +
> +sleep 0.3
> +
>  # success, all done

I think you should have a 'wait' here to reap the background child
process before declaring this test all done.  Particularly if you take
my advice above[1] about detecting errors.

Looks like a good start, but I'm worried about false positives if you
can't guarantee some timing between actions.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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