summaryrefslogtreecommitdiff
path: root/block/qcow2.c
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2014-12-02 18:32:51 +0100
committerKevin Wolf <kwolf@redhat.com>2014-12-10 10:31:20 +0100
commit3b5e14c76a6bb142bf250ddf99e24a0ac8c7bc12 (patch)
tree7abd3a505dd9fbd15119085c6bc0b30cb9c0c990 /block/qcow2.c
parent11c89769dc3e638ef72915d97058411ddf79b64b (diff)
downloadqemu-3b5e14c76a6bb142bf250ddf99e24a0ac8c7bc12.tar.gz
qemu-3b5e14c76a6bb142bf250ddf99e24a0ac8c7bc12.tar.bz2
qemu-3b5e14c76a6bb142bf250ddf99e24a0ac8c7bc12.zip
qcow2: Flushing the caches in qcow2_close may fail
qcow2_cache_flush() may fail; if one of the caches failed to be flushed successfully to disk in qcow2_close() the image should not be marked clean, and we should emit a warning. This breaks the (qcow2-specific) iotests 026, 071 and 089; change their output accordingly. Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/qcow2.c')
-rw-r--r--block/qcow2.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/block/qcow2.c b/block/qcow2.c
index d597b2d44c..2a867f51f8 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1428,10 +1428,23 @@ static void qcow2_close(BlockDriverState *bs)
s->l1_table = NULL;
if (!(bs->open_flags & BDRV_O_INCOMING)) {
- qcow2_cache_flush(bs, s->l2_table_cache);
- qcow2_cache_flush(bs, s->refcount_block_cache);
+ int ret1, ret2;
- qcow2_mark_clean(bs);
+ ret1 = qcow2_cache_flush(bs, s->l2_table_cache);
+ ret2 = qcow2_cache_flush(bs, s->refcount_block_cache);
+
+ if (ret1) {
+ error_report("Failed to flush the L2 table cache: %s",
+ strerror(-ret1));
+ }
+ if (ret2) {
+ error_report("Failed to flush the refcount block cache: %s",
+ strerror(-ret2));
+ }
+
+ if (!ret1 && !ret2) {
+ qcow2_mark_clean(bs);
+ }
}
qcow2_cache_destroy(bs, s->l2_table_cache);