13b491a90SEmanuele Giuseppe Esposito /* 23b491a90SEmanuele Giuseppe Esposito * QEMU System Emulator block driver 33b491a90SEmanuele Giuseppe Esposito * 43b491a90SEmanuele Giuseppe Esposito * Copyright (c) 2003 Fabrice Bellard 53b491a90SEmanuele Giuseppe Esposito * 63b491a90SEmanuele Giuseppe Esposito * Permission is hereby granted, free of charge, to any person obtaining a copy 73b491a90SEmanuele Giuseppe Esposito * of this software and associated documentation files (the "Software"), to deal 83b491a90SEmanuele Giuseppe Esposito * in the Software without restriction, including without limitation the rights 93b491a90SEmanuele Giuseppe Esposito * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 103b491a90SEmanuele Giuseppe Esposito * copies of the Software, and to permit persons to whom the Software is 113b491a90SEmanuele Giuseppe Esposito * furnished to do so, subject to the following conditions: 123b491a90SEmanuele Giuseppe Esposito * 133b491a90SEmanuele Giuseppe Esposito * The above copyright notice and this permission notice shall be included in 143b491a90SEmanuele Giuseppe Esposito * all copies or substantial portions of the Software. 153b491a90SEmanuele Giuseppe Esposito * 163b491a90SEmanuele Giuseppe Esposito * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 173b491a90SEmanuele Giuseppe Esposito * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 183b491a90SEmanuele Giuseppe Esposito * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 193b491a90SEmanuele Giuseppe Esposito * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 203b491a90SEmanuele Giuseppe Esposito * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 213b491a90SEmanuele Giuseppe Esposito * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 223b491a90SEmanuele Giuseppe Esposito * THE SOFTWARE. 233b491a90SEmanuele Giuseppe Esposito */ 243b491a90SEmanuele Giuseppe Esposito #ifndef BLOCK_GLOBAL_STATE_H 253b491a90SEmanuele Giuseppe Esposito #define BLOCK_GLOBAL_STATE_H 263b491a90SEmanuele Giuseppe Esposito 27e2c1c34fSMarkus Armbruster #include "block/block-common.h" 28e2c1c34fSMarkus Armbruster #include "qemu/coroutine.h" 29e2c1c34fSMarkus Armbruster #include "qemu/transactions.h" 303b491a90SEmanuele Giuseppe Esposito 313b491a90SEmanuele Giuseppe Esposito /* 323b491a90SEmanuele Giuseppe Esposito * Global state (GS) API. These functions run under the BQL. 333b491a90SEmanuele Giuseppe Esposito * 34b49f4755SStefan Hajnoczi * If a function modifies the graph, it also uses the graph lock to be sure it 35b49f4755SStefan Hajnoczi * has unique access. The graph lock is needed together with BQL because of the 36b49f4755SStefan Hajnoczi * thread-safe I/O API that concurrently runs and accesses the graph without 37b49f4755SStefan Hajnoczi * the BQL. 383b491a90SEmanuele Giuseppe Esposito * 393b491a90SEmanuele Giuseppe Esposito * It is important to note that not all of these functions are 403b491a90SEmanuele Giuseppe Esposito * necessarily limited to running under the BQL, but they would 413b491a90SEmanuele Giuseppe Esposito * require additional auditing and many small thread-safety changes 423b491a90SEmanuele Giuseppe Esposito * to move them into the I/O API. Often it's not worth doing that 433b491a90SEmanuele Giuseppe Esposito * work since the APIs are only used with the BQL held at the 443b491a90SEmanuele Giuseppe Esposito * moment, so they have been placed in the GS API (for now). 453b491a90SEmanuele Giuseppe Esposito * 463b491a90SEmanuele Giuseppe Esposito * These functions can call any function from this and other categories 473b491a90SEmanuele Giuseppe Esposito * (I/O, "I/O or GS", Common), but must be invoked only by other GS APIs. 483b491a90SEmanuele Giuseppe Esposito * 493b491a90SEmanuele Giuseppe Esposito * All functions in this header must use the macro 503b491a90SEmanuele Giuseppe Esposito * GLOBAL_STATE_CODE(); 513b491a90SEmanuele Giuseppe Esposito * to catch when they are accidentally called without the BQL. 523b491a90SEmanuele Giuseppe Esposito */ 533b491a90SEmanuele Giuseppe Esposito 543b491a90SEmanuele Giuseppe Esposito void bdrv_init(void); 553b491a90SEmanuele Giuseppe Esposito BlockDriver *bdrv_find_protocol(const char *filename, 563b491a90SEmanuele Giuseppe Esposito bool allow_protocol_prefix, 573b491a90SEmanuele Giuseppe Esposito Error **errp); 583b491a90SEmanuele Giuseppe Esposito BlockDriver *bdrv_find_format(const char *format_name); 59741443ebSEmanuele Giuseppe Esposito 604db7ba3bSKevin Wolf int coroutine_fn GRAPH_UNLOCKED 614ec8df01SKevin Wolf bdrv_co_create(BlockDriver *drv, const char *filename, QemuOpts *opts, 624ec8df01SKevin Wolf Error **errp); 634ec8df01SKevin Wolf 644db7ba3bSKevin Wolf int co_wrapper bdrv_create(BlockDriver *drv, const char *filename, 65741443ebSEmanuele Giuseppe Esposito QemuOpts *opts, Error **errp); 66741443ebSEmanuele Giuseppe Esposito 674db7ba3bSKevin Wolf int coroutine_fn GRAPH_UNLOCKED 684ec8df01SKevin Wolf bdrv_co_create_file(const char *filename, QemuOpts *opts, Error **errp); 693b491a90SEmanuele Giuseppe Esposito 703b491a90SEmanuele Giuseppe Esposito BlockDriverState *bdrv_new(void); 713b491a90SEmanuele Giuseppe Esposito int bdrv_append(BlockDriverState *bs_new, BlockDriverState *bs_top, 723b491a90SEmanuele Giuseppe Esposito Error **errp); 73ccd6a379SKevin Wolf 74ccd6a379SKevin Wolf int GRAPH_WRLOCK 75ccd6a379SKevin Wolf bdrv_replace_node(BlockDriverState *from, BlockDriverState *to, Error **errp); 76ccd6a379SKevin Wolf 773b491a90SEmanuele Giuseppe Esposito int bdrv_replace_child_bs(BdrvChild *child, BlockDriverState *new_bs, 783b491a90SEmanuele Giuseppe Esposito Error **errp); 793b491a90SEmanuele Giuseppe Esposito BlockDriverState *bdrv_insert_node(BlockDriverState *bs, QDict *node_options, 803b491a90SEmanuele Giuseppe Esposito int flags, Error **errp); 813b491a90SEmanuele Giuseppe Esposito int bdrv_drop_filter(BlockDriverState *bs, Error **errp); 823b491a90SEmanuele Giuseppe Esposito 834bee90e9SKevin Wolf BdrvChild * no_coroutine_fn 844bee90e9SKevin Wolf bdrv_open_child(const char *filename, QDict *options, const char *bdref_key, 854bee90e9SKevin Wolf BlockDriverState *parent, const BdrvChildClass *child_class, 864bee90e9SKevin Wolf BdrvChildRole child_role, bool allow_none, Error **errp); 874bee90e9SKevin Wolf 884bee90e9SKevin Wolf BdrvChild * coroutine_fn no_co_wrapper 894bee90e9SKevin Wolf bdrv_co_open_child(const char *filename, QDict *options, const char *bdref_key, 904bee90e9SKevin Wolf BlockDriverState *parent, const BdrvChildClass *child_class, 914bee90e9SKevin Wolf BdrvChildRole child_role, bool allow_none, Error **errp); 924bee90e9SKevin Wolf 9383930780SVladimir Sementsov-Ogievskiy int bdrv_open_file_child(const char *filename, 9483930780SVladimir Sementsov-Ogievskiy QDict *options, const char *bdref_key, 9583930780SVladimir Sementsov-Ogievskiy BlockDriverState *parent, Error **errp); 964bee90e9SKevin Wolf 974bee90e9SKevin Wolf BlockDriverState * no_coroutine_fn 984bee90e9SKevin Wolf bdrv_open_blockdev_ref(BlockdevRef *ref, Error **errp); 994bee90e9SKevin Wolf 1004bee90e9SKevin Wolf BlockDriverState * coroutine_fn no_co_wrapper 1014bee90e9SKevin Wolf bdrv_co_open_blockdev_ref(BlockdevRef *ref, Error **errp); 1024bee90e9SKevin Wolf 1033b491a90SEmanuele Giuseppe Esposito int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd, 1043b491a90SEmanuele Giuseppe Esposito Error **errp); 105d0f9fd94SKevin Wolf int GRAPH_WRLOCK 106d0f9fd94SKevin Wolf bdrv_set_backing_hd_drained(BlockDriverState *bs, BlockDriverState *backing_hd, 10792140b9fSKevin Wolf Error **errp); 108d0f9fd94SKevin Wolf 1093b491a90SEmanuele Giuseppe Esposito int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options, 1103b491a90SEmanuele Giuseppe Esposito const char *bdref_key, Error **errp); 1114bee90e9SKevin Wolf 1124bee90e9SKevin Wolf BlockDriverState * no_coroutine_fn 1134bee90e9SKevin Wolf bdrv_open(const char *filename, const char *reference, QDict *options, 1144bee90e9SKevin Wolf int flags, Error **errp); 1154bee90e9SKevin Wolf 1164bee90e9SKevin Wolf BlockDriverState * coroutine_fn no_co_wrapper 1174bee90e9SKevin Wolf bdrv_co_open(const char *filename, const char *reference, 1183b491a90SEmanuele Giuseppe Esposito QDict *options, int flags, Error **errp); 1194bee90e9SKevin Wolf 1203b491a90SEmanuele Giuseppe Esposito BlockDriverState *bdrv_new_open_driver_opts(BlockDriver *drv, 1213b491a90SEmanuele Giuseppe Esposito const char *node_name, 1223b491a90SEmanuele Giuseppe Esposito QDict *options, int flags, 1233b491a90SEmanuele Giuseppe Esposito Error **errp); 1243b491a90SEmanuele Giuseppe Esposito BlockDriverState *bdrv_new_open_driver(BlockDriver *drv, const char *node_name, 1253b491a90SEmanuele Giuseppe Esposito int flags, Error **errp); 1263b491a90SEmanuele Giuseppe Esposito BlockReopenQueue *bdrv_reopen_queue(BlockReopenQueue *bs_queue, 1273b491a90SEmanuele Giuseppe Esposito BlockDriverState *bs, QDict *options, 1283b491a90SEmanuele Giuseppe Esposito bool keep_old_opts); 1293b491a90SEmanuele Giuseppe Esposito void bdrv_reopen_queue_free(BlockReopenQueue *bs_queue); 1303b491a90SEmanuele Giuseppe Esposito int bdrv_reopen_multiple(BlockReopenQueue *bs_queue, Error **errp); 1313b491a90SEmanuele Giuseppe Esposito int bdrv_reopen(BlockDriverState *bs, QDict *opts, bool keep_old_opts, 1323b491a90SEmanuele Giuseppe Esposito Error **errp); 1333b491a90SEmanuele Giuseppe Esposito int bdrv_reopen_set_read_only(BlockDriverState *bs, bool read_only, 1343b491a90SEmanuele Giuseppe Esposito Error **errp); 1353b491a90SEmanuele Giuseppe Esposito BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, 1363b491a90SEmanuele Giuseppe Esposito const char *backing_file); 137b7cfc7d5SKevin Wolf void GRAPH_RDLOCK bdrv_refresh_filename(BlockDriverState *bs); 138e19b157fSKevin Wolf 139e19b157fSKevin Wolf void GRAPH_RDLOCK 140e19b157fSKevin Wolf bdrv_refresh_limits(BlockDriverState *bs, Transaction *tran, Error **errp); 141e19b157fSKevin Wolf 1423b491a90SEmanuele Giuseppe Esposito int bdrv_commit(BlockDriverState *bs); 1430bb79c97SKevin Wolf int GRAPH_RDLOCK bdrv_make_empty(BdrvChild *c, Error **errp); 144e2dd2737SKevin Wolf 1453b491a90SEmanuele Giuseppe Esposito void bdrv_register(BlockDriver *bdrv); 1463b491a90SEmanuele Giuseppe Esposito int bdrv_drop_intermediate(BlockDriverState *top, BlockDriverState *base, 1474b028cbeSPeter Krempa const char *backing_file_str, 1484b028cbeSPeter Krempa bool backing_mask_protocol); 149ad74751fSKevin Wolf 150ad74751fSKevin Wolf BlockDriverState * GRAPH_RDLOCK 151ad74751fSKevin Wolf bdrv_find_overlay(BlockDriverState *active, BlockDriverState *bs); 152ad74751fSKevin Wolf 153ad74751fSKevin Wolf BlockDriverState * GRAPH_RDLOCK bdrv_find_base(BlockDriverState *bs); 1549275fc72SKevin Wolf 1559275fc72SKevin Wolf int GRAPH_RDLOCK 1569275fc72SKevin Wolf bdrv_freeze_backing_chain(BlockDriverState *bs, BlockDriverState *base, 1573b491a90SEmanuele Giuseppe Esposito Error **errp); 1589275fc72SKevin Wolf void GRAPH_RDLOCK 1599275fc72SKevin Wolf bdrv_unfreeze_backing_chain(BlockDriverState *bs, BlockDriverState *base); 1603b491a90SEmanuele Giuseppe Esposito 1613b491a90SEmanuele Giuseppe Esposito /* 1623b491a90SEmanuele Giuseppe Esposito * The units of offset and total_work_size may be chosen arbitrarily by the 1633b491a90SEmanuele Giuseppe Esposito * block driver; total_work_size may change during the course of the amendment 1643b491a90SEmanuele Giuseppe Esposito * operation 1653b491a90SEmanuele Giuseppe Esposito */ 1663b491a90SEmanuele Giuseppe Esposito typedef void BlockDriverAmendStatusCB(BlockDriverState *bs, int64_t offset, 1673b491a90SEmanuele Giuseppe Esposito int64_t total_work_size, void *opaque); 168bd131d67SKevin Wolf int GRAPH_RDLOCK 169bd131d67SKevin Wolf bdrv_amend_options(BlockDriverState *bs_new, QemuOpts *opts, 1703b491a90SEmanuele Giuseppe Esposito BlockDriverAmendStatusCB *status_cb, void *cb_opaque, 171bd131d67SKevin Wolf bool force, Error **errp); 1723b491a90SEmanuele Giuseppe Esposito 1733b491a90SEmanuele Giuseppe Esposito /* check if a named node can be replaced when doing drive-mirror */ 174533c6e4eSKevin Wolf BlockDriverState * GRAPH_RDLOCK 175533c6e4eSKevin Wolf check_to_replace_node(BlockDriverState *parent_bs, const char *node_name, 176533c6e4eSKevin Wolf Error **errp); 1773b491a90SEmanuele Giuseppe Esposito 1782b3912f1SKevin Wolf int no_coroutine_fn GRAPH_RDLOCK 1792b3912f1SKevin Wolf bdrv_activate(BlockDriverState *bs, Error **errp); 180da4afaffSKevin Wolf 1812b3912f1SKevin Wolf int coroutine_fn no_co_wrapper_bdrv_rdlock 182da4afaffSKevin Wolf bdrv_co_activate(BlockDriverState *bs, Error **errp); 183da4afaffSKevin Wolf 1843b491a90SEmanuele Giuseppe Esposito void bdrv_activate_all(Error **errp); 1853b491a90SEmanuele Giuseppe Esposito int bdrv_inactivate_all(void); 1863b491a90SEmanuele Giuseppe Esposito 1873b491a90SEmanuele Giuseppe Esposito int bdrv_flush_all(void); 1883b491a90SEmanuele Giuseppe Esposito void bdrv_close_all(void); 1893b491a90SEmanuele Giuseppe Esposito void bdrv_drain_all_begin(void); 190da0bd744SKevin Wolf void bdrv_drain_all_begin_nopoll(void); 1913b491a90SEmanuele Giuseppe Esposito void bdrv_drain_all_end(void); 1923b491a90SEmanuele Giuseppe Esposito void bdrv_drain_all(void); 1933b491a90SEmanuele Giuseppe Esposito 194652b0dd8SStefan Hajnoczi void bdrv_aio_cancel(BlockAIOCB *acb); 195652b0dd8SStefan Hajnoczi 1963b491a90SEmanuele Giuseppe Esposito int bdrv_has_zero_init_1(BlockDriverState *bs); 19706717986SKevin Wolf int coroutine_mixed_fn GRAPH_RDLOCK bdrv_has_zero_init(BlockDriverState *bs); 1983b491a90SEmanuele Giuseppe Esposito BlockDriverState *bdrv_find_node(const char *node_name); 1993b491a90SEmanuele Giuseppe Esposito BlockDeviceInfoList *bdrv_named_nodes_list(bool flat, Error **errp); 20015f3f1feSKevin Wolf XDbgBlockGraph * GRAPH_RDLOCK bdrv_get_xdbg_block_graph(Error **errp); 2013b491a90SEmanuele Giuseppe Esposito BlockDriverState *bdrv_lookup_bs(const char *device, 2023b491a90SEmanuele Giuseppe Esposito const char *node_name, 2033b491a90SEmanuele Giuseppe Esposito Error **errp); 20479bb7627SKevin Wolf bool GRAPH_RDLOCK 20579bb7627SKevin Wolf bdrv_chain_contains(BlockDriverState *top, BlockDriverState *base); 20679bb7627SKevin Wolf 2073b491a90SEmanuele Giuseppe Esposito BlockDriverState *bdrv_next_node(BlockDriverState *bs); 2083b491a90SEmanuele Giuseppe Esposito BlockDriverState *bdrv_next_all_states(BlockDriverState *bs); 2093b491a90SEmanuele Giuseppe Esposito 2103b491a90SEmanuele Giuseppe Esposito typedef struct BdrvNextIterator { 2113b491a90SEmanuele Giuseppe Esposito enum { 2123b491a90SEmanuele Giuseppe Esposito BDRV_NEXT_BACKEND_ROOTS, 2133b491a90SEmanuele Giuseppe Esposito BDRV_NEXT_MONITOR_OWNED, 2143b491a90SEmanuele Giuseppe Esposito } phase; 2153b491a90SEmanuele Giuseppe Esposito BlockBackend *blk; 2163b491a90SEmanuele Giuseppe Esposito BlockDriverState *bs; 2173b491a90SEmanuele Giuseppe Esposito } BdrvNextIterator; 2183b491a90SEmanuele Giuseppe Esposito 2192b3912f1SKevin Wolf BlockDriverState * GRAPH_RDLOCK bdrv_first(BdrvNextIterator *it); 2202b3912f1SKevin Wolf BlockDriverState * GRAPH_RDLOCK bdrv_next(BdrvNextIterator *it); 2213b491a90SEmanuele Giuseppe Esposito void bdrv_next_cleanup(BdrvNextIterator *it); 2223b491a90SEmanuele Giuseppe Esposito 2233b491a90SEmanuele Giuseppe Esposito BlockDriverState *bdrv_next_monitor_owned(BlockDriverState *bs); 2243b491a90SEmanuele Giuseppe Esposito void bdrv_iterate_format(void (*it)(void *opaque, const char *name), 2253b491a90SEmanuele Giuseppe Esposito void *opaque, bool read_only); 226b7cfc7d5SKevin Wolf 227b7cfc7d5SKevin Wolf char * GRAPH_RDLOCK 228b7cfc7d5SKevin Wolf bdrv_get_full_backing_filename(BlockDriverState *bs, Error **errp); 229b7cfc7d5SKevin Wolf 230b7cfc7d5SKevin Wolf char * GRAPH_RDLOCK bdrv_dirname(BlockDriverState *bs, Error **errp); 2313b491a90SEmanuele Giuseppe Esposito 2323b491a90SEmanuele Giuseppe Esposito void bdrv_img_create(const char *filename, const char *fmt, 2333b491a90SEmanuele Giuseppe Esposito const char *base_filename, const char *base_fmt, 2343b491a90SEmanuele Giuseppe Esposito char *options, uint64_t img_size, int flags, 2353b491a90SEmanuele Giuseppe Esposito bool quiet, Error **errp); 2363b491a90SEmanuele Giuseppe Esposito 2373b491a90SEmanuele Giuseppe Esposito void bdrv_ref(BlockDriverState *bs); 238b2ab5f54SKevin Wolf void no_coroutine_fn bdrv_unref(BlockDriverState *bs); 239b2ab5f54SKevin Wolf void coroutine_fn no_co_wrapper bdrv_co_unref(BlockDriverState *bs); 240ac2ae233SKevin Wolf void GRAPH_WRLOCK bdrv_schedule_unref(BlockDriverState *bs); 24132a8aba3SKevin Wolf 24232a8aba3SKevin Wolf void GRAPH_WRLOCK 24332a8aba3SKevin Wolf bdrv_unref_child(BlockDriverState *parent, BdrvChild *child); 24432a8aba3SKevin Wolf 24532a8aba3SKevin Wolf void coroutine_fn no_co_wrapper_bdrv_wrlock 24632a8aba3SKevin Wolf bdrv_co_unref_child(BlockDriverState *parent, BdrvChild *child); 247afdaeb9eSKevin Wolf 248afdaeb9eSKevin Wolf BdrvChild * GRAPH_WRLOCK 249afdaeb9eSKevin Wolf bdrv_attach_child(BlockDriverState *parent_bs, 2503b491a90SEmanuele Giuseppe Esposito BlockDriverState *child_bs, 2513b491a90SEmanuele Giuseppe Esposito const char *child_name, 2523b491a90SEmanuele Giuseppe Esposito const BdrvChildClass *child_class, 2533b491a90SEmanuele Giuseppe Esposito BdrvChildRole child_role, 2543b491a90SEmanuele Giuseppe Esposito Error **errp); 2553b491a90SEmanuele Giuseppe Esposito 256277f2007SKevin Wolf bool GRAPH_RDLOCK 257277f2007SKevin Wolf bdrv_op_is_blocked(BlockDriverState *bs, BlockOpType op, Error **errp); 258277f2007SKevin Wolf 2593b491a90SEmanuele Giuseppe Esposito void bdrv_op_block(BlockDriverState *bs, BlockOpType op, Error *reason); 2603b491a90SEmanuele Giuseppe Esposito void bdrv_op_unblock(BlockDriverState *bs, BlockOpType op, Error *reason); 2613b491a90SEmanuele Giuseppe Esposito void bdrv_op_block_all(BlockDriverState *bs, Error *reason); 2623b491a90SEmanuele Giuseppe Esposito void bdrv_op_unblock_all(BlockDriverState *bs, Error *reason); 2633b491a90SEmanuele Giuseppe Esposito bool bdrv_op_blocker_is_empty(BlockDriverState *bs); 2643b491a90SEmanuele Giuseppe Esposito 2653b491a90SEmanuele Giuseppe Esposito int bdrv_debug_breakpoint(BlockDriverState *bs, const char *event, 2663b491a90SEmanuele Giuseppe Esposito const char *tag); 2673b491a90SEmanuele Giuseppe Esposito int bdrv_debug_remove_breakpoint(BlockDriverState *bs, const char *tag); 2683b491a90SEmanuele Giuseppe Esposito int bdrv_debug_resume(BlockDriverState *bs, const char *tag); 2693b491a90SEmanuele Giuseppe Esposito bool bdrv_debug_is_suspended(BlockDriverState *bs, const char *tag); 2703b491a90SEmanuele Giuseppe Esposito 2717e8c182fSEmanuele Giuseppe Esposito bool bdrv_child_change_aio_context(BdrvChild *c, AioContext *ctx, 272e08cc001SEmanuele Giuseppe Esposito GHashTable *visited, Transaction *tran, 2737e8c182fSEmanuele Giuseppe Esposito Error **errp); 274a41cfda1SEmanuele Giuseppe Esposito int bdrv_try_change_aio_context(BlockDriverState *bs, AioContext *ctx, 2757e8c182fSEmanuele Giuseppe Esposito BdrvChild *ignore_child, Error **errp); 2763b491a90SEmanuele Giuseppe Esposito 277221caadcSKevin Wolf int GRAPH_RDLOCK bdrv_probe_blocksizes(BlockDriverState *bs, BlockSizes *bsz); 2783b491a90SEmanuele Giuseppe Esposito int bdrv_probe_geometry(BlockDriverState *bs, HDGeometry *geo); 2793b491a90SEmanuele Giuseppe Esposito 2809def6082SKevin Wolf void GRAPH_WRLOCK 2819def6082SKevin Wolf bdrv_add_child(BlockDriverState *parent, BlockDriverState *child, Error **errp); 2829def6082SKevin Wolf 2839def6082SKevin Wolf void GRAPH_WRLOCK 2849def6082SKevin Wolf bdrv_del_child(BlockDriverState *parent, BdrvChild *child, Error **errp); 2853b491a90SEmanuele Giuseppe Esposito 2863b491a90SEmanuele Giuseppe Esposito /** 2873b491a90SEmanuele Giuseppe Esposito * 2883b491a90SEmanuele Giuseppe Esposito * bdrv_register_buf/bdrv_unregister_buf: 2893b491a90SEmanuele Giuseppe Esposito * 2903b491a90SEmanuele Giuseppe Esposito * Register/unregister a buffer for I/O. For example, VFIO drivers are 2913b491a90SEmanuele Giuseppe Esposito * interested to know the memory areas that would later be used for I/O, so 2923b491a90SEmanuele Giuseppe Esposito * that they can prepare IOMMU mapping etc., to get better performance. 2934f384011SStefan Hajnoczi * 2944f384011SStefan Hajnoczi * Buffers must not overlap and they must be unregistered with the same <host, 2954f384011SStefan Hajnoczi * size> values that they were registered with. 296f4ec04baSStefan Hajnoczi * 297f4ec04baSStefan Hajnoczi * Returns: true on success, false on failure 2983b491a90SEmanuele Giuseppe Esposito */ 299f4ec04baSStefan Hajnoczi bool bdrv_register_buf(BlockDriverState *bs, void *host, size_t size, 300f4ec04baSStefan Hajnoczi Error **errp); 3014f384011SStefan Hajnoczi void bdrv_unregister_buf(BlockDriverState *bs, void *host, size_t size); 3023b491a90SEmanuele Giuseppe Esposito 3033b491a90SEmanuele Giuseppe Esposito void bdrv_cancel_in_flight(BlockDriverState *bs); 3043b491a90SEmanuele Giuseppe Esposito 3053b491a90SEmanuele Giuseppe Esposito #endif /* BLOCK_GLOBAL_STATE_H */ 306