diff options
author | Kevin Wolf <kwolf@redhat.com> | 2023-01-26 18:24:20 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2023-02-17 11:22:19 +0100 |
commit | d6ee2e324ec26a02776d90125e3a55454f0ca57e (patch) | |
tree | 05a2db277d24d721903a5474c308160a59b8f2c1 /include | |
parent | 1e84cf79573e364075d6e63a4b00f7dc5f8aa924 (diff) | |
download | qemu-d6ee2e324ec26a02776d90125e3a55454f0ca57e.zip qemu-d6ee2e324ec26a02776d90125e3a55454f0ca57e.tar.gz qemu-d6ee2e324ec26a02776d90125e3a55454f0ca57e.tar.bz2 |
block-coroutine-wrapper: Introduce no_co_wrapper
Some functions must not be called from coroutine context. The common
pattern to use them anyway from a coroutine is running them in a BH and
letting the calling coroutine yield to be woken up when the BH is
completed.
Instead of manually writing such wrappers, add support for generating
them to block-coroutine-wrapper.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20230126172432.436111-2-kwolf@redhat.com>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/block/block-common.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/block/block-common.h b/include/block/block-common.h index 469300f..b5122ef 100644 --- a/include/block/block-common.h +++ b/include/block/block-common.h @@ -54,6 +54,20 @@ #define co_wrapper_bdrv_rdlock no_coroutine_fn #define co_wrapper_mixed_bdrv_rdlock no_coroutine_fn coroutine_mixed_fn +/* + * no_co_wrapper: Function specifier used by block-coroutine-wrapper.py + * + * Function specifier which does nothing but mark functions to be generated by + * scripts/block-coroutine-wrapper.py. + * + * A no_co_wrapper function declaration creates a coroutine_fn wrapper around + * functions that must not be called in coroutine context. It achieves this by + * scheduling a BH in the bottom half that runs the respective non-coroutine + * function. The coroutine yields after scheduling the BH and is reentered when + * the wrapped function returns. + */ +#define no_co_wrapper + #include "block/blockjob.h" /* block.c */ |