1 #ifndef BLOCK_DIRTY_BITMAP_H
2 #define BLOCK_DIRTY_BITMAP_H
4 #include "qemu-common.h"
5 #include "qemu/hbitmap.h"
7 BdrvDirtyBitmap
*bdrv_create_dirty_bitmap(BlockDriverState
*bs
,
11 void bdrv_create_meta_dirty_bitmap(BdrvDirtyBitmap
*bitmap
,
13 void bdrv_release_meta_dirty_bitmap(BdrvDirtyBitmap
*bitmap
);
14 int bdrv_dirty_bitmap_create_successor(BlockDriverState
*bs
,
15 BdrvDirtyBitmap
*bitmap
,
17 BdrvDirtyBitmap
*bdrv_dirty_bitmap_abdicate(BlockDriverState
*bs
,
18 BdrvDirtyBitmap
*bitmap
,
20 BdrvDirtyBitmap
*bdrv_reclaim_dirty_bitmap(BlockDriverState
*bs
,
21 BdrvDirtyBitmap
*bitmap
,
23 BdrvDirtyBitmap
*bdrv_find_dirty_bitmap(BlockDriverState
*bs
,
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_release_persistent_dirty_bitmaps(BlockDriverState
*bs
);
29 void bdrv_remove_persistent_dirty_bitmap(BlockDriverState
*bs
,
32 void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap
*bitmap
);
33 void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap
*bitmap
);
34 BlockDirtyInfoList
*bdrv_query_dirty_bitmaps(BlockDriverState
*bs
);
35 uint32_t bdrv_get_default_bitmap_granularity(BlockDriverState
*bs
);
36 uint32_t bdrv_dirty_bitmap_granularity(const BdrvDirtyBitmap
*bitmap
);
37 uint32_t bdrv_dirty_bitmap_meta_granularity(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 cur_sector
, int64_t nr_sectors
);
45 void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap
*bitmap
,
46 int64_t cur_sector
, int64_t nr_sectors
);
47 int bdrv_dirty_bitmap_get_meta(BlockDriverState
*bs
,
48 BdrvDirtyBitmap
*bitmap
, int64_t sector
,
50 int bdrv_dirty_bitmap_get_meta_locked(BlockDriverState
*bs
,
51 BdrvDirtyBitmap
*bitmap
, int64_t sector
,
53 void bdrv_dirty_bitmap_reset_meta(BlockDriverState
*bs
,
54 BdrvDirtyBitmap
*bitmap
, int64_t sector
,
56 BdrvDirtyBitmapIter
*bdrv_dirty_meta_iter_new(BdrvDirtyBitmap
*bitmap
);
57 BdrvDirtyBitmapIter
*bdrv_dirty_iter_new(BdrvDirtyBitmap
*bitmap
,
58 uint64_t first_sector
);
59 void bdrv_dirty_iter_free(BdrvDirtyBitmapIter
*iter
);
61 uint64_t bdrv_dirty_bitmap_serialization_size(const BdrvDirtyBitmap
*bitmap
,
62 uint64_t start
, uint64_t count
);
63 uint64_t bdrv_dirty_bitmap_serialization_align(const BdrvDirtyBitmap
*bitmap
);
64 void bdrv_dirty_bitmap_serialize_part(const BdrvDirtyBitmap
*bitmap
,
65 uint8_t *buf
, uint64_t start
,
67 void bdrv_dirty_bitmap_deserialize_part(BdrvDirtyBitmap
*bitmap
,
68 uint8_t *buf
, uint64_t start
,
69 uint64_t count
, bool finish
);
70 void bdrv_dirty_bitmap_deserialize_zeroes(BdrvDirtyBitmap
*bitmap
,
71 uint64_t start
, uint64_t count
,
73 void bdrv_dirty_bitmap_deserialize_ones(BdrvDirtyBitmap
*bitmap
,
74 uint64_t start
, uint64_t count
,
76 void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap
*bitmap
);
78 void bdrv_dirty_bitmap_set_readonly(BdrvDirtyBitmap
*bitmap
, bool value
);
79 void bdrv_dirty_bitmap_set_autoload(BdrvDirtyBitmap
*bitmap
, bool autoload
);
80 void bdrv_dirty_bitmap_set_persistance(BdrvDirtyBitmap
*bitmap
,
83 /* Functions that require manual locking. */
84 void bdrv_dirty_bitmap_lock(BdrvDirtyBitmap
*bitmap
);
85 void bdrv_dirty_bitmap_unlock(BdrvDirtyBitmap
*bitmap
);
86 int bdrv_get_dirty_locked(BlockDriverState
*bs
, BdrvDirtyBitmap
*bitmap
,
88 void bdrv_set_dirty_bitmap_locked(BdrvDirtyBitmap
*bitmap
,
89 int64_t cur_sector
, int64_t nr_sectors
);
90 void bdrv_reset_dirty_bitmap_locked(BdrvDirtyBitmap
*bitmap
,
91 int64_t cur_sector
, int64_t nr_sectors
);
92 int64_t bdrv_dirty_iter_next(BdrvDirtyBitmapIter
*iter
);
93 void bdrv_set_dirty_iter(BdrvDirtyBitmapIter
*hbi
, int64_t sector_num
);
94 int64_t bdrv_get_dirty_count(BdrvDirtyBitmap
*bitmap
);
95 int64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap
*bitmap
);
96 void bdrv_dirty_bitmap_truncate(BlockDriverState
*bs
);
97 bool bdrv_dirty_bitmap_readonly(const BdrvDirtyBitmap
*bitmap
);
98 bool bdrv_has_readonly_bitmaps(BlockDriverState
*bs
);
99 bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap
*bitmap
);
100 bool bdrv_dirty_bitmap_get_persistance(BdrvDirtyBitmap
*bitmap
);
101 bool bdrv_has_changed_persistent_bitmaps(BlockDriverState
*bs
);
102 BdrvDirtyBitmap
*bdrv_dirty_bitmap_next(BlockDriverState
*bs
,
103 BdrvDirtyBitmap
*bitmap
);
104 char *bdrv_dirty_bitmap_sha256(const BdrvDirtyBitmap
*bitmap
, Error
**errp
);