From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60030) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xgz7K-0004FC-1u for qemu-devel@nongnu.org; Wed, 22 Oct 2014 12:50:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xgz7F-0006BA-3B for qemu-devel@nongnu.org; Wed, 22 Oct 2014 12:50:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18878) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xgz7E-0006B0-Pr for qemu-devel@nongnu.org; Wed, 22 Oct 2014 12:50:28 -0400 Message-ID: <5447E04F.8020003@redhat.com> Date: Wed, 22 Oct 2014 10:50:23 -0600 From: Eric Blake MIME-Version: 1.0 References: <1413993434-11816-1-git-send-email-mreitz@redhat.com> <1413993434-11816-4-git-send-email-mreitz@redhat.com> In-Reply-To: <1413993434-11816-4-git-send-email-mreitz@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="GQCQaj70Crmx7W2cOj4Jjln9xT1MP1b8c" Subject: Re: [Qemu-devel] [PATCH v3 3/3] iotests: Add test for external image truncation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz , qemu-devel@nongnu.org Cc: Kevin Wolf , =?UTF-8?B?QmVub8OudCBDYW5ldA==?= , Stefan Hajnoczi This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --GQCQaj70Crmx7W2cOj4Jjln9xT1MP1b8c Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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. >=20 > Signed-off-by: Max Reitz > --- > tests/qemu-iotests/102 | 15 +++++++++++++++ > tests/qemu-iotests/102.out | 9 +++++++++ > 2 files changed, 24 insertions(+) >=20 > 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" > =20 > +echo > +echo '=3D=3D=3D Testing map on an image file truncated outside of qemu= =3D=3D=3D' > +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_IM= G 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. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --GQCQaj70Crmx7W2cOj4Jjln9xT1MP1b8c Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg iQEcBAEBCAAGBQJUR+BPAAoJEKeha0olJ0NqFccH/iEjedWvpw9U1dKhqoymPGZt l8EJTn1YNyrDHYQc1RgJZIUr4IX7GJ2hEcbYn9N449cUZOnmCZk41VdSJBGDkk7A oLVfvDAEZNoYd/I2AOs/p2JGzAmDhwn2U25SuUsGYRqm14xPhwuSVrVHew9kgSDt uIjpYtdQGLbed2JFIwZjkl862S2tgAuCACm8k7Rb2OQpglLo1u4hACNqyVCkdadh kjci3eC3iNmtqLnkclWUem1XV0UO7giytlnTFCrvFNpdglGW4PU3KfvnUmQElF1l uxCTGKgBMEqqVhuctEGGePQUh/1tCb3QS3DOE7N+lsnuDIQZINXaeSYwUAVBCzY= =isZE -----END PGP SIGNATURE----- --GQCQaj70Crmx7W2cOj4Jjln9xT1MP1b8c--