Skip to content

Commit

Permalink
qcow2: Flushing the caches in qcow2_close may fail
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
XanClic authored and kevmw committed Dec 10, 2014
1 parent 11c8976 commit 3b5e14c
Show file tree
Hide file tree
Showing 4 changed files with 146 additions and 3 deletions.
19 changes: 16 additions & 3 deletions block/qcow2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 3b5e14c

Please sign in to comment.