aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2015-12-22 16:14:10 +0100
committerKevin Wolf <kwolf@redhat.com>2016-01-20 13:36:24 +0100
commit191fb11bdfbf53b33068268ce995a5c84045a8d9 (patch)
treeedd46608d17d01e129d293ba4b98047c11892f4e
parent140fd5a69cf19460b8daa8a9bb83bd869f6db14d (diff)
downloadqemu-191fb11bdfbf53b33068268ce995a5c84045a8d9.zip
qemu-191fb11bdfbf53b33068268ce995a5c84045a8d9.tar.gz
qemu-191fb11bdfbf53b33068268ce995a5c84045a8d9.tar.bz2
qcow2: Make image inaccessible after failed qcow2_invalidate_cache()
If qcow2_invalidate_cache() fails, we are in a state where qcow2_close() has already been completed, but the image hasn't been reopened yet. Calling into any qcow2 function for an image in this state will cause crashes. The real solution would be to get rid of the close/open pair and instead do an atomic reset of the involved data structures, but this isn't trivial, so let's just make the image inaccessible for now. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
-rw-r--r--block/qcow2.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/block/qcow2.c b/block/qcow2.c
index 0f8c485..fd8436c 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1764,6 +1764,7 @@ static void qcow2_invalidate_cache(BlockDriverState *bs, Error **errp)
bdrv_invalidate_cache(bs->file->bs, &local_err);
if (local_err) {
error_propagate(errp, local_err);
+ bs->drv = NULL;
return;
}
@@ -1776,9 +1777,11 @@ static void qcow2_invalidate_cache(BlockDriverState *bs, Error **errp)
if (local_err) {
error_propagate(errp, local_err);
error_prepend(errp, "Could not reopen qcow2 layer: ");
+ bs->drv = NULL;
return;
} else if (ret < 0) {
error_setg_errno(errp, -ret, "Could not reopen qcow2 layer");
+ bs->drv = NULL;
return;
}