From patchwork Tue Apr 12 16:18:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 8812411 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 6A382C0553 for ; Tue, 12 Apr 2016 16:19:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 82169201FA for ; Tue, 12 Apr 2016 16:19:55 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id A1CA2201EF for ; Tue, 12 Apr 2016 16:19:54 +0000 (UTC) Received: from localhost ([::1]:52775 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aq12f-00055h-R3 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 12 Apr 2016 12:19:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34925) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aq12B-0004li-ME for qemu-devel@nongnu.org; Tue, 12 Apr 2016 12:19:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aq12A-0007cP-J6 for qemu-devel@nongnu.org; Tue, 12 Apr 2016 12:19:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36798) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aq128-0007bM-3V; Tue, 12 Apr 2016 12:19:20 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C5995627DA; Tue, 12 Apr 2016 16:19:19 +0000 (UTC) Received: from noname.redhat.com (ovpn-116-111.ams2.redhat.com [10.36.116.111]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3CGJ9W4005137; Tue, 12 Apr 2016 12:19:18 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Tue, 12 Apr 2016 18:18:59 +0200 Message-Id: <1460477948-24686-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1460477948-24686-1-git-send-email-kwolf@redhat.com> References: <1460477948-24686-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 12 Apr 2016 16:19:19 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/13] iotests: Make 150 use qemu-img map instead of du 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: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Max Reitz The actual on-disk size of a file does not only depend on factors qemu can control. Thus, we should not depend on this to determine whether a file has indeed been fully allocated. Instead, use qemu-img map and hope that if an area is referenced, it is indeed allocated, too. Also, limit the supported image formats to raw and qcow2 because the actual qemu-img map output may depend on the image format. Signed-off-by: Max Reitz Tested-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- tests/qemu-iotests/150 | 41 +++++------------------------------------ tests/qemu-iotests/150.out | 13 +++++-------- 2 files changed, 10 insertions(+), 44 deletions(-) diff --git a/tests/qemu-iotests/150 b/tests/qemu-iotests/150 index 97d2a35..665373d 100755 --- a/tests/qemu-iotests/150 +++ b/tests/qemu-iotests/150 @@ -38,65 +38,34 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.rc . ./common.filter -_supported_fmt generic +_supported_fmt raw qcow2 _supported_proto file _supported_os Linux -on_disk_size() -{ - du "$@" | sed -e 's/\t\+.*//' -} - - img_size=1048576 echo -echo '=== Comparing empty image against sparse conversion ===' +echo '=== Mapping sparse conversion ===' echo -_make_test_img $img_size - -empty_size=$(on_disk_size "$TEST_IMG") - - $QEMU_IMG_PROG convert -O "$IMGFMT" -S 512 \ "json:{ 'driver': 'null-co', 'size': $img_size, 'read-zeroes': true }" \ "$TEST_IMG" -sparse_convert_size=$(on_disk_size "$TEST_IMG") - - -if [ "$empty_size" -eq "$sparse_convert_size" ]; then - echo 'Equal image size' -else - echo 'Different image size' -fi +$QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map echo -echo '=== Comparing full image against non-sparse conversion ===' +echo '=== Mapping non-sparse conversion ===' echo -_make_test_img $img_size -$QEMU_IO -c "write 0 $img_size" "$TEST_IMG" | _filter_qemu_io - -full_size=$(on_disk_size "$TEST_IMG") - - $QEMU_IMG convert -O "$IMGFMT" -S 0 \ "json:{ 'driver': 'null-co', 'size': $img_size, 'read-zeroes': true }" \ "$TEST_IMG" -non_sparse_convert_size=$(on_disk_size "$TEST_IMG") - - -if [ "$full_size" -eq "$non_sparse_convert_size" ]; then - echo 'Equal image size' -else - echo 'Different image size' -fi +$QEMU_IMG map "$TEST_IMG" | _filter_qemu_img_map # success, all done diff --git a/tests/qemu-iotests/150.out b/tests/qemu-iotests/150.out index 2d29da1..2a54e8d 100644 --- a/tests/qemu-iotests/150.out +++ b/tests/qemu-iotests/150.out @@ -1,14 +1,11 @@ QA output created by 150 -=== Comparing empty image against sparse conversion === +=== Mapping sparse conversion === -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 -Equal image size +Offset Length File -=== Comparing full image against non-sparse conversion === +=== Mapping non-sparse conversion === -Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=1048576 -wrote 1048576/1048576 bytes at offset 0 -1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -Equal image size +Offset Length File +0 0x100000 TEST_DIR/t.IMGFMT *** done