1 #ifndef BLOCK_DIRTY_BITMAP_H
2 #define BLOCK_DIRTY_BITMAP_H
4 #include "qapi/qapi-types-block-core.h"
5 #include "qemu/hbitmap.h"
7 typedef enum BitmapCheckFlags
{
10 BDRV_BITMAP_INCONSISTENT
= 4,
13 #define BDRV_BITMAP_DEFAULT (BDRV_BITMAP_BUSY | BDRV_BITMAP_RO | \
14 BDRV_BITMAP_INCONSISTENT)
15 #define BDRV_BITMAP_ALLOW_RO (BDRV_BITMAP_BUSY | BDRV_BITMAP_INCONSISTENT)
17 BdrvDirtyBitmap
*bdrv_create_dirty_bitmap(BlockDriverState
*bs
,
21 void bdrv_create_meta_dirty_bitmap(BdrvDirtyBitmap
*bitmap
,
23 void bdrv_release_meta_dirty_bitmap(BdrvDirtyBitmap
*bitmap
);
24 int bdrv_dirty_bitmap_create_successor(BlockDriverState
*bs
,
25 BdrvDirtyBitmap
*bitmap
,
27 BdrvDirtyBitmap
*bdrv_dirty_bitmap_abdicate(BlockDriverState
*bs
,
28 BdrvDirtyBitmap
*bitmap
,
30 BdrvDirtyBitmap
*bdrv_reclaim_dirty_bitmap(BlockDriverState
*bs
,
31 BdrvDirtyBitmap
*bitmap
,
33 void bdrv_dirty_bitmap_enable_successor(BdrvDirtyBitmap
*bitmap
);
34 BdrvDirtyBitmap
*bdrv_find_dirty_bitmap(BlockDriverState
*bs
,
36 int bdrv_dirty_bitmap_check(const BdrvDirtyBitmap
*bitmap
, uint32_t flags
,
38 void bdrv_release_dirty_bitmap(BlockDriverState
*bs
, BdrvDirtyBitmap
*bitmap
);
39 void bdrv_release_named_dirty_bitmaps(BlockDriverState
*bs
);
40 void bdrv_remove_persistent_dirty_bitmap(BlockDriverState
*bs
,
43 void bdrv_disable_dirty_bitmap(BdrvDirtyBitmap
*bitmap
);
44 void bdrv_enable_dirty_bitmap(BdrvDirtyBitmap
*bitmap
);
45 void bdrv_enable_dirty_bitmap_locked(BdrvDirtyBitmap
*bitmap
);
46 BlockDirtyInfoList
*bdrv_query_dirty_bitmaps(BlockDriverState
*bs
);
47 uint32_t bdrv_get_default_bitmap_granularity(BlockDriverState
*bs
);
48 uint32_t bdrv_dirty_bitmap_granularity(const BdrvDirtyBitmap
*bitmap
);
49 bool bdrv_dirty_bitmap_enabled(BdrvDirtyBitmap
*bitmap
);
50 bool bdrv_dirty_bitmap_has_successor(BdrvDirtyBitmap
*bitmap
);
51 const char *bdrv_dirty_bitmap_name(const BdrvDirtyBitmap
*bitmap
);
52 int64_t bdrv_dirty_bitmap_size(const BdrvDirtyBitmap
*bitmap
);
53 DirtyBitmapStatus
bdrv_dirty_bitmap_status(BdrvDirtyBitmap
*bitmap
);
54 void bdrv_set_dirty_bitmap(BdrvDirtyBitmap
*bitmap
,
55 int64_t offset
, int64_t bytes
);
56 void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap
*bitmap
,
57 int64_t offset
, int64_t bytes
);
58 BdrvDirtyBitmapIter
*bdrv_dirty_meta_iter_new(BdrvDirtyBitmap
*bitmap
);
59 BdrvDirtyBitmapIter
*bdrv_dirty_iter_new(BdrvDirtyBitmap
*bitmap
);
60 void bdrv_dirty_iter_free(BdrvDirtyBitmapIter
*iter
);
62 uint64_t bdrv_dirty_bitmap_serialization_size(const BdrvDirtyBitmap
*bitmap
,
63 uint64_t offset
, uint64_t bytes
);
64 uint64_t bdrv_dirty_bitmap_serialization_align(const BdrvDirtyBitmap
*bitmap
);
65 void bdrv_dirty_bitmap_serialize_part(const BdrvDirtyBitmap
*bitmap
,
66 uint8_t *buf
, uint64_t offset
,
68 void bdrv_dirty_bitmap_deserialize_part(BdrvDirtyBitmap
*bitmap
,
69 uint8_t *buf
, uint64_t offset
,
70 uint64_t bytes
, bool finish
);
71 void bdrv_dirty_bitmap_deserialize_zeroes(BdrvDirtyBitmap
*bitmap
,
72 uint64_t offset
, uint64_t bytes
,
74 void bdrv_dirty_bitmap_deserialize_ones(BdrvDirtyBitmap
*bitmap
,
75 uint64_t offset
, uint64_t bytes
,
77 void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap
*bitmap
);
79 void bdrv_dirty_bitmap_set_readonly(BdrvDirtyBitmap
*bitmap
, bool value
);
80 void bdrv_dirty_bitmap_set_persistence(BdrvDirtyBitmap
*bitmap
,
82 void bdrv_dirty_bitmap_set_inconsistent(BdrvDirtyBitmap
*bitmap
);
83 void bdrv_dirty_bitmap_set_busy(BdrvDirtyBitmap
*bitmap
, bool busy
);
84 void bdrv_merge_dirty_bitmap(BdrvDirtyBitmap
*dest
, const BdrvDirtyBitmap
*src
,
85 HBitmap
**backup
, Error
**errp
);
86 void bdrv_dirty_bitmap_skip_store(BdrvDirtyBitmap
*bitmap
, bool skip
);
87 bool bdrv_dirty_bitmap_get(BdrvDirtyBitmap
*bitmap
, int64_t offset
);
89 /* Functions that require manual locking. */
90 void bdrv_dirty_bitmap_lock(BdrvDirtyBitmap
*bitmap
);
91 void bdrv_dirty_bitmap_unlock(BdrvDirtyBitmap
*bitmap
);
92 bool bdrv_dirty_bitmap_get_locked(BdrvDirtyBitmap
*bitmap
, int64_t offset
);
93 void bdrv_set_dirty_bitmap_locked(BdrvDirtyBitmap
*bitmap
,
94 int64_t offset
, int64_t bytes
);
95 void bdrv_reset_dirty_bitmap_locked(BdrvDirtyBitmap
*bitmap
,
96 int64_t offset
, int64_t bytes
);
97 int64_t bdrv_dirty_iter_next(BdrvDirtyBitmapIter
*iter
);
98 void bdrv_set_dirty_iter(BdrvDirtyBitmapIter
*hbi
, int64_t offset
);
99 int64_t bdrv_get_dirty_count(BdrvDirtyBitmap
*bitmap
);
100 int64_t bdrv_get_meta_dirty_count(BdrvDirtyBitmap
*bitmap
);
101 void bdrv_dirty_bitmap_truncate(BlockDriverState
*bs
, int64_t bytes
);
102 bool bdrv_dirty_bitmap_readonly(const BdrvDirtyBitmap
*bitmap
);
103 bool bdrv_has_readonly_bitmaps(BlockDriverState
*bs
);
104 bool bdrv_dirty_bitmap_get_autoload(const BdrvDirtyBitmap
*bitmap
);
105 bool bdrv_dirty_bitmap_get_persistence(BdrvDirtyBitmap
*bitmap
);
106 bool bdrv_dirty_bitmap_inconsistent(const BdrvDirtyBitmap
*bitmap
);
107 bool bdrv_has_changed_persistent_bitmaps(BlockDriverState
*bs
);
108 BdrvDirtyBitmap
*bdrv_dirty_bitmap_next(BlockDriverState
*bs
,
109 BdrvDirtyBitmap
*bitmap
);
110 char *bdrv_dirty_bitmap_sha256(const BdrvDirtyBitmap
*bitmap
, Error
**errp
);
111 int64_t bdrv_dirty_bitmap_next_zero(BdrvDirtyBitmap
*bitmap
, uint64_t offset
,
113 bool bdrv_dirty_bitmap_next_dirty_area(BdrvDirtyBitmap
*bitmap
,
114 uint64_t *offset
, uint64_t *bytes
);
115 BdrvDirtyBitmap
*bdrv_reclaim_dirty_bitmap_locked(BlockDriverState
*bs
,
116 BdrvDirtyBitmap
*bitmap
,