coroutine: simplify co_aio_sleep_ns() prototype
PATCH 1/1 coroutine: simplify co_aio_sleep_ns() prototype
The AioContext pointer argument to co_aio_sleep_ns() is only used for the sleep timer. It does not affect where the caller coroutine is resumed.
Due to changes to coroutine and AIO APIs it is now possible to drop the AioContext pointer argument. This is safe to do since no caller has specific requirements for which AioContext the timer must run in.
This patch drops the AioContext pointer argument and renames the function to simplify the API.
--- include/qemu/coroutine.h | 6 +----- block/null.c | 3 +-- block/sheepdog.c | 3 +-- blockjob.c | 2 +- util/qemu-coroutine-sleep.c | 4 ++-- 5 files changed, 6 insertions(+), 12 deletions(-)
include/qemu/coroutine.h +1 -5
@@ -261,12 +261,8 @@ void qemu_co_rwlock_unlock(CoRwlock *lock);/** * Yield the coroutine for a given duration -* -* Behaves similarly to co_sleep_ns(), but the sleeping coroutine will be -* resumed when using aio_poll(). */ -void coroutine_fn co_aio_sleep_ns(AioContext *ctx, QEMUClockType type, -int64_t ns); +void coroutine_fn qemu_co_sleep_ns(QEMUClockType type, int64_t ns);/** * Yield until a file descriptor becomes readable
block/null.c +1 -2
@@ -110,8 +110,7 @@ static coroutine_fn int null_co_common(BlockDriverState *bs)BDRVNullState *s = bs->opaque;if (s->latency_ns) { -co_aio_sleep_ns (bdrv_get_aio_context (bs),QEMU_CLOCK_REALTIME , - s->latency_ns); +qemu_co_sleep_ns (QEMU_CLOCK_REALTIME , s->latency_ns); }return 0 ; }
block/sheepdog.c +1 -2
@@ -776,8 +776,7 @@ static coroutine_fn void reconnect_to_sdog(void *opaque)if (s->fd <0 ) {DPRINTF ("Wait for connection to be established\n" );error_report_err (local_err); -co_aio_sleep_ns (bdrv_get_aio_context (s->bs),QEMU_CLOCK_REALTIME , -1000000000ULL ); +qemu_co_sleep_ns (QEMU_CLOCK_REALTIME ,1000000000ULL ); } };
blockjob.c +1 -1
@@ -799,7 +799,7 @@ void block_job_sleep_ns(BlockJob *job, QEMUClockType type, int64_t ns) job->busy = false;if (!block_job_should_pause (job)) { -co_aio_sleep_ns (blk_get_aio_context (job->blk), type, ns); +qemu_co_sleep_ns (type, ns); } job->busy = true;
util/qemu-coroutine-sleep.c +2 -2
@@ -28,9 +28,9 @@ static void co_sleep_cb(void *opaque)aio_co_wake (sleep_cb->co); } -void coroutine_fn co_aio_sleep_ns(AioContext *ctx, QEMUClockType type, -int64_t ns) +void coroutine_fn qemu_co_sleep_ns(QEMUClockType type, int64_t ns) { +AioContext *ctx =qemu_get_current_aio_context ();CoSleepCB sleep_cb = { .co =qemu_coroutine_self (), };
Signature · 1 line
2.13.6
Quoted 10 lines · Stefan Hajnoczi
The AioContext pointer argument to
co_aio_sleep_ns()is only used for the sleep timer. It does not affect where the caller coroutine is resumed.Due to changes to coroutine and AIO APIs it is now possible to drop the AioContext pointer argument. This is safe to do since no caller has specific requirements for which AioContext the timer must run in.
This patch drops the AioContext pointer argument and renames the function to simplify the API.
And it fixes a stale comment ;)
Quoted 4 lines
Reported-by Paolo Bonzini <[email protected]>Reported-by Eric Blake <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>
Quoted 8 lines
--- include/qemu/coroutine.h | 6 +----- block/null.c | 3 +-- block/sheepdog.c | 3 +-- blockjob.c | 2 +- util/qemu-coroutine-sleep.c | 4 ++-- 5 files changed, 6 insertions(+), 12 deletions(-)
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
Stefan Hajnoczi
AppliedQuoted 14 lines · Stefan Hajnoczi
The AioContext pointer argument to
co_aio_sleep_ns()is only used for the sleep timer. It does not affect where the caller coroutine is resumed.Due to changes to coroutine and AIO APIs it is now possible to drop the AioContext pointer argument. This is safe to do since no caller has specific requirements for which AioContext the timer must run in.
This patch drops the AioContext pointer argument and renames the function to simplify the API.
Reported-by Paolo Bonzini <[email protected]>Reported-by Eric Blake <[email protected]>Signed-off-by Stefan Hajnoczi <[email protected]>
Quoted 7 lines
--- include/qemu/coroutine.h | 6 +----- block/null.c | 3 +-- block/sheepdog.c | 3 +-- blockjob.c | 2 +- util/qemu-coroutine-sleep.c | 4 ++-- 5 files changed, 6 insertions(+), 12 deletions(-)
Thanks, applied to my block-next tree for QEMU 2.12:
https://github.com/stefanha/qemu/commits/block-next
Stefan