1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#ifndef BLOCK_INT_IO_H
25#define BLOCK_INT_IO_H
26
27#include "block/block_int-common.h"
28#include "qemu/hbitmap.h"
29#include "qemu/main-loop.h"
30
31
32
33
34
35
36
37
38int coroutine_fn GRAPH_RDLOCK bdrv_co_preadv_snapshot(BdrvChild *child,
39 int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset);
40int coroutine_fn GRAPH_RDLOCK bdrv_co_snapshot_block_status(
41 BlockDriverState *bs, bool want_zero, int64_t offset, int64_t bytes,
42 int64_t *pnum, int64_t *map, BlockDriverState **file);
43int coroutine_fn GRAPH_RDLOCK bdrv_co_pdiscard_snapshot(BlockDriverState *bs,
44 int64_t offset, int64_t bytes);
45
46
47int coroutine_fn GRAPH_RDLOCK bdrv_co_preadv(BdrvChild *child,
48 int64_t offset, int64_t bytes, QEMUIOVector *qiov,
49 BdrvRequestFlags flags);
50int coroutine_fn GRAPH_RDLOCK bdrv_co_preadv_part(BdrvChild *child,
51 int64_t offset, int64_t bytes,
52 QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags);
53int coroutine_fn GRAPH_RDLOCK bdrv_co_pwritev(BdrvChild *child,
54 int64_t offset, int64_t bytes, QEMUIOVector *qiov,
55 BdrvRequestFlags flags);
56int coroutine_fn GRAPH_RDLOCK bdrv_co_pwritev_part(BdrvChild *child,
57 int64_t offset, int64_t bytes,
58 QEMUIOVector *qiov, size_t qiov_offset, BdrvRequestFlags flags);
59
60static inline int coroutine_fn GRAPH_RDLOCK bdrv_co_pread(BdrvChild *child,
61 int64_t offset, int64_t bytes, void *buf, BdrvRequestFlags flags)
62{
63 QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes);
64 IO_CODE();
65 assert_bdrv_graph_readable();
66
67 return bdrv_co_preadv(child, offset, bytes, &qiov, flags);
68}
69
70static inline int coroutine_fn GRAPH_RDLOCK bdrv_co_pwrite(BdrvChild *child,
71 int64_t offset, int64_t bytes, const void *buf, BdrvRequestFlags flags)
72{
73 QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes);
74 IO_CODE();
75 assert_bdrv_graph_readable();
76
77 return bdrv_co_pwritev(child, offset, bytes, &qiov, flags);
78}
79
80void coroutine_fn bdrv_make_request_serialising(BdrvTrackedRequest *req,
81 uint64_t align);
82BdrvTrackedRequest *coroutine_fn bdrv_co_get_self_request(BlockDriverState *bs);
83
84BlockDriver *bdrv_probe_all(const uint8_t *buf, int buf_size,
85 const char *filename);
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100void bdrv_wakeup(BlockDriverState *bs);
101
102const char *bdrv_get_parent_name(const BlockDriverState *bs);
103bool blk_dev_has_tray(BlockBackend *blk);
104bool blk_dev_is_tray_open(BlockBackend *blk);
105
106void bdrv_set_dirty(BlockDriverState *bs, int64_t offset, int64_t bytes);
107
108void bdrv_clear_dirty_bitmap(BdrvDirtyBitmap *bitmap, HBitmap **out);
109void bdrv_dirty_bitmap_merge_internal(BdrvDirtyBitmap *dest,
110 const BdrvDirtyBitmap *src,
111 HBitmap **backup, bool lock);
112
113void bdrv_inc_in_flight(BlockDriverState *bs);
114void bdrv_dec_in_flight(BlockDriverState *bs);
115
116int coroutine_fn GRAPH_RDLOCK
117bdrv_co_copy_range_from(BdrvChild *src, int64_t src_offset,
118 BdrvChild *dst, int64_t dst_offset,
119 int64_t bytes, BdrvRequestFlags read_flags,
120 BdrvRequestFlags write_flags);
121int coroutine_fn GRAPH_RDLOCK
122bdrv_co_copy_range_to(BdrvChild *src, int64_t src_offset,
123 BdrvChild *dst, int64_t dst_offset,
124 int64_t bytes, BdrvRequestFlags read_flags,
125 BdrvRequestFlags write_flags);
126
127int coroutine_fn GRAPH_RDLOCK
128bdrv_co_refresh_total_sectors(BlockDriverState *bs, int64_t hint);
129
130int co_wrapper_mixed_bdrv_rdlock
131bdrv_refresh_total_sectors(BlockDriverState *bs, int64_t hint);
132
133BdrvChild *bdrv_cow_child(BlockDriverState *bs);
134BdrvChild *bdrv_filter_child(BlockDriverState *bs);
135BdrvChild *bdrv_filter_or_cow_child(BlockDriverState *bs);
136BdrvChild *bdrv_primary_child(BlockDriverState *bs);
137BlockDriverState *bdrv_skip_filters(BlockDriverState *bs);
138BlockDriverState *bdrv_backing_chain_next(BlockDriverState *bs);
139
140static inline BlockDriverState *bdrv_cow_bs(BlockDriverState *bs)
141{
142 IO_CODE();
143 return child_bs(bdrv_cow_child(bs));
144}
145
146static inline BlockDriverState *bdrv_filter_bs(BlockDriverState *bs)
147{
148 IO_CODE();
149 return child_bs(bdrv_filter_child(bs));
150}
151
152static inline BlockDriverState *bdrv_filter_or_cow_bs(BlockDriverState *bs)
153{
154 IO_CODE();
155 return child_bs(bdrv_filter_or_cow_child(bs));
156}
157
158static inline BlockDriverState *bdrv_primary_bs(BlockDriverState *bs)
159{
160 IO_CODE();
161 return child_bs(bdrv_primary_child(bs));
162}
163
164
165
166
167
168
169
170
171
172
173bool bdrv_bsc_is_data(BlockDriverState *bs, int64_t offset, int64_t *pnum);
174
175
176
177
178
179
180
181
182void bdrv_bsc_invalidate_range(BlockDriverState *bs,
183 int64_t offset, int64_t bytes);
184
185
186
187
188void bdrv_bsc_fill(BlockDriverState *bs, int64_t offset, int64_t bytes);
189
190#endif
191