xref: /openbmc/qemu/block/coroutines.h (revision 26ed501b)
1 /*
2  * Block layer I/O functions
3  *
4  * Copyright (c) 2003 Fabrice Bellard
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 
25 #ifndef BLOCK_COROUTINES_H
26 #define BLOCK_COROUTINES_H
27 
28 #include "block/block_int.h"
29 
30 /* For blk_bs() in generated block/block-gen.c */
31 #include "sysemu/block-backend.h"
32 
33 /*
34  * I/O API functions. These functions are thread-safe.
35  *
36  * See include/block/block-io.h for more information about
37  * the I/O API.
38  */
39 
40 int coroutine_fn bdrv_co_check(BlockDriverState *bs,
41                                BdrvCheckResult *res, BdrvCheckMode fix);
42 int coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, Error **errp);
43 
44 int coroutine_fn
45 bdrv_co_common_block_status_above(BlockDriverState *bs,
46                                   BlockDriverState *base,
47                                   bool include_base,
48                                   bool want_zero,
49                                   int64_t offset,
50                                   int64_t bytes,
51                                   int64_t *pnum,
52                                   int64_t *map,
53                                   BlockDriverState **file,
54                                   int *depth);
55 
56 int coroutine_fn bdrv_co_readv_vmstate(BlockDriverState *bs,
57                                        QEMUIOVector *qiov, int64_t pos);
58 int coroutine_fn bdrv_co_writev_vmstate(BlockDriverState *bs,
59                                         QEMUIOVector *qiov, int64_t pos);
60 
61 int coroutine_fn
62 nbd_co_do_establish_connection(BlockDriverState *bs, bool blocking,
63                                Error **errp);
64 
65 
66 int coroutine_fn
67 blk_co_do_preadv(BlockBackend *blk, int64_t offset, int64_t bytes,
68                  QEMUIOVector *qiov, BdrvRequestFlags flags);
69 
70 
71 int coroutine_fn
72 blk_co_do_pwritev_part(BlockBackend *blk, int64_t offset, int64_t bytes,
73                        QEMUIOVector *qiov, size_t qiov_offset,
74                        BdrvRequestFlags flags);
75 
76 int coroutine_fn
77 blk_co_do_ioctl(BlockBackend *blk, unsigned long int req, void *buf);
78 
79 int coroutine_fn
80 blk_co_do_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes);
81 
82 int coroutine_fn blk_co_do_flush(BlockBackend *blk);
83 
84 
85 /*
86  * "I/O or GS" API functions. These functions can run without
87  * the BQL, but only in one specific iothread/main loop.
88  *
89  * See include/block/block-io.h for more information about
90  * the "I/O or GS" API.
91  */
92 
93 int generated_co_wrapper
94 bdrv_preadv(BdrvChild *child, int64_t offset, unsigned int bytes,
95             QEMUIOVector *qiov, BdrvRequestFlags flags);
96 
97 int generated_co_wrapper
98 bdrv_pwritev(BdrvChild *child, int64_t offset, unsigned int bytes,
99              QEMUIOVector *qiov, BdrvRequestFlags flags);
100 
101 int generated_co_wrapper
102 bdrv_common_block_status_above(BlockDriverState *bs,
103                                BlockDriverState *base,
104                                bool include_base,
105                                bool want_zero,
106                                int64_t offset,
107                                int64_t bytes,
108                                int64_t *pnum,
109                                int64_t *map,
110                                BlockDriverState **file,
111                                int *depth);
112 int generated_co_wrapper
113 nbd_do_establish_connection(BlockDriverState *bs, bool blocking, Error **errp);
114 
115 int generated_co_wrapper
116 blk_do_preadv(BlockBackend *blk, int64_t offset, int64_t bytes,
117               QEMUIOVector *qiov, BdrvRequestFlags flags);
118 
119 int generated_co_wrapper
120 blk_do_pwritev_part(BlockBackend *blk, int64_t offset, int64_t bytes,
121                     QEMUIOVector *qiov, size_t qiov_offset,
122                     BdrvRequestFlags flags);
123 
124 int generated_co_wrapper
125 blk_do_ioctl(BlockBackend *blk, unsigned long int req, void *buf);
126 
127 int generated_co_wrapper
128 blk_do_pdiscard(BlockBackend *blk, int64_t offset, int64_t bytes);
129 
130 int generated_co_wrapper blk_do_flush(BlockBackend *blk);
131 
132 #endif /* BLOCK_COROUTINES_H */
133