[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 32/34] qcow2: Allow preallocation and backing files if extende
From: |
Alberto Garcia |
Subject: |
[PATCH v8 32/34] qcow2: Allow preallocation and backing files if extended_l2 is set |
Date: |
Wed, 10 Jun 2020 17:03:10 +0200 |
Traditional qcow2 images don't allow preallocation if a backing file
is set. This is because once a cluster is allocated there is no way to
tell that its data should be read from the backing file.
Extended L2 entries have individual allocation bits for each
subcluster, and therefore it is perfectly possible to have an
allocated cluster with all its subclusters unallocated.
Signed-off-by: Alberto Garcia <berto@igalia.com>
---
block/qcow2.c | 7 ++++---
tests/qemu-iotests/206.out | 2 +-
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/block/qcow2.c b/block/qcow2.c
index 37bfae823c..1ea8d3b87e 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -3451,10 +3451,11 @@ qcow2_co_create(BlockdevCreateOptions *create_options,
Error **errp)
qcow2_opts->preallocation = PREALLOC_MODE_OFF;
}
if (qcow2_opts->has_backing_file &&
- qcow2_opts->preallocation != PREALLOC_MODE_OFF)
+ qcow2_opts->preallocation != PREALLOC_MODE_OFF &&
+ !qcow2_opts->extended_l2)
{
- error_setg(errp, "Backing file and preallocation cannot be used at "
- "the same time");
+ error_setg(errp, "Backing file and preallocation can only be used at "
+ "the same time if extended_l2 is on");
ret = -EINVAL;
goto out;
}
diff --git a/tests/qemu-iotests/206.out b/tests/qemu-iotests/206.out
index 363c5abe35..a100849fcb 100644
--- a/tests/qemu-iotests/206.out
+++ b/tests/qemu-iotests/206.out
@@ -203,7 +203,7 @@ Job failed: Different refcount widths than 16 bits require
compatibility level 1
=== Invalid backing file options ===
{"execute": "blockdev-create", "arguments": {"job-id": "job0", "options":
{"backing-file": "/dev/null", "driver": "qcow2", "file": "node0",
"preallocation": "full", "size": 67108864}}}
{"return": {}}
-Job failed: Backing file and preallocation cannot be used at the same time
+Job failed: Backing file and preallocation can only be used at the same time
if extended_l2 is on
{"execute": "job-dismiss", "arguments": {"id": "job0"}}
{"return": {}}
--
2.20.1
- [PATCH v8 04/34] qcow2: Split cluster_needs_cow() out of count_cow_clusters(), (continued)
- [PATCH v8 04/34] qcow2: Split cluster_needs_cow() out of count_cow_clusters(), Alberto Garcia, 2020/06/10
- [PATCH v8 16/34] qcow2: Add qcow2_cluster_is_allocated(), Alberto Garcia, 2020/06/10
- [PATCH v8 08/34] qcow2: Add dummy has_subclusters() function, Alberto Garcia, 2020/06/10
- [PATCH v8 10/34] qcow2: Add offset_to_sc_index(), Alberto Garcia, 2020/06/10
- [PATCH v8 19/34] qcow2: Handle QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC, Alberto Garcia, 2020/06/10
- [PATCH v8 07/34] qcow2: Document the Extended L2 Entries feature, Alberto Garcia, 2020/06/10
- [PATCH v8 02/34] qcow2: Convert qcow2_get_cluster_offset() into qcow2_get_host_offset(), Alberto Garcia, 2020/06/10
- [PATCH v8 29/34] qcow2: Add subcluster support to qcow2_measure(), Alberto Garcia, 2020/06/10
- [PATCH v8 23/34] qcow2: Add subcluster support to discard_in_l2_slice(), Alberto Garcia, 2020/06/10
- [PATCH v8 09/34] qcow2: Add subcluster-related fields to BDRVQcow2State, Alberto Garcia, 2020/06/10
- [PATCH v8 32/34] qcow2: Allow preallocation and backing files if extended_l2 is set,
Alberto Garcia <=
- [PATCH v8 05/34] qcow2: Process QCOW2_CLUSTER_ZERO_ALLOC clusters in handle_copied(), Alberto Garcia, 2020/06/10
- [PATCH v8 33/34] qcow2: Assert that expand_zero_clusters_in_l1() does not support subclusters, Alberto Garcia, 2020/06/10
- [PATCH v8 14/34] qcow2: Add QCow2SubclusterType and qcow2_get_subcluster_type(), Alberto Garcia, 2020/06/10
- [PATCH v8 31/34] qcow2: Add the 'extended_l2' option and the QCOW2_INCOMPAT_EXTL2 bit, Alberto Garcia, 2020/06/10
- [PATCH v8 21/34] qcow2: Add subcluster support to qcow2_get_host_offset(), Alberto Garcia, 2020/06/10
- [PATCH v8 30/34] qcow2: Add prealloc field to QCowL2Meta, Alberto Garcia, 2020/06/10