Received: from eggs.gnu.org ([2001:4830:134:3::10]:46919) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgyHz-0002RB-6s for qemu-devel@nongnu.org; Wed, 22 Oct 2014 11:57:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XgyHs-0004rH-VC for qemu-devel@nongnu.org; Wed, 22 Oct 2014 11:57:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24541) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XgyHs-0004pk-NB for qemu-devel@nongnu.org; Wed, 22 Oct 2014 11:57:24 -0400 From: Max Reitz Date: Wed, 22 Oct 2014 17:57:14 +0200 Message-Id: <1413993434-11816-4-git-send-email-mreitz@redhat.com> In-Reply-To: <1413993434-11816-1-git-send-email-mreitz@redhat.com> References: <1413993434-11816-1-git-send-email-mreitz@redhat.com> Subject: [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: qemu-devel@nongnu.org Cc: Kevin Wolf , =?UTF-8?q?Beno=C3=AEt=20Canet?= , Stefan Hajnoczi , Max Reitz 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 --- 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") & +truncate -s $((5 * 64 * 1024)) "$TEST_IMG" +# To be sure the image has been truncated before $QEMU_IO and $QEMU_IMG run +echo '--- truncated ---' + +sleep 0.3 + # success, all done echo '*** done' rm -f $seq.full diff --git a/tests/qemu-iotests/102.out b/tests/qemu-iotests/102.out index e0e9cdc..96f4a33 100644 --- a/tests/qemu-iotests/102.out +++ b/tests/qemu-iotests/102.out @@ -7,4 +7,13 @@ wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) [ 0] 128/ 128 sectors allocated at offset 0 bytes (1) Offset Length Mapped to File + +=== Testing map on an image file truncated outside of qemu === + +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=65536 +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +--- truncated --- +[ 0] 128/ 128 sectors allocated at offset 0 bytes (1) +Offset Length Mapped to File *** done -- 1.9.3