From nobody Mon Feb 9 19:53:01 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1592563278; cv=none; d=zohomail.com; s=zohoarc; b=eg6G5FZQtawtnjAAGmsHLc4VpVrdiNLbXTpQgmsMbZyRZjiA5jvKqaZ1OXnG61LU+tyHKVsofIqLUXIPqzzAR3UPWcQqZqER6PVZgvKws5f44QqooV+brcBrC624UsS2WkfEI+94o3vckBFl5qxHecwPOtQ6DRJQKAEbsK6YF8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1592563278; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tn26SWpQZvPrUnPWcaacLiB+xjnFQetZ2himE/eWy6I=; b=aSwO5ucY3X4HM9wOkxkmEiv0YfO+9SErKPeZ3DZQI96EtLC5nvOZhs010SqfpATZwl++S0RruVStdgfDEflO1O2eDiGzJbKIckeX0Cuf5uRZ5OheAFXYshDjBzZeUBS8qdC193fBYOr1JaRkDLfNTr35AY10NWDOZ6bi4MZyb0w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1592563278555229.8186191829168; Fri, 19 Jun 2020 03:41:18 -0700 (PDT) Received: from localhost ([::1]:42158 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jmESS-0000Tb-T3 for importer@patchew.org; Fri, 19 Jun 2020 06:41:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58320) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jmERd-0008E5-Fv for qemu-devel@nongnu.org; Fri, 19 Jun 2020 06:40:25 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:58061 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jmERa-0000vx-Ma for qemu-devel@nongnu.org; Fri, 19 Jun 2020 06:40:25 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-182-3Ldqw--2PTeYeOMAxlCTaA-1; Fri, 19 Jun 2020 06:40:20 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5108C8035CF; Fri, 19 Jun 2020 10:40:19 +0000 (UTC) Received: from localhost (ovpn-113-28.ams2.redhat.com [10.36.113.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C3FC25C1D0; Fri, 19 Jun 2020 10:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1592563222; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tn26SWpQZvPrUnPWcaacLiB+xjnFQetZ2himE/eWy6I=; b=W8wbn9lU7BLQxuv1IwPx2/hgUX3reP37VmQh59iovJWRrEgHRrllgqveit7TM/0dKepTUL MdnGrCwasleY16l2bnObVuSPkR7/MEJna6AmktPsn1KGVLACn1rt23LJgo5mTkrgCPrPVd qsp/O3NnOc0+7qNbJOuKcaKLMs5u6cw= X-MC-Unique: 3Ldqw--2PTeYeOMAxlCTaA-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH 2/2] iotests/244: Test preallocation for data-file-raw Date: Fri, 19 Jun 2020 12:40:12 +0200 Message-Id: <20200619104012.235977-3-mreitz@redhat.com> In-Reply-To: <20200619104012.235977-1-mreitz@redhat.com> References: <20200619104012.235977-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=mreitz@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/19 05:19:18 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Max Reitz --- tests/qemu-iotests/244 | 65 ++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/244.out | 23 ++++++++++++++ 2 files changed, 88 insertions(+) diff --git a/tests/qemu-iotests/244 b/tests/qemu-iotests/244 index efe3c0428b..c2fdeab0c7 100755 --- a/tests/qemu-iotests/244 +++ b/tests/qemu-iotests/244 @@ -217,6 +217,71 @@ $QEMU_IMG amend -f $IMGFMT -o "data_file=3Dblkdebug::$= TEST_IMG.data" "$TEST_IMG" $QEMU_IMG convert -f $IMGFMT -O $IMGFMT -n -C "$TEST_IMG.src" "$TEST_IMG" $QEMU_IMG compare -f $IMGFMT -F $IMGFMT "$TEST_IMG.src" "$TEST_IMG" =20 +echo +echo '=3D=3D=3D Preallocation with data-file-raw =3D=3D=3D' + +echo +echo '--- Using a non-zeroed data file ---' + +# Using data-file-raw must enforce at least metadata preallocation so +# that it does not matter whether one reads the raw file or the qcow2 +# file + +# The real test we would like to do here is to use an existing block +# device with some random data on it as the external data file. +# When creating the qcow2 file, it would not be overwritten and its +# data would stay as it is. However, using an existing block device +# is a bit cumbersome in a test, so we are going to cheat by using a +# normal regular file. + +# Unfortunately, this will O_CREAT | O_TRUNC that regular file, so +# there is no point in creating it beforehand and filling it with +# random data: +_make_test_img -o "data_file=3D$TEST_IMG.data,data_file_raw=3Don" 1M + +# So now comes the cheating: We write directly into the data file. +# That is actually unsupported, but it works for this test. +# (As written above, the actual case would be to use a block device +# as the external data file. Such a device would not be emptied when +# the qcow2 file is created, so its data would persist that step.) +$QEMU_IO -f raw -c 'write -P 42 0 1M' "$TEST_IMG.data" | _filter_qemu_io + +echo +echo 'Comparing pattern:' + +# Reading from either the qcow2 file or the data file should return +# the same result: +$QEMU_IO -f raw -c 'read -P 42 0 1M' "$TEST_IMG.data" | _filter_qemu_io +$QEMU_IO -f $IMGFMT -c 'read -P 42 0 1M' "$TEST_IMG" | _filter_qemu_io + +# For good measure +$QEMU_IMG compare -f raw "$TEST_IMG.data" "$TEST_IMG" + +echo +echo '--- Giving a backing file at runtime ---' + +# qcow2 files with data-file-raw cannot have backing files given by +# their image header, but qemu will allow you to set a backing node at +# runtime -- it should not have any effect, though (because reading +# from the qcow2 node should return the same data as reading from the +# raw node). + +_make_test_img -o "data_file=3D$TEST_IMG.data,data_file_raw=3Don" 1M +TEST_IMG=3D"$TEST_IMG.base" _make_test_img 1M + +# Write something that is not zero into the base image +$QEMU_IO -c 'write -P 42 0 1M' "$TEST_IMG.base" | _filter_qemu_io + +echo +echo 'Comparing qcow2 image and raw data file:' + +# $TEST_IMG and $TEST_IMG.data must show the same data at all times; +# that is, the qcow2 node must not fall through to the backing image +# at any point +$QEMU_IMG compare --image-opts \ + "driver=3Draw,file.filename=3D$TEST_IMG.data" \ + "file.filename=3D$TEST_IMG,backing.file.filename=3D$TEST_IMG.base" + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/244.out b/tests/qemu-iotests/244.out index 24f02363dd..34d6b0e626 100644 --- a/tests/qemu-iotests/244.out +++ b/tests/qemu-iotests/244.out @@ -130,4 +130,27 @@ Offset Length Mapped to File Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 data_file=3DT= EST_DIR/t.IMGFMT.data Images are identical. Images are identical. + +=3D=3D=3D Preallocation with data-file-raw =3D=3D=3D + +--- Using a non-zeroed data file --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.data data_file_raw=3Don +wrote 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +Comparing pattern: +read 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Images are identical. + +--- Giving a backing file at runtime --- +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D1048576 data_file=3DTE= ST_DIR/t.IMGFMT.data data_file_raw=3Don +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=3DIMGFMT size=3D1048576 +wrote 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +Comparing qcow2 image and raw data file: +Images are identical. *** done --=20 2.26.2