From patchwork Fri Oct 24 10:58:00 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 402799 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 69322140080 for ; Fri, 24 Oct 2014 21:59:12 +1100 (AEDT) Received: from localhost ([::1]:46627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XhcaM-0005oP-EU for incoming@patchwork.ozlabs.org; Fri, 24 Oct 2014 06:59:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XhcZT-0004S0-NW for qemu-devel@nongnu.org; Fri, 24 Oct 2014 06:58:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XhcZN-0003Aj-6t for qemu-devel@nongnu.org; Fri, 24 Oct 2014 06:58:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45462) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XhcZM-0003Af-WD for qemu-devel@nongnu.org; Fri, 24 Oct 2014 06:58:09 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9OAw8VQ029050 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 24 Oct 2014 06:58:08 -0400 Received: from localhost (dhcp-192-247.str.redhat.com [10.33.192.247]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9OAw6et024089 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Fri, 24 Oct 2014 06:58:08 -0400 From: Max Reitz To: qemu-devel@nongnu.org Date: Fri, 24 Oct 2014 12:58:00 +0200 Message-Id: <1414148280-17949-4-git-send-email-mreitz@redhat.com> In-Reply-To: <1414148280-17949-1-git-send-email-mreitz@redhat.com> References: <1414148280-17949-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz Subject: [Qemu-devel] [PATCH v4 3/3] iotests: Add test for external image truncation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. While touching this test, replace the existing "truncate" invocation by "$QEMU_IMG convert -f raw". Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- tests/qemu-iotests/102 | 21 +++++++++++++++++++-- tests/qemu-iotests/102.out | 11 +++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/102 b/tests/qemu-iotests/102 index 34b363f..161b197 100755 --- a/tests/qemu-iotests/102 +++ b/tests/qemu-iotests/102 @@ -34,9 +34,10 @@ _cleanup() } trap "_cleanup; exit \$status" 0 1 2 3 15 -# get standard environment, filters and checks +# get standard environment, filters and qemu instance handling . ./common.rc . ./common.filter +. ./common.qemu _supported_fmt qcow2 _supported_proto file @@ -53,11 +54,27 @@ _make_test_img $IMG_SIZE $QEMU_IO -c 'write 0 64k' "$TEST_IMG" | _filter_qemu_io # Remove data cluster from image (first cluster: image header, second: reftable, # third: refblock, fourth: L1 table, fifth: L2 table) -truncate -s $((5 * 64 * 1024)) "$TEST_IMG" +$QEMU_IMG resize -f raw "$TEST_IMG" $((5 * 64 * 1024)) $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 + +qemu_comm_method=monitor _launch_qemu -drive if=none,file="$TEST_IMG",id=drv0 + +$QEMU_IMG resize -f raw "$TEST_IMG" $((5 * 64 * 1024)) + +_send_qemu_cmd $QEMU_HANDLE 'qemu-io drv0 map' 'allocated' \ + | sed -e 's/^(qemu).*qemu-io drv0 map...$/(qemu) qemu-io drv0 map/' +_send_qemu_cmd $QEMU_HANDLE 'quit' '' + # 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..eecde16 100644 --- a/tests/qemu-iotests/102.out +++ b/tests/qemu-iotests/102.out @@ -5,6 +5,17 @@ QA output created by 102 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) +Image resized. [ 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) +Image resized. +QEMU X.Y.Z monitor - type 'help' for more information +(qemu) qemu-io drv0 map +[ 0] 128/ 128 sectors allocated at offset 0 bytes (1) *** done