/qemu/docs/devel/ |
H A D | block-coroutine-wrapper.rst | 2 block-coroutine-wrapper 6 called in coroutine context. Such functions are normally marked by the 8 non-coroutine context; for this we need to start a coroutine, run the 9 needed function from it and wait for the coroutine to finish in a 10 BDRV_POLL_WHILE() loop. To run a coroutine we need a function with one 12 non-coroutine interface, we should define a structure to pack the 15 with same list of arguments as original one, which will pack the 16 parameters into a struct, create a coroutine, run it and wait in 24 ``bdrv_co_foo(<some args>)`` and need a non-coroutine interface for it, 29 ``block/coroutines.h``) with the ``co_wrapper`` mark, [all …]
|
/qemu/util/ |
H A D | coroutine-sigaltstack.c | 2 * sigaltstack coroutine initialization code 8 ** Copyright (c) 1999-2006 Ralf S. Engelschall <rse@engelschall.com> 21 * License along with this library; if not, see <http://www.gnu.org/licenses/>. 33 #error "SafeStack is not compatible with code run in alternate signal stacks" 37 Coroutine base; 44 * Per-thread coroutine bookkeeping 47 /** Currently executing coroutine */ 48 Coroutine *current; 50 /** The default coroutine */ 67 s->current = &s->leader.base; in coroutine_get_thread_state() [all …]
|
H A D | qemu-coroutine.c | 11 * See the COPYING.LIB file in the top-level directory. 20 #include "qemu/coroutine-tls.h" 29 * Coroutine creation and deletion is expensive so a pool of unused coroutines 40 * .-----------------------------------. 42 * `-----------------------------------' 44 * .-------------------. 45 * | Batch 1 | Batch 2 | per-thread local_pool (maximum 2 batches) 46 * `-------------------' 53 QSLIST_HEAD(, Coroutine) list; 74 QSLIST_INIT(&batch->list); in coroutine_pool_batch_new() [all …]
|
H A D | coroutine-wasm.c | 2 * emscripten fiber coroutine initialization code 3 * based on coroutine-ucontext.c 19 * License along with this library; if not, see <http://www.gnu.org/licenses/>. 24 #include "qemu/coroutine-tls.h" 29 Coroutine base; 42 * Per-thread coroutine bookkeeping 44 QEMU_DEFINE_STATIC_CO_TLS(Coroutine *, current); 50 Coroutine *co = co_; in coroutine_trampoline() 53 co->entry(co->entry_arg); in coroutine_trampoline() 54 qemu_coroutine_switch(co, co->caller, COROUTINE_TERMINATE); in coroutine_trampoline() [all …]
|
H A D | qemu-coroutine-lock.c | 2 * coroutine queues and locks 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 * The lock-free mutex implementation is based on OSv 38 QSIMPLEQ_INIT(&queue->entries); in qemu_co_queue_init() 44 Coroutine *self = qemu_coroutine_self(); in qemu_co_queue_wait_impl() 46 QSIMPLEQ_INSERT_HEAD(&queue->entries, self, co_queue_next); in qemu_co_queue_wait_impl() 48 QSIMPLEQ_INSERT_TAIL(&queue->entries, self, co_queue_next); in qemu_co_queue_wait_impl() 57 * coroutine but only after this yield and after the main loop in qemu_co_queue_wait_impl() 64 * primitive automatically places the woken coroutine on the in qemu_co_queue_wait_impl() 76 Coroutine *next; in qemu_co_enter_next_impl() [all …]
|
H A D | coroutine-windows.c | 2 * Win32 coroutine initialization code 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 #include "qemu/coroutine-tls.h" 31 Coroutine base; 38 QEMU_DEFINE_STATIC_CO_TLS(Coroutine *, current); 49 qemu_coroutine_switch(Coroutine *from_, Coroutine *to_, in qemu_coroutine_switch() 57 to->action = action; in qemu_coroutine_switch() 58 SwitchToFiber(to->fiber); in qemu_coroutine_switch() 59 return from->action; in qemu_coroutine_switch() 64 Coroutine *co = co_; in coroutine_trampoline() [all …]
|
H A D | coroutine-ucontext.c | 2 * ucontext coroutine initialization code 18 * License along with this library; if not, see <http://www.gnu.org/licenses/>. 28 #include "qemu/coroutine-tls.h" 46 Coroutine base; 50 /* Need an unsafe stack for each coroutine */ 68 * Per-thread coroutine bookkeeping 70 QEMU_DEFINE_STATIC_CO_TLS(Coroutine *, current); 91 co->tsan_co_fiber = __tsan_create_fiber(0); /* flags: sync on switch */ in on_new_fiber() 92 co->tsan_caller_fiber = __tsan_get_current_fiber(); in on_new_fiber() 107 if (!leaderp->stack) { in finish_switch_fiber() [all …]
|
H A D | async.c | 4 * Copyright (c) 2003-2008 Fabrice Bellard 5 * Copyright (c) 2009-2017 QEMU contributors 22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 #include "block/thread-pool.h" 30 #include "block/graph-lock.h" 31 #include "qemu/main-loop.h" 35 #include "block/raw-aio.h" 37 #include "qemu/coroutine-tls.h" 75 AioContext *ctx = bh->ctx; in aio_bh_enqueue() 79 * Synchronizes with atomic_fetch_and() in aio_bh_dequeue(), ensuring that in aio_bh_enqueue() [all …]
|
/qemu/include/qemu/ |
H A D | coroutine.h | 2 * QEMU coroutine implementation 11 * See the COPYING.LIB file in the top-level directory. 18 #include "qemu/coroutine-core.h" 30 * These functions are re-entrant and may be used outside the BQL. 32 * Functions that execute in coroutine context cannot be called 69 Coroutine *holder; 73 * Assert that the current coroutine holds @mutex. 78 * mutex->holder doesn't need any synchronisation if the assertion holds in qemu_co_mutex_assert_locked() 82 * the pointer for any other coroutine. in qemu_co_mutex_assert_locked() 84 assert(qatomic_read(&mutex->locked) && in qemu_co_mutex_assert_locked() [all …]
|
H A D | coroutine-core.h | 2 * QEMU coroutine implementation 11 * See the COPYING.LIB file in the top-level directory. 25 * These functions are re-entrant and may be used outside the BQL. 27 * Functions that execute in coroutine context cannot be called 41 * Mark a function that executes in coroutine context 44 * Functions that execute in coroutine context cannot be called 57 typedef struct Coroutine Coroutine; typedef 61 * Coroutine entry point 63 * When the coroutine is entered for the first time, opaque is passed in as an 66 * When this function returns, the coroutine is destroyed automatically and [all …]
|
H A D | coroutine_int.h | 2 * Coroutine internals 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 #include "qemu/coroutine.h" 44 struct Coroutine { struct 47 Coroutine *caller; argument 49 /* Only used when the coroutine has terminated. */ 50 QSLIST_ENTRY(Coroutine) pool_next; 54 /* Only used when the coroutine has yielded. */ 57 /* Used to catch and abort on illegal co-routine entry. 59 * scheduled the coroutine. */ [all …]
|
H A D | coroutine-tls.h | 6 * SPDX-License-Identifier: LGPL-2.1-or-later 9 * See the COPYING.LIB file in the top-level directory. 12 * compiler optimizations may cause values to be cached across coroutine 13 * re-entry. Coroutines can run in more than one thread through the course of 19 * ..code-block:: c 20 * :caption: A coroutine that may see the wrong TLS value 28 * aio_notify(current_aio_context); // <-- may be stale after yielding! 34 * ..code-block:: c 35 * :caption: A coroutine that safely uses TLS 43 * aio_notify(get_current_aio_context()); // <-- safe [all …]
|
H A D | job.h | 22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 #include "qapi/qapi-types-job.h" 32 #include "qemu/coroutine.h" 40 * Long-running operation. 51 * All callbacks are called with job_mutex *not* held. 56 * The coroutine that executes the job. If not NULL, it is reentered when 60 Coroutine *co; 76 /* ProgressMeter API is thread-safe */ 80 * AioContext to run the job coroutine in. 104 * Counter for pause request. If non-zero, the block job is either paused, [all …]
|
/qemu/scripts/qapi/ |
H A D | commands.py | 5 Copyright (C) 2014-2018 Red Hat, Inc. 13 See the COPYING file in the top-level directory. 45 coroutine: bool) -> str: 50 coroutine_fn='coroutine_fn ' if coroutine else '', 59 gen_tracing: bool) -> str: 87 trace_qmp_enter_%(name)s(req_json->str); 128 trace_qmp_exit_%(name)s(ret_json->str, true); 142 def gen_marshal_output(ret_type: QAPISchemaType) -> str: 164 coroutine: bool) -> str: 166 'coroutine_fn': 'coroutine_fn ' if coroutine else '', [all …]
|
/qemu/include/block/ |
H A D | aio.h | 10 * the COPYING file in the top-level directory. 20 #include "qemu/coroutine-core.h" 26 #include "block/graph-lock.h" 27 #include "hw/qdev-core.h" 76 * Called with ctx->list_lock acquired. 88 * Called with ctx->list_lock incremented but not locked. 98 * Tell aio_poll() when to stop userspace polling early because ->wait() 106 * Returns: true if ->wait() should be called, false otherwise. 133 /* Used by AioContext users to protect from multi-threaded access. */ 144 /* The list of registered AIO handlers. Protected by ctx->list_lock. */ [all …]
|
H A D | block-common.h | 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 #include "qapi/qapi-types-block-core.h" 31 * co_wrapper{*}: Function specifiers used by block-coroutine-wrapper.py 34 * generated by scripts/block-coroutine-wrapper.py 36 * Usage: read docs/devel/block-coroutine-wrapper.rst 39 * - co_wrapper functions can be called by only non-coroutine context, because 40 * they always generate a new coroutine. 41 * - co_wrapper_mixed functions can be called by both coroutine and 42 * non-coroutine context. 43 * - co_wrapper_bdrv_rdlock are co_wrapper functions but automatically take and [all …]
|
H A D | graph-lock.h | 18 * License along with this library; if not, see <http://www.gnu.org/licenses/>. 34 * BlockDriverState ->parents and->children. 45 * If a coroutine changes AioContext, the counter in the original and new 78 * using a function pointer. As a workaround, annotate function pointers with 109 * The wrlock can only be taken from the main loop, with BQL held, as only the 130 * the graph, therefore wait in a coroutine queue. 131 * The writer will then wake this coroutine once it is done. 137 * Calling this function from the Main Loop with BQL held 141 * function/coroutine itself, and need to delegate the caller (usually main 142 * loop) to take it and wait that the coroutine ends, so that [all …]
|
/qemu/tests/unit/ |
H A D | test-coroutine.c | 2 * Coroutine tests 10 * See the COPYING.LIB file in the top-level directory. 28 Coroutine *coroutine; in test_in_coroutine() local 32 coroutine = qemu_coroutine_create(verify_in_coroutine, NULL); in test_in_coroutine() 33 qemu_coroutine_enter(coroutine); in test_in_coroutine() 42 Coroutine **p_co = opaque; in verify_self() 48 Coroutine *coroutine; in test_self() local 50 coroutine = qemu_coroutine_create(verify_self, &coroutine); in test_self() 51 qemu_coroutine_enter(coroutine); in test_self() 60 Coroutine *caller = (Coroutine *)opaque; in verify_entered_step_2() [all …]
|
H A D | test-aio-multithread.c | 10 * See the COPYING.LIB file in the top-level directory. 15 #include "qemu/coroutine.h" 17 #include "qemu/error-report.h" 26 static __thread int id = -1; 41 data->cb(data->arg); in ctx_run_bh_cb() 109 static Coroutine *to_schedule[NUM_CONTEXTS]; 118 Coroutine *co; in schedule_next() 173 Coroutine *co1 = qemu_coroutine_create(test_multi_co_schedule_entry, NULL); in test_multi_co_schedule() 201 /* CoMutex thread-safety. */ 218 * exits before the coroutine is woken up, causing a spurious in test_multi_co_mutex_entry() [all …]
|
/qemu/scripts/qemugdb/ |
H A D | coroutine.py | 10 # or later. See the COPYING file in the top-level directory. 27 …return gdb.parse_and_eval('(((uint64_t)%s >> 0x11) | ((uint64_t)%s << (64 - 0x11))) ^ (uint64_t)%s… 63 # Example: Line 321 of "../util/coroutine-ucontext.c" starts at address 82 Backtrace dump with raw registers, mimic GDB command 'bt'. 92 # instruction instead of the CALL. Here -1 would work for any 94 print(f"#{i} {hex(rip)} in {symbol_lookup(rip if i == 0 else rip-1)}") 101 Backtrace dump with gdb's 'bt' command, only usable in a live session. 128 # but only works with live sessions. 143 '''Display coroutine backtrace''' 145 gdb.Command.__init__(self, 'qemu coroutine', gdb.COMMAND_DATA, [all …]
|
/qemu/include/io/ |
H A D | channel.h | 17 * License along with this library; if not, see <http://www.gnu.org/licenses/>. 25 #include "qemu/coroutine-core.h" 28 #define TYPE_QIO_CHANNEL "qio-channel" 33 #define QIO_CHANNEL_ERR_BLOCK -2 71 * - Use QOM to properly support arbitrary subclassing 72 * - Support use of iovecs for efficient I/O with multiple blocks 73 * - None of the character set translation, binary data exclusively 74 * - Direct support for QEMU Error object reporting 75 * - File descriptor passing 78 * will be subclasses for dealing with sockets, files, and higher [all …]
|
/qemu/qapi/ |
H A D | qmp-dispatch.c | 10 * See the COPYING.LIB file in the top-level directory. 17 #include "qapi/compat-policy.h" 19 #include "qapi/qmp-registry.h" 22 #include "qapi/qobject-input-visitor.h" 23 #include "qapi/qobject-output-visitor.h" 25 #include "qemu/coroutine.h" 26 #include "qemu/main-loop.h" 58 || (!strcmp(arg_name, "exec-oob") && allow_oob)) { in qmp_dispatch_check_obj() 65 error_setg(errp, "QMP input member '%s' clashes with '%s'", in qmp_dispatch_check_obj() 105 * Does @qdict look like a command to be run out-of-band? [all …]
|
/qemu/scripts/ |
H A D | block-coroutine-wrapper.py | 2 """Generate coroutine wrappers for block subsystem. 5 searches for functions with the 'co_wrapper' specifier 8 Usage: block-coroutine-wrapper.py generated-file.c FILE.[ch]... 23 along with this program. If not, see <http://www.gnu.org/licenses/>. 37 * File is generated by scripts/block-coroutine-wrapper.py 44 #include "block/block-gen.h" 46 #include "block/dirty-bitmap.h" 53 r'(?P<name>[a-z][a-z0-9_]*)' 56 def __init__(self, param_decl: str) -> None: 67 args: str, variant: str) -> None: [all …]
|
/qemu/python/qemu/qmp/ |
H A D | util.py | 18 Coroutine, 28 # -------------------------- 30 # -------------------------- 33 async def flush(writer: asyncio.StreamWriter) -> None: 38 the "high-water mark". This function ensures we flush the entire 39 buffer -- by setting the high water mark to 0 and then calling 43 transport = cast( # type: ignore[redundant-cast] 56 def upper_half(func: T) -> T: 58 Do-nothing decorator that annotates a method as an "upper-half" method. 60 These methods must not call bottom-half functions directly, but can [all …]
|
/qemu/hw/9pfs/ |
H A D | coth.h | 11 * the COPYING file in the top-level directory. 19 #include "qemu/coroutine-core.h" 26 * 1. Yield the coroutine in the QEMU thread. 27 * 2. Submit the coroutine to a worker thread. 28 * 3. Enter the coroutine in the worker thread. 30 * can enter coroutine while step1 is still running 37 * is highly recommended to fetch all data from fs driver with a single 49 * yield in qemu thread and re-enter back \ 57 /* re-enter back to qemu thread */ \
|