From nobody Thu May 2 21:27:24 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 151022329455056.7497049939916; Thu, 9 Nov 2017 02:28:14 -0800 (PST) Received: from localhost ([::1]:36087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCk42-0001wA-1t for importer@patchew.org; Thu, 09 Nov 2017 05:28:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60242) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eCk36-0001b9-TF for qemu-devel@nongnu.org; Thu, 09 Nov 2017 05:27:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eCk36-000529-1M for qemu-devel@nongnu.org; Thu, 09 Nov 2017 05:27:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40938) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eCk2z-000502-HR; Thu, 09 Nov 2017 05:26:57 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1EA287E383; Thu, 9 Nov 2017 10:26:56 +0000 (UTC) Received: from localhost (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4EC5C60C89; Thu, 9 Nov 2017 10:26:53 +0000 (UTC) From: Stefan Hajnoczi To: Date: Thu, 9 Nov 2017 10:26:52 +0000 Message-Id: <20171109102652.6360-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 09 Nov 2017 10:26:56 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] coroutine: simplify co_aio_sleep_ns() prototype X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Paolo Bonzini , Stefan Hajnoczi , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reported-by: Eric Blake Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake --- 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(-) diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h index 9aff9a735e..ce2eb73670 100644 --- a/include/qemu/coroutine.h +++ b/include/qemu/coroutine.h @@ -261,12 +261,8 @@ void qemu_co_rwlock_unlock(CoRwlock *lock); =20 /** * 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); =20 /** * Yield until a file descriptor becomes readable diff --git a/block/null.c b/block/null.c index dd9c13f9ba..0cdabaa440 100644 --- a/block/null.c +++ b/block/null.c @@ -110,8 +110,7 @@ static coroutine_fn int null_co_common(BlockDriverState= *bs) BDRVNullState *s =3D bs->opaque; =20 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; } diff --git a/block/sheepdog.c b/block/sheepdog.c index 696a71442a..a1edb992ff 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -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_REALTI= ME, - 1000000000ULL); + qemu_co_sleep_ns(QEMU_CLOCK_REALTIME, 1000000000ULL); } }; =20 diff --git a/blockjob.c b/blockjob.c index 3a0c49137e..24d912161f 100644 --- a/blockjob.c +++ b/blockjob.c @@ -799,7 +799,7 @@ void block_job_sleep_ns(BlockJob *job, QEMUClockType ty= pe, int64_t ns) =20 job->busy =3D 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 =3D true; =20 diff --git a/util/qemu-coroutine-sleep.c b/util/qemu-coroutine-sleep.c index 9c5655041b..b345a55994 100644 --- a/util/qemu-coroutine-sleep.c +++ b/util/qemu-coroutine-sleep.c @@ -28,9 +28,9 @@ static void co_sleep_cb(void *opaque) aio_co_wake(sleep_cb->co); } =20 -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 =3D qemu_get_current_aio_context(); CoSleepCB sleep_cb =3D { .co =3D qemu_coroutine_self(), }; --=20 2.13.6