|
|
22c213 |
From ecc4fb6e1941035e1d9def1f69b779fbea216caf Mon Sep 17 00:00:00 2001
|
|
|
22c213 |
From: Kevin Wolf <kwolf@redhat.com>
|
|
|
22c213 |
Date: Mon, 24 Feb 2020 16:13:07 +0000
|
|
|
22c213 |
Subject: [PATCH 7/9] qcow2: Fix qcow2_alloc_cluster_abort() for external data
|
|
|
22c213 |
file
|
|
|
22c213 |
|
|
|
22c213 |
RH-Author: Kevin Wolf <kwolf@redhat.com>
|
|
|
22c213 |
Message-id: <20200224161307.29783-2-kwolf@redhat.com>
|
|
|
22c213 |
Patchwork-id: 94042
|
|
|
22c213 |
O-Subject: [RHEL-AV-8.2.0 qemu-kvm PATCH 1/1] qcow2: Fix qcow2_alloc_cluster_abort() for external data file
|
|
|
22c213 |
Bugzilla: 1703907
|
|
|
22c213 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
22c213 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
22c213 |
RH-Acked-by: Max Reitz <mreitz@redhat.com>
|
|
|
22c213 |
|
|
|
22c213 |
For external data file, cluster allocations return an offset in the data
|
|
|
22c213 |
file and are not refcounted. In this case, there is nothing to do for
|
|
|
22c213 |
qcow2_alloc_cluster_abort(). Freeing the same offset in the qcow2 file
|
|
|
22c213 |
is wrong and causes crashes in the better case or image corruption in
|
|
|
22c213 |
the worse case.
|
|
|
22c213 |
|
|
|
22c213 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
22c213 |
Message-Id: <20200211094900.17315-3-kwolf@redhat.com>
|
|
|
22c213 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
22c213 |
(cherry picked from commit c3b6658c1a5a3fb24d6c27b2594cf86146f75b22)
|
|
|
22c213 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
22c213 |
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
|
|
|
22c213 |
---
|
|
|
22c213 |
block/qcow2-cluster.c | 7 +++++--
|
|
|
22c213 |
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
|
22c213 |
|
|
|
22c213 |
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
|
|
|
22c213 |
index 8982b7b..dc3c270 100644
|
|
|
22c213 |
--- a/block/qcow2-cluster.c
|
|
|
22c213 |
+++ b/block/qcow2-cluster.c
|
|
|
22c213 |
@@ -1015,8 +1015,11 @@ err:
|
|
|
22c213 |
void qcow2_alloc_cluster_abort(BlockDriverState *bs, QCowL2Meta *m)
|
|
|
22c213 |
{
|
|
|
22c213 |
BDRVQcow2State *s = bs->opaque;
|
|
|
22c213 |
- qcow2_free_clusters(bs, m->alloc_offset, m->nb_clusters << s->cluster_bits,
|
|
|
22c213 |
- QCOW2_DISCARD_NEVER);
|
|
|
22c213 |
+ if (!has_data_file(bs)) {
|
|
|
22c213 |
+ qcow2_free_clusters(bs, m->alloc_offset,
|
|
|
22c213 |
+ m->nb_clusters << s->cluster_bits,
|
|
|
22c213 |
+ QCOW2_DISCARD_NEVER);
|
|
|
22c213 |
+ }
|
|
|
22c213 |
}
|
|
|
22c213 |
|
|
|
22c213 |
/*
|
|
|
22c213 |
--
|
|
|
22c213 |
1.8.3.1
|
|
|
22c213 |
|