From patchwork Wed Nov 29 18:51:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 10083219 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0722960234 for ; Wed, 29 Nov 2017 18:53:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EDF1D29A08 for ; Wed, 29 Nov 2017 18:53:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2CA129B73; Wed, 29 Nov 2017 18:53:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7AB6429A46 for ; Wed, 29 Nov 2017 18:53:24 +0000 (UTC) Received: from localhost ([::1]:44712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eK7U3-000390-Dz for patchwork-qemu-devel@patchwork.kernel.org; Wed, 29 Nov 2017 13:53:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eK7Rw-0001Ld-DF for qemu-devel@nongnu.org; Wed, 29 Nov 2017 13:51:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eK7Rv-0001kH-JV for qemu-devel@nongnu.org; Wed, 29 Nov 2017 13:51:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46316) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eK7Rr-0001ds-74; Wed, 29 Nov 2017 13:51:07 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5475AC0587D9; Wed, 29 Nov 2017 18:51:06 +0000 (UTC) Received: from localhost (ovpn-204-230.brq.redhat.com [10.40.204.230]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7627B5D973; Wed, 29 Nov 2017 18:51:05 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 29 Nov 2017 19:51:02 +0100 Message-Id: <20171129185102.29390-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 29 Nov 2017 18:51:06 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.12] qemu-iotests: Fix locking issue in 102 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 102 truncates a qcow2 file (the raw file) on purpose while a VM is running. However, image locking will usually prevent exactly this. The fact that most people have not noticed until now (I suppose you may have seen sporadic failures, but not taken them too seriously, like me) further shows that this truncation is actually not really done concurrently, but that the VM is still starting up by this point and has not yet opened the image. Remedy this by waiting for the monitor shell to appear before the qemu-img invocation so we know the VM is up. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- tests/qemu-iotests/102 | 7 ++++++- tests/qemu-iotests/102.out | 3 ++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/102 b/tests/qemu-iotests/102 index d7ad8d9840..04b3f28445 100755 --- a/tests/qemu-iotests/102 +++ b/tests/qemu-iotests/102 @@ -69,7 +69,12 @@ $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 --shrink "$TEST_IMG" $((5 * 64 * 1024)) +# Wait for a prompt to appear (so we know qemu has opened the image) +_send_qemu_cmd '' '(qemu)' + +$QEMU_IMG resize --shrink --image-opts \ + "driver=raw,file.driver=file,file.filename=$TEST_IMG,file.locking=off" \ + $((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/' diff --git a/tests/qemu-iotests/102.out b/tests/qemu-iotests/102.out index ccf172abd9..4401b08fee 100644 --- a/tests/qemu-iotests/102.out +++ b/tests/qemu-iotests/102.out @@ -14,8 +14,9 @@ Offset Length Mapped to File 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 +Image resized. +(qemu) (qemu) qemu-io drv0 map 64 KiB (0x10000) bytes allocated at offset 0 bytes (0x0) *** done