2011-04-24 03:40:22 +02:00
|
|
|
/*
|
2015-11-18 18:57:30 +01:00
|
|
|
* 9p backend
|
2011-04-24 03:40:22 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-01-26 19:17:10 +01:00
|
|
|
#include "qemu/osdep.h"
|
2015-11-27 12:43:06 +01:00
|
|
|
#include "qemu-common.h"
|
|
|
|
#include "block/thread-pool.h"
|
2015-09-01 15:48:02 +02:00
|
|
|
#include "qemu/coroutine.h"
|
2015-11-18 18:57:30 +01:00
|
|
|
#include "coth.h"
|
2011-04-24 03:40:22 +02:00
|
|
|
|
2015-11-27 12:43:06 +01:00
|
|
|
/* Called from QEMU I/O thread. */
|
|
|
|
static void coroutine_enter_cb(void *opaque, int ret)
|
2011-04-24 03:40:22 +02:00
|
|
|
{
|
|
|
|
Coroutine *co = opaque;
|
coroutine: move entry argument to qemu_coroutine_create
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>
2016-07-04 19:10:01 +02:00
|
|
|
qemu_coroutine_enter(co);
|
2011-04-24 03:40:22 +02:00
|
|
|
}
|
|
|
|
|
2015-11-27 12:43:06 +01:00
|
|
|
/* Called from worker thread. */
|
|
|
|
static int coroutine_enter_func(void *arg)
|
2011-04-24 03:40:22 +02:00
|
|
|
{
|
2015-11-27 12:43:06 +01:00
|
|
|
Coroutine *co = arg;
|
coroutine: move entry argument to qemu_coroutine_create
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>
2016-07-04 19:10:01 +02:00
|
|
|
qemu_coroutine_enter(co);
|
2015-11-27 12:43:06 +01:00
|
|
|
return 0;
|
2011-04-24 03:40:22 +02:00
|
|
|
}
|
|
|
|
|
2015-11-27 12:43:06 +01:00
|
|
|
void co_run_in_worker_bh(void *opaque)
|
2011-04-24 03:40:22 +02:00
|
|
|
{
|
2015-11-27 12:43:06 +01:00
|
|
|
Coroutine *co = opaque;
|
2015-12-23 10:56:58 +01:00
|
|
|
thread_pool_submit_aio(aio_get_thread_pool(qemu_get_aio_context()),
|
2015-11-27 12:43:06 +01:00
|
|
|
coroutine_enter_func, co, coroutine_enter_cb, co);
|
2011-04-24 03:40:22 +02:00
|
|
|
}
|