1 #ifndef BLOCK_DIRTY_BITMAP_H 2 #define BLOCK_DIRTY_BITMAP_H 3 4 #include "qemu-common.h" 5 #include "qapi/qapi-types-block-core.h" 6 #include "qemu/hbitmap.h" 7 8 BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, 9 uint32_t granularity, 10 const char *name, 11 Error **errp); 12 void bdrv_create_meta_dirty_bitmap(BdrvDirtyBitmap *bitmap, 13 int chunk_size); 14 void bdrv_release_meta_dirty_bitmap(BdrvDirtyBitmap *bitmap); 15 int bdrv_dirty_bitmap_create_successor(BlockDriverState *bs, 16 BdrvDirtyBitmap *bitmap, 17 Error **errp); 18 BdrvDirtyBitmap *bdrv_dirty_bitmap_abdicate(BlockDriverState *bs, 19 BdrvDirtyBitmap *bitmap, 20 Error **errp); 21 BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap(BlockDriverState *bs, 22 BdrvDirtyBitmap *bitmap, 23 Error **errp); 24 void bdrv_dirty_bitmap_enable_successor(BdrvDirtyBitmap *bitmap); 25 BdrvDirtyBitmap *bdrv_find_dirty_bitmap(BlockDriverState *bs, 26 const char *name); 27 void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap); 28 void bdrv_release_named_dirty_bitmaps(BlockDriverState *bs); 29 void bdrv_release_persistent_dirty_bitmaps(BlockDriverState *bs); 30 void bdrv_remove_persistent_dirty_bitmap(BlockDriverState *bs, 31 const char *name, 32 Error **errp); 33 void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap); 34 void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap); 35 BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs); 36 uint32_t bdrv_get_default_bitmap_granularity(BlockDriverState *bs); 37 uint32_t bdrv_dirty_bitmap_granularity(const BdrvDirtyBitmap *bitmap); 38 bool bdrv_dirty_bitmap_enabled(BdrvDirtyBitmap *bitmap); 39 bool bdrv_dirty_bitmap_frozen(BdrvDirtyBitmap *bitmap); 40 const char *bdrv_dirty_bitmap_name(const BdrvDirtyBitmap *bitmap); 41 int64_t bdrv_dirty_bitmap_size(const BdrvDirtyBitmap *bitmap); 42 DirtyBitmapStatus bdrv_dirty_bitmap_status(BdrvDirtyBitmap *bitmap); 43 void bdrv_set_dirty_bitmap(BdrvDirtyBitmap *bitmap, 44 int64_t offset, int64_t bytes); 45 void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap *bitmap, 46 int64_t offset, int64_t bytes); 47 BdrvDirtyBitmapIter *bdrv_dirty_meta_iter_new(BdrvDirtyBitmap *bitmap); 48 BdrvDirtyBitmapIter *bdrv_dirty_iter_new(BdrvDirtyBitmap *bitmap); 49 void bdrv_dirty_iter_free(BdrvDirtyBitmapIter *iter); 50 51 uint64_t bdrv_dirty_bitmap_serialization_size(const BdrvDirtyBitmap *bitmap, 52 uint64_t offset, uint64_t bytes); 53 uint64_t bdrv_dirty_bitmap_serialization_align(const BdrvDirtyBitmap *bitmap); 54 void bdrv_dirty_bitmap_serialize_part(const BdrvDirtyBitmap *bitmap, 55 uint8_t *buf, uint64_t offset, 56 uint64_t bytes); 57 void bdrv_dirty_bitmap_deserialize_part(BdrvDirtyBitmap *bitmap, 58 uint8_t *buf, uint64_t offset, 59 uint64_t bytes, bool finish); 60 void bdrv_dirty_bitmap_deserialize_zeroes(BdrvDirtyBitmap *bitmap, 61 uint64_t offset, uint64_t bytes, 62 bool finish); 63 void bdrv_dirty_bitmap_deserialize_ones(BdrvDirtyBitmap *bitmap, 64 uint64_t offset, uint64_t bytes, 65 bool finish); 66 void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap); 67 68 void bdrv_dirty_bitmap_set_readonly(BdrvDirtyBitmap *bitmap, bool value); 69 void bdrv_dirty_bitmap_set_persistance(BdrvDirtyBitmap *bitmap, 70 bool persistent); 71 void bdrv_dirty_bitmap_set_qmp_locked(BdrvDirtyBitmap *bitmap, bool qmp_locked); 72 void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap *dest, const BdrvDirtyBitmap *src, 73 Error **errp); 74 75 /* Functions that require manual locking. */ 76 void bdrv_dirty_bitmap_lock(BdrvDirtyBitmap *bitmap); 77 void bdrv_dirty_bitmap_unlock(BdrvDirtyBitmap *bitmap); 78 bool bdrv_get_dirty_locked(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, 79 int64_t offset); 80 void bdrv_set_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap, 81 int64_t offset, int64_t bytes); 82 void bdrv_reset_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap, 83 int64_t offset, int64_t bytes); 84 int64_t bdrv_dirty_iter_next(BdrvDirtyBitmapIter *iter); 85 bool bdrv_dirty_iter_next_area(BdrvDirtyBitmapIter *iter, uint64_t max_offset, 86 uint64_t *offset, int *bytes); 87 void bdrv_set_dirty_iter(BdrvDirtyBitmapIter *hbi, int64_t offset); 88 int64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap); 89 int64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap *bitmap); 90 void bdrv_dirty_bitmap_truncate(BlockDriverState *bs, int64_t bytes); 91 bool bdrv_dirty_bitmap_readonly(const BdrvDirtyBitmap *bitmap); 92 bool bdrv_has_readonly_bitmaps(BlockDriverState *bs); 93 bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap *bitmap); 94 bool bdrv_dirty_bitmap_get_persistance(BdrvDirtyBitmap *bitmap); 95 bool bdrv_dirty_bitmap_qmp_locked(BdrvDirtyBitmap *bitmap); 96 bool bdrv_has_changed_persistent_bitmaps(BlockDriverState *bs); 97 BdrvDirtyBitmap *bdrv_dirty_bitmap_next(BlockDriverState *bs, 98 BdrvDirtyBitmap *bitmap); 99 char *bdrv_dirty_bitmap_sha256(const BdrvDirtyBitmap *bitmap, Error **errp); 100 int64_t bdrv_dirty_bitmap_next_zero(BdrvDirtyBitmap *bitmap, uint64_t start); 101 BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap_locked(BlockDriverState *bs, 102 BdrvDirtyBitmap *bitmap, 103 Error **errp); 104 105 #endif 106