Calculate refcounts for qcow2 bitmaps. It is needed for qcow2's qemu-img
check implementation.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
block/qcow2-bitmap.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++
block/qcow2-refcount.c | 6 +++++
block/qcow2.h | 3 +++
3 files changed, 82 insertions(+)
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index 55b1112..0e0ddf3 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -1155,3 +1155,76 @@ common_errp:
name, bdrv_get_device_or_node_name(bs), reason);
return false;
}
+
+int qcow2_check_bitmaps_refcounts(BlockDriverState *bs, BdrvCheckResult *res,
+ void **refcount_table,
+ int64_t *refcount_table_size)
+{
+ }
+
+ if (offset == 0) {
+ continue;
+ }
+
+ ret = qcow2_inc_refcounts_imrt(bs, res,
+ refcount_table, refcount_table_size,
+ offset, s->cluster_size);
+ if (ret < 0) {
+ g_free(bitmap_table);
+ goto out;
+ }
+ }
+
+ g_free(bitmap_table);
+ }
+
+out:
+ bitmap_list_free(bm_list);
+
+ return ret;
+}