]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
qcow2: Fix alloc_cluster_abort() for pre-existing clusters
authorMax Reitz <mreitz@redhat.com>
Tue, 25 Feb 2020 14:31:28 +0000 (15:31 +0100)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 2 Jun 2020 15:49:38 +0000 (10:49 -0500)
handle_alloc() reuses preallocated zero clusters.  If anything goes
wrong during the data write, we do not change their L2 entry, so we
must not let qcow2_alloc_cluster_abort() free them.

Fixes: 8b24cd141549b5b264baeddd4e72902cfb5de23b
Cc: qemu-stable@nongnu.org
Signed-off-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200225143130.111267-2-mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 3ede935fdbbd5f7b24b4724bbfb8938acb5956d8)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
block/qcow2-cluster.c

index dc3c2702261b1ee2e00a3f5553db8e9352ee8539..f1a6d42df0e084387f9a1a2b61d02c2031899096 100644 (file)
@@ -1015,7 +1015,7 @@ err:
 void qcow2_alloc_cluster_abort(BlockDriverState *bs, QCowL2Meta *m)
 {
     BDRVQcow2State *s = bs->opaque;
-    if (!has_data_file(bs)) {
+    if (!has_data_file(bs) && !m->keep_old_clusters) {
         qcow2_free_clusters(bs, m->alloc_offset,
                             m->nb_clusters << s->cluster_bits,
                             QCOW2_DISCARD_NEVER);