From nobody Tue Feb 10 12:57:50 2026 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1495818112261889.2079752151967; Fri, 26 May 2017 10:01:52 -0700 (PDT) Received: from localhost ([::1]:37634 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dEIcY-0004QP-0x for importer@patchew.org; Fri, 26 May 2017 13:01:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dEIXQ-0000RR-MC for qemu-devel@nongnu.org; Fri, 26 May 2017 12:56:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dEIXP-0003qk-GJ for qemu-devel@nongnu.org; Fri, 26 May 2017 12:56:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53566) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dEIXK-0003q4-Dj; Fri, 26 May 2017 12:56:26 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4ACEB7F4AE; Fri, 26 May 2017 16:56:25 +0000 (UTC) Received: from localhost (unknown [10.40.205.98]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3E6DF5C883; Fri, 26 May 2017 16:56:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4ACEB7F4AE Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4ACEB7F4AE From: Max Reitz To: qemu-block@nongnu.org Date: Fri, 26 May 2017 18:55:17 +0200 Message-Id: <20170526165518.7580-16-mreitz@redhat.com> In-Reply-To: <20170526165518.7580-1-mreitz@redhat.com> References: <20170526165518.7580-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 26 May 2017 16:56:25 +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 v3 15/16] iotests: Add preallocated resize test for raw 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, Stefan Hajnoczi , 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: Stefan Hajnoczi --- tests/qemu-iotests/106 | 92 ++++++++++++++++++++++++++++++++++++++++++= ++++ tests/qemu-iotests/106.out | 50 +++++++++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 143 insertions(+) create mode 100755 tests/qemu-iotests/106 create mode 100644 tests/qemu-iotests/106.out diff --git a/tests/qemu-iotests/106 b/tests/qemu-iotests/106 new file mode 100755 index 0000000..3264957 --- /dev/null +++ b/tests/qemu-iotests/106 @@ -0,0 +1,92 @@ +#!/bin/bash +# +# Test preallocated resize of raw images +# +# Copyright (C) 2017 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=3Dmreitz@redhat.com + +seq=3D$(basename $0) +echo "QA output created by $seq" + +here=3D$PWD +status=3D1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment and filters +. ./common.rc +. ./common.filter + +_supported_fmt raw +_supported_proto file +_supported_os Linux + +# in kB +CREATION_SIZE=3D128 +GROWTH_SIZE=3D256 + +echo '=3D=3D=3D Testing image growth =3D=3D=3D' + +for create_mode in off falloc full; do + for growth_mode in off falloc full; do + echo + echo "--- create_mode=3D$create_mode growth_mode=3D$growth_mode --= -" + + IMGOPTS=3D"preallocation=3D$create_mode" _make_test_img ${CREATION= _SIZE}K + $QEMU_IMG resize -f "$IMGFMT" --preallocation=3D$growth_mode "$TES= T_IMG" +${GROWTH_SIZE}K + + expected_size=3D0 + if [ $create_mode !=3D off ]; then + expected_size=3D$CREATION_SIZE + fi + if [ $growth_mode !=3D off ]; then + expected_size=3D$((expected_size + $GROWTH_SIZE)) + fi + + actual_size=3D$($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | grep 'di= sk size') + actual_size=3D$(echo "$actual_size" | sed -e 's/^[^0-9]*\([0-9]\+\= ).*$/\1/') + + # The actual size may exceed the expected size, depending on the f= ile + # system. Therefore we just test that the actual size is at least = what + # we expect. + if [ $actual_size -lt $expected_size ]; then + echo "ERROR: Image should have at least ${expected_size}K, but= has ${actual_size}K" + fi + done +done + +echo +echo '=3D=3D=3D Testing image shrinking =3D=3D=3D' + +# None of this should work except for "off", because other modes cannot be= used +# for shrinking +for growth_mode in falloc full off; do + echo + echo "--- growth_mode=3D$growth_mode ---" + $QEMU_IMG resize -f "$IMGFMT" --preallocation=3D$growth_mode "$TEST_IM= G" -${GROWTH_SIZE}K +done + +# success, all done +echo '*** done' +rm -f $seq.full +status=3D0 diff --git a/tests/qemu-iotests/106.out b/tests/qemu-iotests/106.out new file mode 100644 index 0000000..0a42312 --- /dev/null +++ b/tests/qemu-iotests/106.out @@ -0,0 +1,50 @@ +QA output created by 106 +=3D=3D=3D Testing image growth =3D=3D=3D + +--- create_mode=3Doff growth_mode=3Doff --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 preallocation= =3Doff +Image resized. + +--- create_mode=3Doff growth_mode=3Dfalloc --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 preallocation= =3Doff +Image resized. + +--- create_mode=3Doff growth_mode=3Dfull --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 preallocation= =3Doff +Image resized. + +--- create_mode=3Dfalloc growth_mode=3Doff --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 preallocation= =3Dfalloc +Image resized. + +--- create_mode=3Dfalloc growth_mode=3Dfalloc --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 preallocation= =3Dfalloc +Image resized. + +--- create_mode=3Dfalloc growth_mode=3Dfull --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 preallocation= =3Dfalloc +Image resized. + +--- create_mode=3Dfull growth_mode=3Doff --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 preallocation= =3Dfull +Image resized. + +--- create_mode=3Dfull growth_mode=3Dfalloc --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 preallocation= =3Dfull +Image resized. + +--- create_mode=3Dfull growth_mode=3Dfull --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D131072 preallocation= =3Dfull +Image resized. + +=3D=3D=3D Testing image shrinking =3D=3D=3D + +--- growth_mode=3Dfalloc --- +qemu-img: Preallocation can only be used for growing images + +--- growth_mode=3Dfull --- +qemu-img: Preallocation can only be used for growing images + +--- growth_mode=3Doff --- +Image resized. +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index ae2ef21..9846e03 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -112,6 +112,7 @@ 103 rw auto quick 104 rw auto 105 rw auto quick +106 rw auto quick 107 rw auto quick 108 rw auto quick 109 rw auto --=20 2.9.4