1#ifndef BLOCK_H
2#define BLOCK_H
3
4#include "block/aio.h"
5#include "block/aio-wait.h"
6#include "qemu/iov.h"
7#include "qemu/coroutine.h"
8#include "block/accounting.h"
9#include "block/dirty-bitmap.h"
10#include "block/blockjob.h"
11#include "qemu/hbitmap.h"
12#include "qemu/transactions.h"
13
14
15
16
17
18
19
20
21
22#define generated_co_wrapper
23
24
25typedef struct BlockDriver BlockDriver;
26typedef struct BdrvChild BdrvChild;
27typedef struct BdrvChildClass BdrvChildClass;
28
29typedef struct BlockDriverInfo {
30
31 int cluster_size;
32
33 int64_t vm_state_offset;
34 bool is_dirty;
35
36
37
38 bool needs_compressed_writes;
39} BlockDriverInfo;
40
41typedef struct BlockFragInfo {
42 uint64_t allocated_clusters;
43 uint64_t total_clusters;
44 uint64_t fragmented_clusters;
45 uint64_t compressed_clusters;
46} BlockFragInfo;
47
48typedef enum {
49 BDRV_REQ_COPY_ON_READ = 0x1,
50 BDRV_REQ_ZERO_WRITE = 0x2,
51
52
53
54
55
56
57
58 BDRV_REQ_MAY_UNMAP = 0x4,
59
60 BDRV_REQ_FUA = 0x10,
61 BDRV_REQ_WRITE_COMPRESSED = 0x20,
62
63
64
65 BDRV_REQ_WRITE_UNCHANGED = 0x40,
66
67
68 BDRV_REQ_SERIALISING = 0x80,
69
70
71
72
73 BDRV_REQ_NO_FALLBACK = 0x100,
74
75
76
77
78
79
80
81
82 BDRV_REQ_PREFETCH = 0x200,
83
84
85
86
87
88 BDRV_REQ_NO_WAIT = 0x400,
89
90
91 BDRV_REQ_MASK = 0x7ff,
92} BdrvRequestFlags;
93
94typedef struct BlockSizes {
95 uint32_t phys;
96 uint32_t log;
97} BlockSizes;
98
99typedef struct HDGeometry {
100 uint32_t heads;
101 uint32_t sectors;
102 uint32_t cylinders;
103} HDGeometry;
104
105#define BDRV_O_NO_SHARE 0x0001
106#define BDRV_O_RDWR 0x0002
107#define BDRV_O_RESIZE 0x0004
108#define BDRV_O_SNAPSHOT 0x0008
109#define BDRV_O_TEMPORARY 0x0010
110#define BDRV_O_NOCACHE 0x0020
111#define BDRV_O_NATIVE_AIO 0x0080
112#define BDRV_O_NO_BACKING 0x0100
113#define BDRV_O_NO_FLUSH 0x0200
114#define BDRV_O_COPY_ON_READ 0x0400
115#define BDRV_O_INACTIVE 0x0800
116#define BDRV_O_CHECK 0x1000
117#define BDRV_O_ALLOW_RDWR 0x2000
118#define BDRV_O_UNMAP 0x4000
119#define BDRV_O_PROTOCOL 0x8000
120
121
122#define BDRV_O_NO_IO 0x10000
123#define BDRV_O_AUTO_RDONLY 0x20000
124#define BDRV_O_IO_URING 0x40000
125
126#define BDRV_O_CACHE_MASK (BDRV_O_NOCACHE | BDRV_O_NO_FLUSH)
127
128
129
130
131#define BDRV_OPT_CACHE_WB "cache.writeback"
132#define BDRV_OPT_CACHE_DIRECT "cache.direct"
133#define BDRV_OPT_CACHE_NO_FLUSH "cache.no-flush"
134#define BDRV_OPT_READ_ONLY "read-only"
135#define BDRV_OPT_AUTO_READ_ONLY "auto-read-only"
136#define BDRV_OPT_DISCARD "discard"
137#define BDRV_OPT_FORCE_SHARE "force-share"
138
139
140#define BDRV_SECTOR_BITS 9
141#define BDRV_SECTOR_SIZE (1ULL << BDRV_SECTOR_BITS)
142
143#define BDRV_REQUEST_MAX_SECTORS MIN_CONST(SIZE_MAX >> BDRV_SECTOR_BITS, \
144 INT_MAX >> BDRV_SECTOR_BITS)
145#define BDRV_REQUEST_MAX_BYTES (BDRV_REQUEST_MAX_SECTORS << BDRV_SECTOR_BITS)
146
147
148
149
150
151
152
153
154#define BDRV_MAX_ALIGNMENT (1L << 30)
155#define BDRV_MAX_LENGTH (QEMU_ALIGN_DOWN(INT64_MAX, BDRV_MAX_ALIGNMENT))
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196#define BDRV_BLOCK_DATA 0x01
197#define BDRV_BLOCK_ZERO 0x02
198#define BDRV_BLOCK_OFFSET_VALID 0x04
199#define BDRV_BLOCK_RAW 0x08
200#define BDRV_BLOCK_ALLOCATED 0x10
201#define BDRV_BLOCK_EOF 0x20
202#define BDRV_BLOCK_RECURSE 0x40
203
204typedef QTAILQ_HEAD(BlockReopenQueue, BlockReopenQueueEntry) BlockReopenQueue;
205
206typedef struct BDRVReopenState {
207 BlockDriverState *bs;
208 int flags;
209 BlockdevDetectZeroesOptions detect_zeroes;
210 bool backing_missing;
211 BlockDriverState *old_backing_bs;
212 BlockDriverState *old_file_bs;
213 QDict *options;
214 QDict *explicit_options;
215 void *opaque;
216} BDRVReopenState;
217
218
219
220
221typedef enum BlockOpType {
222 BLOCK_OP_TYPE_BACKUP_SOURCE,
223 BLOCK_OP_TYPE_BACKUP_TARGET,
224 BLOCK_OP_TYPE_CHANGE,
225 BLOCK_OP_TYPE_COMMIT_SOURCE,
226 BLOCK_OP_TYPE_COMMIT_TARGET,
227 BLOCK_OP_TYPE_DATAPLANE,
228 BLOCK_OP_TYPE_DRIVE_DEL,
229 BLOCK_OP_TYPE_EJECT,
230 BLOCK_OP_TYPE_EXTERNAL_SNAPSHOT,
231 BLOCK_OP_TYPE_INTERNAL_SNAPSHOT,
232 BLOCK_OP_TYPE_INTERNAL_SNAPSHOT_DELETE,
233 BLOCK_OP_TYPE_MIRROR_SOURCE,
234 BLOCK_OP_TYPE_MIRROR_TARGET,
235 BLOCK_OP_TYPE_RESIZE,
236 BLOCK_OP_TYPE_STREAM,
237 BLOCK_OP_TYPE_REPLACE,
238 BLOCK_OP_TYPE_MAX,
239} BlockOpType;
240
241
242enum {
243
244
245
246
247
248
249
250
251
252
253 BLK_PERM_CONSISTENT_READ = 0x01,
254
255
256 BLK_PERM_WRITE = 0x02,
257
258
259
260
261
262
263
264
265
266 BLK_PERM_WRITE_UNCHANGED = 0x04,
267
268
269 BLK_PERM_RESIZE = 0x08,
270
271
272
273
274
275 BLK_PERM_GRAPH_MOD = 0x10,
276
277 BLK_PERM_ALL = 0x1f,
278
279 DEFAULT_PERM_PASSTHROUGH = BLK_PERM_CONSISTENT_READ
280 | BLK_PERM_WRITE
281 | BLK_PERM_WRITE_UNCHANGED
282 | BLK_PERM_RESIZE,
283
284 DEFAULT_PERM_UNCHANGED = BLK_PERM_ALL & ~DEFAULT_PERM_PASSTHROUGH,
285};
286
287
288
289
290
291
292
293
294enum BdrvChildRoleBits {
295
296
297
298
299 BDRV_CHILD_DATA = (1 << 0),
300
301
302
303
304
305
306 BDRV_CHILD_METADATA = (1 << 1),
307
308
309
310
311
312
313
314
315 BDRV_CHILD_FILTERED = (1 << 2),
316
317
318
319
320
321
322
323
324
325 BDRV_CHILD_COW = (1 << 3),
326
327
328
329
330
331
332 BDRV_CHILD_PRIMARY = (1 << 4),
333
334
335 BDRV_CHILD_IMAGE = BDRV_CHILD_DATA
336 | BDRV_CHILD_METADATA
337 | BDRV_CHILD_PRIMARY,
338};
339
340
341typedef unsigned int BdrvChildRole;
342
343char *bdrv_perm_names(uint64_t perm);
344uint64_t bdrv_qapi_perm_to_blk_perm(BlockPermission qapi_perm);
345
346
347void bdrv_init(void);
348void bdrv_init_with_whitelist(void);
349bool bdrv_uses_whitelist(void);
350int bdrv_is_whitelisted(BlockDriver *drv, bool read_only);
351BlockDriver *bdrv_find_protocol(const char *filename,
352 bool allow_protocol_prefix,
353 Error **errp);
354BlockDriver *bdrv_find_format(const char *format_name);
355int bdrv_create(BlockDriver *drv, const char* filename,
356 QemuOpts *opts, Error **errp);
357int bdrv_create_file(const char *filename, QemuOpts *opts, Error **errp);
358
359BlockDriverState *bdrv_new(void);
360int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top,
361 Error **errp);
362int bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
363 Error **errp);
364int bdrv_replace_child_bs(BdrvChild *child, BlockDriverState *new_bs,
365 Error **errp);
366BlockDriverState *bdrv_insert_node(BlockDriverState *bs, QDict *node_options,
367 int flags, Error **errp);
368int bdrv_drop_filter(BlockDriverState *bs, Error **errp);
369
370int bdrv_parse_aio(const char *mode, int *flags);
371int bdrv_parse_cache_mode(const char *mode, int *flags, bool *writethrough);
372int bdrv_parse_discard_flags(const char *mode, int *flags);
373BdrvChild *bdrv_open_child(const char *filename,
374 QDict *options, const char *bdref_key,
375 BlockDriverState* parent,
376 const BdrvChildClass *child_class,
377 BdrvChildRole child_role,
378 bool allow_none, Error **errp);
379BlockDriverState *bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp);
380int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd,
381 Error **errp);
382int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options,
383 const char *bdref_key, Error **errp);
384BlockDriverState *bdrv_open(const char *filename, const char *reference,
385 QDict *options, int flags, Error **errp);
386BlockDriverState *bdrv_new_open_driver_opts(BlockDriver *drv,
387 const char *node_name,
388 QDict *options, int flags,
389 Error **errp);
390BlockDriverState *bdrv_new_open_driver(BlockDriver *drv, const char *node_name,
391 int flags, Error **errp);
392BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue,
393 BlockDriverState *bs, QDict *options,
394 bool keep_old_opts);
395void bdrv_reopen_queue_free(BlockReopenQueue *bs_queue);
396int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp);
397int bdrv_reopen(BlockDriverState *bs, QDict *opts, bool keep_old_opts,
398 Error **errp);
399int bdrv_reopen_set_read_only(BlockDriverState *bs, bool read_only,
400 Error **errp);
401int bdrv_pwrite_zeroes(BdrvChild *child, int64_t offset,
402 int64_t bytes, BdrvRequestFlags flags);
403int bdrv_make_zero(BdrvChild *child, BdrvRequestFlags flags);
404int bdrv_pread(BdrvChild *child, int64_t offset, void *buf, int64_t bytes);
405int bdrv_pwrite(BdrvChild *child, int64_t offset, const void *buf,
406 int64_t bytes);
407int bdrv_pwrite_sync(BdrvChild *child, int64_t offset,
408 const void *buf, int64_t bytes);
409
410
411
412
413
414
415int coroutine_fn bdrv_co_pwrite_zeroes(BdrvChild *child, int64_t offset,
416 int64_t bytes, BdrvRequestFlags flags);
417BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs,
418 const char *backing_file);
419void bdrv_refresh_filename(BlockDriverState *bs);
420
421int coroutine_fn bdrv_co_truncate(BdrvChild *child, int64_t offset, bool exact,
422 PreallocMode prealloc, BdrvRequestFlags flags,
423 Error **errp);
424int generated_co_wrapper
425bdrv_truncate(BdrvChild *child, int64_t offset, bool exact,
426 PreallocMode prealloc, BdrvRequestFlags flags, Error **errp);
427
428int64_t bdrv_nb_sectors(BlockDriverState *bs);
429int64_t bdrv_getlength(BlockDriverState *bs);
430int64_t bdrv_get_allocated_file_size(BlockDriverState *bs);
431BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOpts *opts,
432 BlockDriverState *in_bs, Error **errp);
433void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr);
434void bdrv_refresh_limits(BlockDriverState *bs, Transaction *tran, Error **errp);
435int bdrv_commit(BlockDriverState *bs);
436int bdrv_make_empty(BdrvChild *c, Error **errp);
437int bdrv_change_backing_file(BlockDriverState *bs, const char *backing_file,
438 const char *backing_fmt, bool warn);
439void bdrv_register(BlockDriver *bdrv);
440int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base,
441 const char *backing_file_str);
442BlockDriverState *bdrv_find_overlay(BlockDriverState *active,
443 BlockDriverState *bs);
444BlockDriverState *bdrv_find_base(BlockDriverState *bs);
445bool bdrv_is_backing_chain_frozen(BlockDriverState *bs, BlockDriverState *base,
446 Error **errp);
447int bdrv_freeze_backing_chain(BlockDriverState *bs, BlockDriverState *base,
448 Error **errp);
449void bdrv_unfreeze_backing_chain(BlockDriverState *bs, BlockDriverState *base);
450int coroutine_fn bdrv_co_delete_file(BlockDriverState *bs, Error **errp);
451void coroutine_fn bdrv_co_delete_file_noerr(BlockDriverState *bs);
452
453
454typedef struct BdrvCheckResult {
455 int corruptions;
456 int leaks;
457 int check_errors;
458 int corruptions_fixed;
459 int leaks_fixed;
460 int64_t image_end_offset;
461 BlockFragInfo bfi;
462} BdrvCheckResult;
463
464typedef enum {
465 BDRV_FIX_LEAKS = 1,
466 BDRV_FIX_ERRORS = 2,
467} BdrvCheckMode;
468
469int generated_co_wrapper bdrv_check(BlockDriverState *bs, BdrvCheckResult *res,
470 BdrvCheckMode fix);
471
472
473
474
475typedef void BlockDriverAmendStatusCB(BlockDriverState *bs, int64_t offset,
476 int64_t total_work_size, void *opaque);
477int bdrv_amend_options(BlockDriverState *bs_new, QemuOpts *opts,
478 BlockDriverAmendStatusCB *status_cb, void *cb_opaque,
479 bool force,
480 Error **errp);
481
482
483BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs,
484 const char *node_name, Error **errp);
485
486
487void bdrv_aio_cancel(BlockAIOCB *acb);
488void bdrv_aio_cancel_async(BlockAIOCB *acb);
489
490
491int bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf);
492
493
494int generated_co_wrapper bdrv_invalidate_cache(BlockDriverState *bs,
495 Error **errp);
496void bdrv_invalidate_cache_all(Error **errp);
497int bdrv_inactivate_all(void);
498
499
500int generated_co_wrapper bdrv_flush(BlockDriverState *bs);
501int coroutine_fn bdrv_co_flush(BlockDriverState *bs);
502int bdrv_flush_all(void);
503void bdrv_close_all(void);
504void bdrv_drain(BlockDriverState *bs);
505void coroutine_fn bdrv_co_drain(BlockDriverState *bs);
506void bdrv_drain_all_begin(void);
507void bdrv_drain_all_end(void);
508void bdrv_drain_all(void);
509
510#define BDRV_POLL_WHILE(bs, cond) ({ \
511 BlockDriverState *bs_ = (bs); \
512 AIO_WAIT_WHILE(bdrv_get_aio_context(bs_), \
513 cond); })
514
515int generated_co_wrapper bdrv_pdiscard(BdrvChild *child, int64_t offset,
516 int64_t bytes);
517int bdrv_co_pdiscard(BdrvChild *child, int64_t offset, int64_t bytes);
518int bdrv_has_zero_init_1(BlockDriverState *bs);
519int bdrv_has_zero_init(BlockDriverState *bs);
520bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs);
521int bdrv_block_status(BlockDriverState *bs, int64_t offset,
522 int64_t bytes, int64_t *pnum, int64_t *map,
523 BlockDriverState **file);
524int bdrv_block_status_above(BlockDriverState *bs, BlockDriverState *base,
525 int64_t offset, int64_t bytes, int64_t *pnum,
526 int64_t *map, BlockDriverState **file);
527int bdrv_is_allocated(BlockDriverState *bs, int64_t offset, int64_t bytes,
528 int64_t *pnum);
529int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
530 bool include_base, int64_t offset, int64_t bytes,
531 int64_t *pnum);
532int coroutine_fn bdrv_co_is_zero_fast(BlockDriverState *bs, int64_t offset,
533 int64_t bytes);
534
535bool bdrv_is_read_only(BlockDriverState *bs);
536int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only,
537 bool ignore_allow_rdw, Error **errp);
538int bdrv_apply_auto_read_only(BlockDriverState *bs, const char *errmsg,
539 Error **errp);
540bool bdrv_is_writable(BlockDriverState *bs);
541bool bdrv_is_sg(BlockDriverState *bs);
542bool bdrv_is_inserted(BlockDriverState *bs);
543void bdrv_lock_medium(BlockDriverState *bs, bool locked);
544void bdrv_eject(BlockDriverState *bs, bool eject_flag);
545const char *bdrv_get_format_name(BlockDriverState *bs);
546BlockDriverState *bdrv_find_node(const char *node_name);
547BlockDeviceInfoList *bdrv_named_nodes_list(bool flat, Error **errp);
548XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **errp);
549BlockDriverState *bdrv_lookup_bs(const char *device,
550 const char *node_name,
551 Error **errp);
552bool bdrv_chain_contains(BlockDriverState *top, BlockDriverState *base);
553BlockDriverState *bdrv_next_node(BlockDriverState *bs);
554BlockDriverState *bdrv_next_all_states(BlockDriverState *bs);
555
556typedef struct BdrvNextIterator {
557 enum {
558 BDRV_NEXT_BACKEND_ROOTS,
559 BDRV_NEXT_MONITOR_OWNED,
560 } phase;
561 BlockBackend *blk;
562 BlockDriverState *bs;
563} BdrvNextIterator;
564
565BlockDriverState *bdrv_first(BdrvNextIterator *it);
566BlockDriverState *bdrv_next(BdrvNextIterator *it);
567void bdrv_next_cleanup(BdrvNextIterator *it);
568
569BlockDriverState *bdrv_next_monitor_owned(BlockDriverState *bs);
570bool bdrv_supports_compressed_writes(BlockDriverState *bs);
571void bdrv_iterate_format(void (*it)(void *opaque, const char *name),
572 void *opaque, bool read_only);
573const char *bdrv_get_node_name(const BlockDriverState *bs);
574const char *bdrv_get_device_name(const BlockDriverState *bs);
575const char *bdrv_get_device_or_node_name(const BlockDriverState *bs);
576int bdrv_get_flags(BlockDriverState *bs);
577int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi);
578ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs,
579 Error **errp);
580BlockStatsSpecific *bdrv_get_specific_stats(BlockDriverState *bs);
581void bdrv_round_to_clusters(BlockDriverState *bs,
582 int64_t offset, int64_t bytes,
583 int64_t *cluster_offset,
584 int64_t *cluster_bytes);
585
586void bdrv_get_backing_filename(BlockDriverState *bs,
587 char *filename, int filename_size);
588char *bdrv_get_full_backing_filename(BlockDriverState *bs, Error **errp);
589char *bdrv_get_full_backing_filename_from_filename(const char *backed,
590 const char *backing,
591 Error **errp);
592char *bdrv_dirname(BlockDriverState *bs, Error **errp);
593
594int path_has_protocol(const char *path);
595int path_is_absolute(const char *path);
596char *path_combine(const char *base_path, const char *filename);
597
598int generated_co_wrapper
599bdrv_readv_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos);
600int generated_co_wrapper
601bdrv_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos);
602int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf,
603 int64_t pos, int size);
604
605int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf,
606 int64_t pos, int size);
607
608void bdrv_img_create(const char *filename, const char *fmt,
609 const char *base_filename, const char *base_fmt,
610 char *options, uint64_t img_size, int flags,
611 bool quiet, Error **errp);
612
613
614
615size_t bdrv_min_mem_align(BlockDriverState *bs);
616
617size_t bdrv_opt_mem_align(BlockDriverState *bs);
618void *qemu_blockalign(BlockDriverState *bs, size_t size);
619void *qemu_blockalign0(BlockDriverState *bs, size_t size);
620void *qemu_try_blockalign(BlockDriverState *bs, size_t size);
621void *qemu_try_blockalign0(BlockDriverState *bs, size_t size);
622bool bdrv_qiov_is_aligned(BlockDriverState *bs, QEMUIOVector *qiov);
623
624void bdrv_enable_copy_on_read(BlockDriverState *bs);
625void bdrv_disable_copy_on_read(BlockDriverState *bs);
626
627void bdrv_ref(BlockDriverState *bs);
628void bdrv_unref(BlockDriverState *bs);
629void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child);
630BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs,
631 BlockDriverState *child_bs,
632 const char *child_name,
633 const BdrvChildClass *child_class,
634 BdrvChildRole child_role,
635 Error **errp);
636
637bool bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp);
638void bdrv_op_block(BlockDriverState *bs, BlockOpType op, Error *reason);
639void bdrv_op_unblock(BlockDriverState *bs, BlockOpType op, Error *reason);
640void bdrv_op_block_all(BlockDriverState *bs, Error *reason);
641void bdrv_op_unblock_all(BlockDriverState *bs, Error *reason);
642bool bdrv_op_blocker_is_empty(BlockDriverState *bs);
643
644#define BLKDBG_EVENT(child, evt) \
645 do { \
646 if (child) { \
647 bdrv_debug_event(child->bs, evt); \
648 } \
649 } while (0)
650
651void bdrv_debug_event(BlockDriverState *bs, BlkdebugEvent event);
652
653int bdrv_debug_breakpoint(BlockDriverState *bs, const char *event,
654 const char *tag);
655int bdrv_debug_remove_breakpoint(BlockDriverState *bs, const char *tag);
656int bdrv_debug_resume(BlockDriverState *bs, const char *tag);
657bool bdrv_debug_is_suspended(BlockDriverState *bs, const char *tag);
658
659
660
661
662
663
664AioContext *bdrv_get_aio_context(BlockDriverState *bs);
665
666
667
668
669
670
671
672
673
674
675AioContext *coroutine_fn bdrv_co_enter(BlockDriverState *bs);
676
677
678
679
680
681void coroutine_fn bdrv_co_leave(BlockDriverState *bs, AioContext *old_ctx);
682
683
684
685
686
687
688
689
690void coroutine_fn bdrv_co_lock(BlockDriverState *bs);
691
692
693
694
695void coroutine_fn bdrv_co_unlock(BlockDriverState *bs);
696
697
698
699
700void bdrv_coroutine_enter(BlockDriverState *bs, Coroutine *co);
701
702void bdrv_set_aio_context_ignore(BlockDriverState *bs,
703 AioContext *new_context, GSList **ignore);
704int bdrv_try_set_aio_context(BlockDriverState *bs, AioContext *ctx,
705 Error **errp);
706int bdrv_child_try_set_aio_context(BlockDriverState *bs, AioContext *ctx,
707 BdrvChild *ignore_child, Error **errp);
708bool bdrv_child_can_set_aio_context(BdrvChild *c, AioContext *ctx,
709 GSList **ignore, Error **errp);
710bool bdrv_can_set_aio_context(BlockDriverState *bs, AioContext *ctx,
711 GSList **ignore, Error **errp);
712AioContext *bdrv_child_get_parent_aio_context(BdrvChild *c);
713AioContext *child_of_bds_get_parent_aio_context(BdrvChild *c);
714
715int bdrv_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz);
716int bdrv_probe_geometry(BlockDriverState *bs, HDGeometry *geo);
717
718void bdrv_io_plug(BlockDriverState *bs);
719void bdrv_io_unplug(BlockDriverState *bs);
720
721
722
723
724
725
726
727void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll);
728
729
730
731
732
733
734
735
736
737void bdrv_parent_drained_end_single(BdrvChild *c);
738
739
740
741
742
743
744
745
746
747
748
749
750
751bool bdrv_drain_poll(BlockDriverState *bs, bool recursive,
752 BdrvChild *ignore_parent, bool ignore_bds_parents);
753
754
755
756
757
758
759
760
761
762void bdrv_drained_begin(BlockDriverState *bs);
763
764
765
766
767
768
769
770void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
771 BdrvChild *parent, bool ignore_bds_parents);
772
773
774
775
776
777void bdrv_subtree_drained_begin(BlockDriverState *bs);
778
779
780
781
782
783
784
785
786
787
788
789
790void bdrv_drained_end(BlockDriverState *bs);
791
792
793
794
795
796
797
798
799
800
801
802
803
804void bdrv_drained_end_no_poll(BlockDriverState *bs, int *drained_end_counter);
805
806
807
808
809void bdrv_subtree_drained_end(BlockDriverState *bs);
810
811void bdrv_add_child(BlockDriverState *parent, BlockDriverState *child,
812 Error **errp);
813void bdrv_del_child(BlockDriverState *parent, BdrvChild *child, Error **errp);
814
815bool bdrv_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *name,
816 uint32_t granularity, Error **errp);
817
818
819
820
821
822
823
824
825void bdrv_register_buf(BlockDriverState *bs, void *host, size_t size);
826void bdrv_unregister_buf(BlockDriverState *bs, void *host);
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857int coroutine_fn bdrv_co_copy_range(BdrvChild *src, int64_t src_offset,
858 BdrvChild *dst, int64_t dst_offset,
859 int64_t bytes, BdrvRequestFlags read_flags,
860 BdrvRequestFlags write_flags);
861
862void bdrv_cancel_in_flight(BlockDriverState *bs);
863
864#endif
865