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