From fe446b5da225b551fc6493890d437fe4a8ba7552 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Fri, 11 Oct 2019 17:28:07 +0200 Subject: qcow2: Add qcow2_check_fix_snapshot_table() qcow2_check_read_snapshot_table() can perform consistency checks, but it cannot fix everything. Specifically, it cannot allocate new clusters, because that should wait until the refcount structures are known to be consistent (i.e., after qcow2_check_refcounts()). Thus, it cannot call qcow2_write_snapshots(). Do that in qcow2_check_fix_snapshot_table(), which is called after qcow2_check_refcounts(). Currently, there is nothing that would set result->corruptions, so this is a no-op. A follow-up patch will change that. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Message-id: 20191011152814.14791-10-mreitz@redhat.com Signed-off-by: Max Reitz --- block/qcow2.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'block/qcow2.c') diff --git a/block/qcow2.c b/block/qcow2.c index b0026e8..8d4f38a 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -597,14 +597,21 @@ static int coroutine_fn qcow2_co_check_locked(BlockDriverState *bs, memset(result, 0, sizeof(*result)); ret = qcow2_check_read_snapshot_table(bs, &snapshot_res, fix); - qcow2_add_check_result(result, &snapshot_res, false); if (ret < 0) { + qcow2_add_check_result(result, &snapshot_res, false); return ret; } ret = qcow2_check_refcounts(bs, &refcount_res, fix); qcow2_add_check_result(result, &refcount_res, true); if (ret < 0) { + qcow2_add_check_result(result, &snapshot_res, false); + return ret; + } + + ret = qcow2_check_fix_snapshot_table(bs, &snapshot_res, fix); + qcow2_add_check_result(result, &snapshot_res, false); + if (ret < 0) { return ret; } -- cgit v1.1