From nobody Fri Oct 24 22:15:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519823709048887.5119694081952; Wed, 28 Feb 2018 05:15:09 -0800 (PST) Received: from localhost ([::1]:44230 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er1Zb-0001AR-R0 for importer@patchew.org; Wed, 28 Feb 2018 08:15:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45456) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er1Y5-0000Fu-L9 for qemu-devel@nongnu.org; Wed, 28 Feb 2018 08:13:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1er1Y4-0001vi-Na for qemu-devel@nongnu.org; Wed, 28 Feb 2018 08:13:33 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38164 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1er1Xy-0001tt-El; Wed, 28 Feb 2018 08:13:26 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 58C608182D2E; Wed, 28 Feb 2018 13:13:25 +0000 (UTC) Received: from localhost (unknown [10.40.205.159]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0122020A846E; Wed, 28 Feb 2018 13:13:24 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 28 Feb 2018 14:13:15 +0100 Message-Id: <20180228131315.30194-3-mreitz@redhat.com> In-Reply-To: <20180228131315.30194-1-mreitz@redhat.com> References: <20180228131315.30194-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 28 Feb 2018 13:13:25 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Wed, 28 Feb 2018 13:13:25 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 2/2] iotests: Test preallocated truncate of 2G image 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-stable@nongnu.org, qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Max Reitz Reviewed-by: Daniel P. Berrang=C3=A9 --- tests/qemu-iotests/106 | 24 ++++++++++++++++++++++++ tests/qemu-iotests/106.out | 10 ++++++++++ 2 files changed, 34 insertions(+) diff --git a/tests/qemu-iotests/106 b/tests/qemu-iotests/106 index bfe71f4e60..5e51f88a78 100755 --- a/tests/qemu-iotests/106 +++ b/tests/qemu-iotests/106 @@ -86,6 +86,30 @@ for growth_mode in falloc full off; do $QEMU_IMG resize -f "$IMGFMT" --shrink --preallocation=3D$growth_mode = "$TEST_IMG" -${GROWTH_SIZE}K done =20 +echo +echo '=3D=3D=3D Testing image growth on 2G empty image =3D=3D=3D' + +for growth_mode in falloc full; do + echo + echo "--- growth_mode=3D$growth_mode ---" + + # Maybe we want to do an lseek() to the end of the file before the + # preallocation; if the file has a length of 2 GB, that would + # return an integer that overflows to negative when put into a + # plain int. We should use the correct type for the result, and + # this tests we do. + + _make_test_img 2G + $QEMU_IMG resize -f "$IMGFMT" --preallocation=3D$growth_mode "$TEST_IM= G" +${GROWTH_SIZE}K + + actual_size=3D$($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep 'disk s= ize') + actual_size=3D$(echo "$actual_size" | sed -e 's/^[^0-9]*\([0-9]\+\).*$= /\1/') + + if [ $actual_size -lt $GROWTH_SIZE ]; then + echo "ERROR: Image should have at least ${GROWTH_SIZE}K, but has $= {actual_size}K" + fi +done + # success, all done echo '*** done' rm -f $seq.full diff --git a/tests/qemu-iotests/106.out b/tests/qemu-iotests/106.out index 0a42312301..c459957660 100644 --- a/tests/qemu-iotests/106.out +++ b/tests/qemu-iotests/106.out @@ -47,4 +47,14 @@ qemu-img: Preallocation can only be used for growing ima= ges =20 --- growth_mode=3Doff --- Image resized. + +=3D=3D=3D Testing image growth on 2G empty image =3D=3D=3D + +--- growth_mode=3Dfalloc --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2147483648 +Image resized. + +--- growth_mode=3Dfull --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D2147483648 +Image resized. *** done --=20 2.14.3