From nobody Fri May 3 13:51:40 2024 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=1616770641; cv=none; d=zohomail.com; s=zohoarc; b=AIksHPi6v3lhR5/DDGjHISCZ53fVv7cx0LL6o171neiAzZHkzoAervPNuHn2t/PDqD1+V5Vb9XkSODGZWRzrJBO6AE65DcbExVLM7S+quqwZ4vEU74XW/lC7/63eTQPBAT85pi70dBTD22xgPmK7+VSELiA8QBQqEQ5NxnPTXQA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616770641; 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=/lXYHYx7LYQealjtHRsx6hYEwV7O5G1hEeWdoq4AAs0=; b=NTrabq48vn9m36sKnb5LfpkonPwGmCpdrbvsvAxB1p+idpL6aiu1Bth1ttmojcBV1Mu16Ic/TWZ0WnD2OrFHblecLQ/dl4yHPB2FHMdb4Z6BlSiRpiYBJ6cIE08oD9LQouZJuletzGH5asJGiYrPJtzhd1qx34PfVkVSoOP6Zq0= 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 1616770641938351.32988565007486; Fri, 26 Mar 2021 07:57:21 -0700 (PDT) Received: from localhost ([::1]:34486 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPnto-0006IG-Sy for importer@patchew.org; Fri, 26 Mar 2021 10:57:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPnso-0004dC-Gi for qemu-devel@nongnu.org; Fri, 26 Mar 2021 10:56:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50084) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPnsl-0002Wj-FW for qemu-devel@nongnu.org; Fri, 26 Mar 2021 10:56:18 -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-334-tuE3hKtuPpS1U3KiPfCLtw-1; Fri, 26 Mar 2021 10:56:11 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F39101926DCE; Fri, 26 Mar 2021 14:55:13 +0000 (UTC) Received: from localhost (ovpn-113-48.ams2.redhat.com [10.36.113.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F366608BA; Fri, 26 Mar 2021 14:55:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616770573; 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=/lXYHYx7LYQealjtHRsx6hYEwV7O5G1hEeWdoq4AAs0=; b=W/k0APyjaHVEtJ2gS5yQOFkcjaC3h0yijcJm5m/hferzFeycz5tEIQ52IvixqKUffuBh+T bnQFzRcPpAYXWEYWvmbVccAhryTrfFJrFLLFPjAjJ1nWMCnucmhCDLk9tNE2vf4SKecrKD U6r3wpUeAFaghPR3g4QEtEuNjRApiBs= X-MC-Unique: tuE3hKtuPpS1U3KiPfCLtw-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v2 1/2] qcow2: Force preallocation with data-file-raw Date: Fri, 26 Mar 2021 15:55:08 +0100 Message-Id: <20210326145509.163455-2-mreitz@redhat.com> In-Reply-To: <20210326145509.163455-1-mreitz@redhat.com> References: <20210326145509.163455-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com 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=170.10.133.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no 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" Setting the qcow2 data-file-raw bit means that you can ignore the qcow2 metadata when reading from the external data file. It does not mean that you have to ignore it, though. Therefore, the data read must be the same regardless of whether you interpret the metadata or whether you ignore it, and thus the L1/L2 tables must all be present and give a 1:1 mapping. This patch changes 244's output: First, the qcow2 file is larger right after creation, because of metadata preallocation. Second, the qemu-img map output changes: Everything that was not explicitly discarded or zeroed is now a data area. Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- block/qcow2.c | 34 ++++++++++++++++++++++++++++++++++ tests/qemu-iotests/244.out | 9 ++++----- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 0db1227ac9..9920c756eb 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3502,6 +3502,28 @@ qcow2_co_create(BlockdevCreateOptions *create_option= s, Error **errp) ret =3D -EINVAL; goto out; } + if (qcow2_opts->data_file_raw && + qcow2_opts->preallocation =3D=3D PREALLOC_MODE_OFF) + { + /* + * data-file-raw means that "the external data file can be + * read as a consistent standalone raw image without looking + * at the qcow2 metadata." It does not say that the metadata + * must be ignored, though (and the qcow2 driver in fact does + * not ignore it), so the L1/L2 tables must be present and + * give a 1:1 mapping, so you get the same result regardless + * of whether you look at the metadata or whether you ignore + * it. + */ + qcow2_opts->preallocation =3D PREALLOC_MODE_METADATA; + + /* + * Cannot use preallocation with backing files, but giving a + * backing file when specifying data_file_raw is an error + * anyway. + */ + assert(!qcow2_opts->has_backing_file); + } =20 if (qcow2_opts->data_file) { if (version < 3) { @@ -4237,6 +4259,18 @@ static int coroutine_fn qcow2_co_truncate(BlockDrive= rState *bs, int64_t offset, error_setg_errno(errp, -ret, "Failed to grow the L1 table"); goto fail; } + + if (data_file_is_raw(bs) && prealloc =3D=3D PREALLOC_MODE_OFF) { + /* + * When creating a qcow2 image with data-file-raw, we enforce + * at least prealloc=3Dmetadata, so that the L1/L2 tables are + * fully allocated and reading from the data file will return + * the same data as reading from the qcow2 image. When the + * image is grown, we must consequently preallocate the + * metadata structures to cover the added area. + */ + prealloc =3D PREALLOC_MODE_METADATA; + } } =20 switch (prealloc) { diff --git a/tests/qemu-iotests/244.out b/tests/qemu-iotests/244.out index 7269b4295a..1a3ae31dde 100644 --- a/tests/qemu-iotests/244.out +++ b/tests/qemu-iotests/244.out @@ -83,7 +83,7 @@ qcow2 file size after I/O: 327680 =3D=3D=3D Standalone image with external data file (valid raw) =3D=3D=3D =20 Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 data_file=3DT= EST_DIR/t.IMGFMT.data data_file_raw=3Don -qcow2 file size before I/O: 196616 +qcow2 file size before I/O: 327680 =20 wrote 4194304/4194304 bytes at offset 1048576 4 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) @@ -93,11 +93,10 @@ wrote 3145728/3145728 bytes at offset 3145728 3 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) No errors were found on the image. =20 -[{ "start": 0, "length": 1048576, "depth": 0, "zero": true, "data": false}, -{ "start": 1048576, "length": 1048576, "depth": 0, "zero": false, "data": = true, "offset": 1048576}, +[{ "start": 0, "length": 2097152, "depth": 0, "zero": false, "data": true,= "offset": 0}, { "start": 2097152, "length": 2097152, "depth": 0, "zero": true, "data": f= alse}, -{ "start": 4194304, "length": 1048576, "depth": 0, "zero": true, "data": f= alse, "offset": 4194304}, -{ "start": 5242880, "length": 61865984, "depth": 0, "zero": true, "data": = false}] +{ "start": 4194304, "length": 2097152, "depth": 0, "zero": true, "data": f= alse, "offset": 4194304}, +{ "start": 6291456, "length": 60817408, "depth": 0, "zero": false, "data":= true, "offset": 6291456}] =20 read 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) --=20 2.29.2 From nobody Fri May 3 13:51:40 2024 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=1616770654; cv=none; d=zohomail.com; s=zohoarc; b=WiWBJADzcaMmb/hwynGDZ16cSNiravjHW4w6KSa37U0yokWgYNiBhOpQSxz0+KAxrPvDYwVYekcTa+gzvN3OT7CQLKoRoM+mp4amj7eSgO9Hev1g1m27c7jdJ1av9Y/1mwmj9AaGzzaEVmaBeyEiqWW+I3szmhoQG4pRVLgTW8E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616770654; 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=afxEBppvjLlp9SGQU5+xHmLHuMUswPXdjVR7hIw2cdw=; b=fEyueeEslupNm4gOeR9hOCnE92biVcM4Lv+XdXswehjy+VAhGo2c7gZp/SE+bq7pcI4buHf8+MVIPjgj1LUz0uEeIjqt2eXgeKMjs2CJ+n8Hq/hlkxEHbpcIKKLhYZLaoTqd0MO8PknDanWAkAklVjKKCsbeHgI1unbrJticphs= 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 161677065425615.825197451475447; Fri, 26 Mar 2021 07:57:34 -0700 (PDT) Received: from localhost ([::1]:35534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lPnu1-0006kQ-1v for importer@patchew.org; Fri, 26 Mar 2021 10:57:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPnss-0004iu-Sl for qemu-devel@nongnu.org; Fri, 26 Mar 2021 10:56:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34817) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lPnsp-0002Yr-Ii for qemu-devel@nongnu.org; Fri, 26 Mar 2021 10:56:22 -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-131-2SUU6k2wO1yZvxyHAp7rYA-1; Fri, 26 Mar 2021 10:56:12 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5D7191927805; Fri, 26 Mar 2021 14:55:16 +0000 (UTC) Received: from localhost (ovpn-113-48.ams2.redhat.com [10.36.113.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BA02C13441; Fri, 26 Mar 2021 14:55:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616770578; 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=afxEBppvjLlp9SGQU5+xHmLHuMUswPXdjVR7hIw2cdw=; b=DEPmBzw5f81eNEirEu4KlCjpFg+gQRWKEki8JHcGT+Vl1T+dbix8g2SlZJg93nCAmU5bf2 vm9HyFfSxZOwjVxRelh0mRAetai2A2OIh20ZCnDQRypN6L4I+DaSWCaU6F9nAoZ92cZJ7H cMqbOM9OUZxnkD+pWv2PJWOuRnlvNzA= X-MC-Unique: 2SUU6k2wO1yZvxyHAp7rYA-1 From: Max Reitz To: qemu-block@nongnu.org Subject: [PATCH v2 2/2] iotests/244: Test preallocation for data-file-raw Date: Fri, 26 Mar 2021 15:55:09 +0100 Message-Id: <20210326145509.163455-3-mreitz@redhat.com> In-Reply-To: <20210326145509.163455-1-mreitz@redhat.com> References: <20210326145509.163455-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mreitz@redhat.com 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=216.205.24.124; envelope-from=mreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no 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" Three test cases: (1) Adding a qcow2 (metadata) file to an existing data file, see whether we can read the existing data through the qcow2 image. (2) Append data to the data file, grow the qcow2 image accordingly, see whether we can read the new data through the qcow2 image. (3) At runtime, add a backing image to a freshly created qcow2 image with an external data file (with data-file-raw). Reading data from the qcow2 image must return the same result as reading data from the data file, so everything in the backing image must be ignored. (This did not use to be the case, because without the L2 tables preallocated, all clusters would appear as unallocated, and so the qcow2 driver would fall through to the backing file.) Signed-off-by: Max Reitz Reviewed-by: Eric Blake --- tests/qemu-iotests/244 | 104 +++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/244.out | 59 +++++++++++++++++++++ 2 files changed, 163 insertions(+) diff --git a/tests/qemu-iotests/244 b/tests/qemu-iotests/244 index a46b441627..3e61fa25bb 100755 --- a/tests/qemu-iotests/244 +++ b/tests/qemu-iotests/244 @@ -38,6 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 # get standard environment, filters and checks . ./common.rc . ./common.filter +. ./common.qemu =20 _supported_fmt qcow2 _supported_proto file @@ -267,6 +268,109 @@ case $result in ;; esac =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 + +# Pre-create the data file, write some data. Real-world use cases for +# this are adding a qcow2 metadata file to a block device (i.e., using +# the device as the data file) or adding qcow2 features to pre-existing +# raw images (e.g. because the user now wants persistent dirty bitmaps). +truncate -s 1M "$TEST_IMG.data" +$QEMU_IO -f raw -c 'write -P 42 0 1M' "$TEST_IMG.data" | _filter_qemu_io + +# We cannot use qemu-img to create the qcow2 image, because it would +# clear the data file. Use the blockdev-create job instead, which will +# only format the qcow2 image file. +touch "$TEST_IMG" +_launch_qemu \ + -blockdev file,node-name=3Ddata,filename=3D"$TEST_IMG.data" \ + -blockdev file,node-name=3Dmeta,filename=3D"$TEST_IMG" + +_send_qemu_cmd $QEMU_HANDLE '{ "execute": "qmp_capabilities" }' 'return' + +_send_qemu_cmd $QEMU_HANDLE \ + '{ "execute": "blockdev-create", + "arguments": { + "job-id": "create", + "options": { + "driver": "qcow2", + "size": '"$((1 * 1024 * 1024))"', + "file": "meta", + "data-file": "data", + "data-file-raw": true + } } }' \ + '"status": "concluded"' + +_send_qemu_cmd $QEMU_HANDLE \ + '{ "execute": "job-dismiss", "arguments": { "id": "create" } }' \ + 'return' + +_cleanup_qemu + +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 '--- Truncation (growing) ---' + +# Append some new data to the raw file, then resize the qcow2 image +# accordingly and see whether the new data is visible. Technically +# that is not allowed, but it is reasonable behavior, so test it. +truncate -s 2M "$TEST_IMG.data" +$QEMU_IO -f raw -c 'write -P 84 1M 1M' "$TEST_IMG.data" | _filter_qemu_io + +$QEMU_IMG resize "$TEST_IMG" 2M + +echo +echo 'Comparing pattern:' + +$QEMU_IO -f raw -c 'read -P 42 0 1M' -c 'read -P 84 1M 1M' "$TEST_IMG.data= " \ + | _filter_qemu_io +$QEMU_IO -f $IMGFMT -c 'read -P 42 0 1M' -c 'read -P 84 1M 1M' "$TEST_IMG"= \ + | _filter_qemu_io + +$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 1a3ae31dde..99f56ac18c 100644 --- a/tests/qemu-iotests/244.out +++ b/tests/qemu-iotests/244.out @@ -137,4 +137,63 @@ wrote 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 Success: qemu-io failed, so the data file was flushed + +=3D=3D=3D Preallocation with data-file-raw =3D=3D=3D + +--- Using a non-zeroed data file --- +wrote 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +{ "execute": "qmp_capabilities" } +{"return": {}} +{ "execute": "blockdev-create", + "arguments": { + "job-id": "create", + "options": { + "driver": "IMGFMT", + "size": 1048576, + "file": "meta", + "data-file": "data", + "data-file-raw": true + } } } +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "created", "id": "create"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "running", "id": "create"}} +{"return": {}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "waiting", "id": "create"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "pending", "id": "create"}} +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "concluded", "id": "create"}} +{ "execute": "job-dismiss", "arguments": { "id": "create" } } +{"timestamp": {"seconds": TIMESTAMP, "microseconds": TIMESTAMP}, "event"= : "JOB_STATUS_CHANGE", "data": {"status": "null", "id": "create"}} +{"return": {}} + +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. + +--- Truncation (growing) --- +wrote 1048576/1048576 bytes at offset 1048576 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Image resized. + +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 1048576 +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) +read 1048576/1048576 bytes at offset 1048576 +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.29.2