xref: /qemu/block/coroutines.h (revision 69aa0d37)
121c2283eSVladimir Sementsov-Ogievskiy /*
221c2283eSVladimir Sementsov-Ogievskiy  * Block layer I/O functions
321c2283eSVladimir Sementsov-Ogievskiy  *
421c2283eSVladimir Sementsov-Ogievskiy  * Copyright (c) 2003 Fabrice Bellard
521c2283eSVladimir Sementsov-Ogievskiy  *
621c2283eSVladimir Sementsov-Ogievskiy  * Permission is hereby granted, free of charge, to any person obtaining a copy
721c2283eSVladimir Sementsov-Ogievskiy  * of this software and associated documentation files (the "Software"), to deal
821c2283eSVladimir Sementsov-Ogievskiy  * in the Software without restriction, including without limitation the rights
921c2283eSVladimir Sementsov-Ogievskiy  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1021c2283eSVladimir Sementsov-Ogievskiy  * copies of the Software, and to permit persons to whom the Software is
1121c2283eSVladimir Sementsov-Ogievskiy  * furnished to do so, subject to the following conditions:
1221c2283eSVladimir Sementsov-Ogievskiy  *
1321c2283eSVladimir Sementsov-Ogievskiy  * The above copyright notice and this permission notice shall be included in
1421c2283eSVladimir Sementsov-Ogievskiy  * all copies or substantial portions of the Software.
1521c2283eSVladimir Sementsov-Ogievskiy  *
1621c2283eSVladimir Sementsov-Ogievskiy  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1721c2283eSVladimir Sementsov-Ogievskiy  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1821c2283eSVladimir Sementsov-Ogievskiy  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
1921c2283eSVladimir Sementsov-Ogievskiy  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2021c2283eSVladimir Sementsov-Ogievskiy  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2121c2283eSVladimir Sementsov-Ogievskiy  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2221c2283eSVladimir Sementsov-Ogievskiy  * THE SOFTWARE.
2321c2283eSVladimir Sementsov-Ogievskiy  */
2421c2283eSVladimir Sementsov-Ogievskiy 
2552581c71SMarkus Armbruster #ifndef BLOCK_COROUTINES_H
2652581c71SMarkus Armbruster #define BLOCK_COROUTINES_H
2721c2283eSVladimir Sementsov-Ogievskiy 
2821c2283eSVladimir Sementsov-Ogievskiy #include "block/block_int.h"
2921c2283eSVladimir Sementsov-Ogievskiy 
307d55a3bbSVladimir Sementsov-Ogievskiy /* For blk_bs() in generated block/block-gen.c */
317d55a3bbSVladimir Sementsov-Ogievskiy #include "sysemu/block-backend.h"
327d55a3bbSVladimir Sementsov-Ogievskiy 
331581a70dSEmanuele Giuseppe Esposito /*
341581a70dSEmanuele Giuseppe Esposito  * I/O API functions. These functions are thread-safe.
351581a70dSEmanuele Giuseppe Esposito  *
361581a70dSEmanuele Giuseppe Esposito  * See include/block/block-io.h for more information about
371581a70dSEmanuele Giuseppe Esposito  * the I/O API.
381581a70dSEmanuele Giuseppe Esposito  */
391581a70dSEmanuele Giuseppe Esposito 
401b3ff9feSKevin Wolf int coroutine_fn GRAPH_RDLOCK
411b3ff9feSKevin Wolf bdrv_co_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix);
421b3ff9feSKevin Wolf 
431b3ff9feSKevin Wolf int coroutine_fn GRAPH_RDLOCK
441b3ff9feSKevin Wolf bdrv_co_invalidate_cache(BlockDriverState *bs, Error **errp);
4521c2283eSVladimir Sementsov-Ogievskiy 
467ff9579eSKevin Wolf int coroutine_fn GRAPH_RDLOCK
4721c2283eSVladimir Sementsov-Ogievskiy bdrv_co_common_block_status_above(BlockDriverState *bs,
4821c2283eSVladimir Sementsov-Ogievskiy                                   BlockDriverState *base,
493555a432SVladimir Sementsov-Ogievskiy                                   bool include_base,
5021c2283eSVladimir Sementsov-Ogievskiy                                   bool want_zero,
5121c2283eSVladimir Sementsov-Ogievskiy                                   int64_t offset,
5221c2283eSVladimir Sementsov-Ogievskiy                                   int64_t bytes,
5321c2283eSVladimir Sementsov-Ogievskiy                                   int64_t *pnum,
5421c2283eSVladimir Sementsov-Ogievskiy                                   int64_t *map,
55a92b1b06SEric Blake                                   BlockDriverState **file,
56a92b1b06SEric Blake                                   int *depth);
5721c2283eSVladimir Sementsov-Ogievskiy 
581b3ff9feSKevin Wolf int coroutine_fn GRAPH_RDLOCK
591b3ff9feSKevin Wolf bdrv_co_readv_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos);
601b3ff9feSKevin Wolf 
611b3ff9feSKevin Wolf int coroutine_fn GRAPH_RDLOCK
621b3ff9feSKevin Wolf bdrv_co_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos);
6321c2283eSVladimir Sementsov-Ogievskiy 
6469aa0d37SEmanuele Giuseppe Esposito int coroutine_fn GRAPH_RDLOCK
658610b449SPaolo Bonzini nbd_co_do_establish_connection(BlockDriverState *bs, bool blocking,
668610b449SPaolo Bonzini                                Error **errp);
67a71d597bSVladimir Sementsov-Ogievskiy 
68a71d597bSVladimir Sementsov-Ogievskiy 
691581a70dSEmanuele Giuseppe Esposito /*
701581a70dSEmanuele Giuseppe Esposito  * "I/O or GS" API functions. These functions can run without
711581a70dSEmanuele Giuseppe Esposito  * the BQL, but only in one specific iothread/main loop.
721581a70dSEmanuele Giuseppe Esposito  *
731581a70dSEmanuele Giuseppe Esposito  * See include/block/block-io.h for more information about
741581a70dSEmanuele Giuseppe Esposito  * the "I/O or GS" API.
751581a70dSEmanuele Giuseppe Esposito  */
761581a70dSEmanuele Giuseppe Esposito 
7790830f59SEmanuele Giuseppe Esposito int co_wrapper_mixed_bdrv_rdlock
781581a70dSEmanuele Giuseppe Esposito bdrv_common_block_status_above(BlockDriverState *bs,
791581a70dSEmanuele Giuseppe Esposito                                BlockDriverState *base,
801581a70dSEmanuele Giuseppe Esposito                                bool include_base,
811581a70dSEmanuele Giuseppe Esposito                                bool want_zero,
821581a70dSEmanuele Giuseppe Esposito                                int64_t offset,
831581a70dSEmanuele Giuseppe Esposito                                int64_t bytes,
841581a70dSEmanuele Giuseppe Esposito                                int64_t *pnum,
851581a70dSEmanuele Giuseppe Esposito                                int64_t *map,
861581a70dSEmanuele Giuseppe Esposito                                BlockDriverState **file,
871581a70dSEmanuele Giuseppe Esposito                                int *depth);
8869aa0d37SEmanuele Giuseppe Esposito 
8969aa0d37SEmanuele Giuseppe Esposito int co_wrapper_mixed_bdrv_rdlock
908610b449SPaolo Bonzini nbd_do_establish_connection(BlockDriverState *bs, bool blocking, Error **errp);
911581a70dSEmanuele Giuseppe Esposito 
9252581c71SMarkus Armbruster #endif /* BLOCK_COROUTINES_H */
93