[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 06/36] qcow2: Fix qcow2_alloc_cluster_abort() for external data fi
From: |
Kevin Wolf |
Subject: |
[PULL 06/36] qcow2: Fix qcow2_alloc_cluster_abort() for external data file |
Date: |
Tue, 18 Feb 2020 15:06:52 +0100 |
For external data file, cluster allocations return an offset in the data
file and are not refcounted. In this case, there is nothing to do for
qcow2_alloc_cluster_abort(). Freeing the same offset in the qcow2 file
is wrong and causes crashes in the better case or image corruption in
the worse case.
Signed-off-by: Kevin Wolf <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2-cluster.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 1947f13a2d..78c95dfa16 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -1026,8 +1026,11 @@ err:
void qcow2_alloc_cluster_abort(BlockDriverState *bs, QCowL2Meta *m)
{
BDRVQcow2State *s = bs->opaque;
- qcow2_free_clusters(bs, m->alloc_offset, m->nb_clusters << s->cluster_bits,
- QCOW2_DISCARD_NEVER);
+ if (!has_data_file(bs)) {
+ qcow2_free_clusters(bs, m->alloc_offset,
+ m->nb_clusters << s->cluster_bits,
+ QCOW2_DISCARD_NEVER);
+ }
}
/*
--
2.20.1
- [PULL 00/36] Block layer patches, Kevin Wolf, 2020/02/18
- [PULL 04/36] block/vvfat: Do not unref qcow on closing backing bdrv, Kevin Wolf, 2020/02/18
- [PULL 02/36] mirror: Don't let an operation wait for itself, Kevin Wolf, 2020/02/18
- [PULL 05/36] qcow2: update_refcount(): Reset old_table_index after qcow2_cache_put(), Kevin Wolf, 2020/02/18
- [PULL 06/36] qcow2: Fix qcow2_alloc_cluster_abort() for external data file,
Kevin Wolf <=
- [PULL 03/36] qcow2: Fix alignment checks in encrypted images, Kevin Wolf, 2020/02/18
- [PULL 01/36] mirror: Store MirrorOp.co for debuggability, Kevin Wolf, 2020/02/18
- [PULL 08/36] block/qcow2-bitmap: Remove unneeded variable assignment, Kevin Wolf, 2020/02/18
- [PULL 07/36] iotests: Test copy offloading with external data file, Kevin Wolf, 2020/02/18
- [PULL 09/36] qapi: Document meaning of 'ignore' BlockdevOnError for jobs, Kevin Wolf, 2020/02/18
- [PULL 12/36] commit: Inline commit_populate(), Kevin Wolf, 2020/02/18
- [PULL 11/36] commit: Fix argument order for block_job_error_action(), Kevin Wolf, 2020/02/18
- [PULL 14/36] commit: Expose on-error option in QMP, Kevin Wolf, 2020/02/18
- [PULL 10/36] commit: Remove unused bytes_written, Kevin Wolf, 2020/02/18
- [PULL 16/36] block: Remove superfluous semicolons, Kevin Wolf, 2020/02/18