mirror of
https://github.com/xemu-project/xemu.git
synced 2024-12-01 07:21:09 +00:00
0b8b8753e4
In practice the entry argument is always known at creation time, and it is confusing that sometimes qemu_coroutine_enter is used with a non-NULL argument to re-enter a coroutine (this happens in block/sheepdog.c and tests/test-coroutine.c). So pass the opaque value at creation time, for consistency with e.g. aio_bh_new. Mostly done with the following semantic patch: @ entry1 @ expression entry, arg, co; @@ - co = qemu_coroutine_create(entry); + co = qemu_coroutine_create(entry, arg); ... - qemu_coroutine_enter(co, arg); + qemu_coroutine_enter(co); @ entry2 @ expression entry, arg; identifier co; @@ - Coroutine *co = qemu_coroutine_create(entry); + Coroutine *co = qemu_coroutine_create(entry, arg); ... - qemu_coroutine_enter(co, arg); + qemu_coroutine_enter(co); @ entry3 @ expression entry, arg; @@ - qemu_coroutine_enter(qemu_coroutine_create(entry), arg); + qemu_coroutine_enter(qemu_coroutine_create(entry, arg)); @ reentry @ expression co; @@ - qemu_coroutine_enter(co, NULL); + qemu_coroutine_enter(co); except for the aforementioned few places where the semantic patch stumbled (as expected) and for test_co_queue, which would otherwise produce an uninitialized variable warning. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
42 lines
957 B
C
42 lines
957 B
C
/*
|
|
* 9p backend
|
|
*
|
|
* Copyright IBM, Corp. 2010
|
|
*
|
|
* Authors:
|
|
* Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
|
|
* Venkateswararao Jujjuri(JV) <jvrao@linux.vnet.ibm.com>
|
|
*
|
|
* This work is licensed under the terms of the GNU GPL, version 2. See
|
|
* the COPYING file in the top-level directory.
|
|
*
|
|
*/
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "qemu-common.h"
|
|
#include "block/thread-pool.h"
|
|
#include "qemu/coroutine.h"
|
|
#include "coth.h"
|
|
|
|
/* Called from QEMU I/O thread. */
|
|
static void coroutine_enter_cb(void *opaque, int ret)
|
|
{
|
|
Coroutine *co = opaque;
|
|
qemu_coroutine_enter(co);
|
|
}
|
|
|
|
/* Called from worker thread. */
|
|
static int coroutine_enter_func(void *arg)
|
|
{
|
|
Coroutine *co = arg;
|
|
qemu_coroutine_enter(co);
|
|
return 0;
|
|
}
|
|
|
|
void co_run_in_worker_bh(void *opaque)
|
|
{
|
|
Coroutine *co = opaque;
|
|
thread_pool_submit_aio(aio_get_thread_pool(qemu_get_aio_context()),
|
|
coroutine_enter_func, co, coroutine_enter_cb, co);
|
|
}
|