From 0b8b8753e4d94901627b3e86431230f2319215c4 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 4 Jul 2016 19:10:01 +0200 Subject: 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 Reviewed-by: Fam Zheng Signed-off-by: Kevin Wolf --- qemu-io-cmds.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qemu-io-cmds.c') diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 09e879f872..40fe2ebf7d 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -483,8 +483,8 @@ static int do_co_pwrite_zeroes(BlockBackend *blk, int64_t offset, return -ERANGE; } - co = qemu_coroutine_create(co_pwrite_zeroes_entry); - qemu_coroutine_enter(co, &data); + co = qemu_coroutine_create(co_pwrite_zeroes_entry, &data); + qemu_coroutine_enter(co); while (!data.done) { aio_poll(blk_get_aio_context(blk), true); } -- cgit v1.2.3-55-g7522