xref: /openbmc/qemu/hw/9pfs/coth.c (revision 500eb6db)
1 /*
2  * 9p backend
3  *
4  * Copyright IBM, Corp. 2010
5  *
6  * Authors:
7  *  Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
8  *  Venkateswararao Jujjuri(JV) <jvrao@linux.vnet.ibm.com>
9  *
10  * This work is licensed under the terms of the GNU GPL, version 2.  See
11  * the COPYING file in the top-level directory.
12  *
13  */
14 
15 #include "qemu/osdep.h"
16 #include "block/thread-pool.h"
17 #include "qemu/coroutine.h"
18 #include "coth.h"
19 
20 /* Called from QEMU I/O thread.  */
21 static void coroutine_enter_cb(void *opaque, int ret)
22 {
23     Coroutine *co = opaque;
24     qemu_coroutine_enter(co);
25 }
26 
27 /* Called from worker thread.  */
28 static int coroutine_enter_func(void *arg)
29 {
30     Coroutine *co = arg;
31     qemu_coroutine_enter(co);
32     return 0;
33 }
34 
35 void co_run_in_worker_bh(void *opaque)
36 {
37     Coroutine *co = opaque;
38     thread_pool_submit_aio(aio_get_thread_pool(qemu_get_aio_context()),
39                            coroutine_enter_func, co, coroutine_enter_cb, co);
40 }
41