1 #ifndef BLOCK_DIRTY_BITMAP_H 2 #define BLOCK_DIRTY_BITMAP_H 3 4 #include "qemu-common.h" 5 #include "qemu/hbitmap.h" 6 7 BdrvDirtyBitmap *bdrv_create_dirty_bitmap(BlockDriverState *bs, 8 uint32_t granularity, 9 const char *name, 10 Error **errp); 11 void bdrv_create_meta_dirty_bitmap(BdrvDirtyBitmap *bitmap, 12 int chunk_size); 13 void bdrv_release_meta_dirty_bitmap(BdrvDirtyBitmap *bitmap); 14 int bdrv_dirty_bitmap_create_successor(BlockDriverState *bs, 15 BdrvDirtyBitmap *bitmap, 16 Error **errp); 17 BdrvDirtyBitmap *bdrv_dirty_bitmap_abdicate(BlockDriverState *bs, 18 BdrvDirtyBitmap *bitmap, 19 Error **errp); 20 BdrvDirtyBitmap *bdrv_reclaim_dirty_bitmap(BlockDriverState *bs, 21 BdrvDirtyBitmap *bitmap, 22 Error **errp); 23 BdrvDirtyBitmap *bdrv_find_dirty_bitmap(BlockDriverState *bs, 24 const char *name); 25 void bdrv_dirty_bitmap_make_anon(BdrvDirtyBitmap *bitmap); 26 void bdrv_release_dirty_bitmap(BlockDriverState *bs, BdrvDirtyBitmap *bitmap); 27 void bdrv_release_named_dirty_bitmaps(BlockDriverState *bs); 28 void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap *bitmap); 29 void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap *bitmap); 30 BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs); 31 uint32_t bdrv_get_default_bitmap_granularity(BlockDriverState *bs); 32 uint32_t bdrv_dirty_bitmap_granularity(BdrvDirtyBitmap *bitmap); 33 uint32_t bdrv_dirty_bitmap_meta_granularity(BdrvDirtyBitmap *bitmap); 34 bool bdrv_dirty_bitmap_enabled(BdrvDirtyBitmap *bitmap); 35 bool bdrv_dirty_bitmap_frozen(BdrvDirtyBitmap *bitmap); 36 const char *bdrv_dirty_bitmap_name(const BdrvDirtyBitmap *bitmap); 37 int64_t bdrv_dirty_bitmap_size(const BdrvDirtyBitmap *bitmap); 38 DirtyBitmapStatus bdrv_dirty_bitmap_status(BdrvDirtyBitmap *bitmap); 39 void bdrv_set_dirty_bitmap(BdrvDirtyBitmap *bitmap, 40 int64_t cur_sector, int64_t nr_sectors); 41 void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap *bitmap, 42 int64_t cur_sector, int64_t nr_sectors); 43 int bdrv_dirty_bitmap_get_meta(BlockDriverState *bs, 44 BdrvDirtyBitmap *bitmap, int64_t sector, 45 int nb_sectors); 46 int bdrv_dirty_bitmap_get_meta_locked(BlockDriverState *bs, 47 BdrvDirtyBitmap *bitmap, int64_t sector, 48 int nb_sectors); 49 void bdrv_dirty_bitmap_reset_meta(BlockDriverState *bs, 50 BdrvDirtyBitmap *bitmap, int64_t sector, 51 int nb_sectors); 52 BdrvDirtyBitmapIter *bdrv_dirty_meta_iter_new(BdrvDirtyBitmap *bitmap); 53 BdrvDirtyBitmapIter *bdrv_dirty_iter_new(BdrvDirtyBitmap *bitmap, 54 uint64_t first_sector); 55 void bdrv_dirty_iter_free(BdrvDirtyBitmapIter *iter); 56 57 uint64_t bdrv_dirty_bitmap_serialization_size(const BdrvDirtyBitmap *bitmap, 58 uint64_t start, uint64_t count); 59 uint64_t bdrv_dirty_bitmap_serialization_align(const BdrvDirtyBitmap *bitmap); 60 void bdrv_dirty_bitmap_serialize_part(const BdrvDirtyBitmap *bitmap, 61 uint8_t *buf, uint64_t start, 62 uint64_t count); 63 void bdrv_dirty_bitmap_deserialize_part(BdrvDirtyBitmap *bitmap, 64 uint8_t *buf, uint64_t start, 65 uint64_t count, bool finish); 66 void bdrv_dirty_bitmap_deserialize_zeroes(BdrvDirtyBitmap *bitmap, 67 uint64_t start, uint64_t count, 68 bool finish); 69 void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap *bitmap); 70 71 /* Functions that require manual locking. */ 72 void bdrv_dirty_bitmap_lock(BdrvDirtyBitmap *bitmap); 73 void bdrv_dirty_bitmap_unlock(BdrvDirtyBitmap *bitmap); 74 int bdrv_get_dirty_locked(BlockDriverState *bs, BdrvDirtyBitmap *bitmap, 75 int64_t sector); 76 void bdrv_set_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap, 77 int64_t cur_sector, int64_t nr_sectors); 78 void bdrv_reset_dirty_bitmap_locked(BdrvDirtyBitmap *bitmap, 79 int64_t cur_sector, int64_t nr_sectors); 80 int64_t bdrv_dirty_iter_next(BdrvDirtyBitmapIter *iter); 81 void bdrv_set_dirty_iter(BdrvDirtyBitmapIter *hbi, int64_t sector_num); 82 int64_t bdrv_get_dirty_count(BdrvDirtyBitmap *bitmap); 83 int64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap *bitmap); 84 void bdrv_dirty_bitmap_truncate(BlockDriverState *bs); 85 86 #endif 87