From nobody Sat Oct 25 21:42:27 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1521732928250611.9292774654795; Thu, 22 Mar 2018 08:35:28 -0700 (PDT) Received: from localhost ([::1]:33200 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ez2FT-0004ys-82 for importer@patchew.org; Thu, 22 Mar 2018 11:35:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59169) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ez298-0000MQ-Ki for qemu-devel@nongnu.org; Thu, 22 Mar 2018 11:28:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ez297-0008CI-Qm for qemu-devel@nongnu.org; Thu, 22 Mar 2018 11:28:54 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49894 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ez292-00087P-L3; Thu, 22 Mar 2018 11:28:48 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 139FA8160F99; Thu, 22 Mar 2018 15:28:46 +0000 (UTC) Received: from localhost (unknown [10.36.118.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5392D2166BAE; Thu, 22 Mar 2018 15:28:45 +0000 (UTC) From: Stefan Hajnoczi To: Date: Thu, 22 Mar 2018 15:28:32 +0000 Message-Id: <20180322152834.12656-2-stefanha@redhat.com> In-Reply-To: <20180322152834.12656-1-stefanha@redhat.com> References: <20180322152834.12656-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 22 Mar 2018 15:28:46 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 22 Mar 2018 15:28:46 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'stefanha@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 1/3] queue: add QSIMPLEQ_PREPEND() 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 , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , Paolo Bonzini 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" QSIMPLEQ_CONCAT(a, b) joins a =3D a + b. The new QSIMPLEQ_PREPEND(a, b) API joins a =3D b + a. Signed-off-by: Stefan Hajnoczi Reviewed-by: Paolo Bonzini --- include/qemu/queue.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/qemu/queue.h b/include/qemu/queue.h index aa270d2b38..59fd1203a1 100644 --- a/include/qemu/queue.h +++ b/include/qemu/queue.h @@ -324,6 +324,14 @@ struct { = \ } \ } while (/*CONSTCOND*/0) =20 +#define QSIMPLEQ_PREPEND(head1, head2) do { \ + if (!QSIMPLEQ_EMPTY((head2))) { \ + *(head2)->sqh_last =3D (head1)->sqh_first; \ + (head1)->sqh_first =3D (head2)->sqh_first; = \ + QSIMPLEQ_INIT((head2)); \ + } \ +} while (/*CONSTCOND*/0) + #define QSIMPLEQ_LAST(head, type, field) \ (QSIMPLEQ_EMPTY((head)) ? \ NULL : \ --=20 2.14.3 From nobody Sat Oct 25 21:42:27 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1521732684472797.9671138908418; Thu, 22 Mar 2018 08:31:24 -0700 (PDT) Received: from localhost ([::1]:33181 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ez2BW-00024Q-PS for importer@patchew.org; Thu, 22 Mar 2018 11:31:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59200) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ez299-0000Nb-TX for qemu-devel@nongnu.org; Thu, 22 Mar 2018 11:28:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ez298-0008DT-Cv for qemu-devel@nongnu.org; Thu, 22 Mar 2018 11:28:55 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:43576 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ez292-00087b-L6; Thu, 22 Mar 2018 11:28:48 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7F6E640201A6; Thu, 22 Mar 2018 15:28:47 +0000 (UTC) Received: from localhost (unknown [10.36.118.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 155A72023230; Thu, 22 Mar 2018 15:28:46 +0000 (UTC) From: Stefan Hajnoczi To: Date: Thu, 22 Mar 2018 15:28:33 +0000 Message-Id: <20180322152834.12656-3-stefanha@redhat.com> In-Reply-To: <20180322152834.12656-1-stefanha@redhat.com> References: <20180322152834.12656-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 22 Mar 2018 15:28:47 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Thu, 22 Mar 2018 15:28:47 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'stefanha@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 2/3] coroutine: avoid co_queue_wakeup recursion 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 , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , Paolo Bonzini 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" qemu_aio_coroutine_enter() is (indirectly) called recursively when processing co_queue_wakeup. This can lead to stack exhaustion. This patch rewrites co_queue_wakeup in an iterative fashion (instead of recursive) with bounded memory usage to prevent stack exhaustion. qemu_co_queue_run_restart() is inlined into qemu_aio_coroutine_enter() and the qemu_coroutine_enter() call is turned into a loop to avoid recursion. There is one change that is worth mentioning: Previously, when coroutine A queued coroutine B, qemu_co_queue_run_restart() entered coroutine B from coroutine A. If A was terminating then it would still stay alive until B yielded. After this patch B is entered by A's parent so that a A can be deleted immediately if it is terminating. It is safe to make this change since B could never interact with A if it was terminating anyway. Signed-off-by: Stefan Hajnoczi Reviewed-by: Paolo Bonzini --- include/qemu/coroutine_int.h | 1 - block/io.c | 3 +- util/qemu-coroutine-lock.c | 34 ------------- util/qemu-coroutine.c | 110 +++++++++++++++++++++++----------------= ---- 4 files changed, 60 insertions(+), 88 deletions(-) diff --git a/include/qemu/coroutine_int.h b/include/qemu/coroutine_int.h index 59e8406398..bd6b0468e1 100644 --- a/include/qemu/coroutine_int.h +++ b/include/qemu/coroutine_int.h @@ -68,6 +68,5 @@ Coroutine *qemu_coroutine_new(void); void qemu_coroutine_delete(Coroutine *co); CoroutineAction qemu_coroutine_switch(Coroutine *from, Coroutine *to, CoroutineAction action); -void coroutine_fn qemu_co_queue_run_restart(Coroutine *co); =20 #endif diff --git a/block/io.c b/block/io.c index 2b09c656d0..bd9a19a9c4 100644 --- a/block/io.c +++ b/block/io.c @@ -249,8 +249,7 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDr= iverState *bs, BdrvCoDrainData data; =20 /* Calling bdrv_drain() from a BH ensures the current coroutine yields= and - * other coroutines run if they were queued from - * qemu_co_queue_run_restart(). */ + * other coroutines run if they were queued by aio_co_enter(). */ =20 assert(qemu_in_coroutine()); data =3D (BdrvCoDrainData) { diff --git a/util/qemu-coroutine-lock.c b/util/qemu-coroutine-lock.c index 5a80c10690..27438a1858 100644 --- a/util/qemu-coroutine-lock.c +++ b/util/qemu-coroutine-lock.c @@ -68,40 +68,6 @@ void coroutine_fn qemu_co_queue_wait_impl(CoQueue *queue= , QemuLockable *lock) } } =20 -/** - * qemu_co_queue_run_restart: - * - * Enter each coroutine that was previously marked for restart by - * qemu_co_queue_next() or qemu_co_queue_restart_all(). This function is - * invoked by the core coroutine code when the current coroutine yields or - * terminates. - */ -void qemu_co_queue_run_restart(Coroutine *co) -{ - Coroutine *next; - QSIMPLEQ_HEAD(, Coroutine) tmp_queue_wakeup =3D - QSIMPLEQ_HEAD_INITIALIZER(tmp_queue_wakeup); - - trace_qemu_co_queue_run_restart(co); - - /* Because "co" has yielded, any coroutine that we wakeup can resume i= t. - * If this happens and "co" terminates, co->co_queue_wakeup becomes - * invalid memory. Therefore, use a temporary queue and do not touch - * the "co" coroutine as soon as you enter another one. - * - * In its turn resumed "co" can populate "co_queue_wakeup" queue with - * new coroutines to be woken up. The caller, who has resumed "co", - * will be responsible for traversing the same queue, which may cause - * a different wakeup order but not any missing wakeups. - */ - QSIMPLEQ_CONCAT(&tmp_queue_wakeup, &co->co_queue_wakeup); - - while ((next =3D QSIMPLEQ_FIRST(&tmp_queue_wakeup))) { - QSIMPLEQ_REMOVE_HEAD(&tmp_queue_wakeup, co_queue_next); - qemu_coroutine_enter(next); - } -} - static bool qemu_co_queue_do_restart(CoQueue *queue, bool single) { Coroutine *next; diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c index 9eff7fd450..1ba4191b84 100644 --- a/util/qemu-coroutine.c +++ b/util/qemu-coroutine.c @@ -104,57 +104,65 @@ static void coroutine_delete(Coroutine *co) =20 void qemu_aio_coroutine_enter(AioContext *ctx, Coroutine *co) { - Coroutine *self =3D qemu_coroutine_self(); - CoroutineAction ret; - - /* Cannot rely on the read barrier for co in aio_co_wake(), as there a= re - * callers outside of aio_co_wake() */ - const char *scheduled =3D atomic_mb_read(&co->scheduled); - - trace_qemu_aio_coroutine_enter(ctx, self, co, co->entry_arg); - - /* if the Coroutine has already been scheduled, entering it again will - * cause us to enter it twice, potentially even after the coroutine has - * been deleted */ - if (scheduled) { - fprintf(stderr, - "%s: Co-routine was already scheduled in '%s'\n", - __func__, scheduled); - abort(); - } - - if (co->caller) { - fprintf(stderr, "Co-routine re-entered recursively\n"); - abort(); - } - - co->caller =3D self; - co->ctx =3D ctx; - - /* Store co->ctx before anything that stores co. Matches - * barrier in aio_co_wake and qemu_co_mutex_wake. - */ - smp_wmb(); - - ret =3D qemu_coroutine_switch(self, co, COROUTINE_ENTER); - - qemu_co_queue_run_restart(co); - - /* Beware, if ret =3D=3D COROUTINE_YIELD and qemu_co_queue_run_restart= () - * has started any other coroutine, "co" might have been reentered - * and even freed by now! So be careful and do not touch it. - */ - - switch (ret) { - case COROUTINE_YIELD: - return; - case COROUTINE_TERMINATE: - assert(!co->locks_held); - trace_qemu_coroutine_terminate(co); - coroutine_delete(co); - return; - default: - abort(); + QSIMPLEQ_HEAD(, Coroutine) pending =3D QSIMPLEQ_HEAD_INITIALIZER(pendi= ng); + Coroutine *from =3D qemu_coroutine_self(); + + QSIMPLEQ_INSERT_TAIL(&pending, co, co_queue_next); + + /* Run co and any queued coroutines */ + while (!QSIMPLEQ_EMPTY(&pending)) { + Coroutine *to =3D QSIMPLEQ_FIRST(&pending); + CoroutineAction ret; + + /* Cannot rely on the read barrier for to in aio_co_wake(), as the= re are + * callers outside of aio_co_wake() */ + const char *scheduled =3D atomic_mb_read(&to->scheduled); + + QSIMPLEQ_REMOVE_HEAD(&pending, co_queue_next); + + trace_qemu_aio_coroutine_enter(ctx, from, to, to->entry_arg); + + /* if the Coroutine has already been scheduled, entering it again = will + * cause us to enter it twice, potentially even after the coroutin= e has + * been deleted */ + if (scheduled) { + fprintf(stderr, + "%s: Co-routine was already scheduled in '%s'\n", + __func__, scheduled); + abort(); + } + + if (to->caller) { + fprintf(stderr, "Co-routine re-entered recursively\n"); + abort(); + } + + to->caller =3D from; + to->ctx =3D ctx; + + /* Store to->ctx before anything that stores to. Matches + * barrier in aio_co_wake and qemu_co_mutex_wake. + */ + smp_wmb(); + + ret =3D qemu_coroutine_switch(from, to, COROUTINE_ENTER); + + /* Queued coroutines are run depth-first; previously pending corou= tines + * run after those queued more recently. + */ + QSIMPLEQ_PREPEND(&pending, &to->co_queue_wakeup); + + switch (ret) { + case COROUTINE_YIELD: + break; + case COROUTINE_TERMINATE: + assert(!to->locks_held); + trace_qemu_coroutine_terminate(to); + coroutine_delete(to); + break; + default: + abort(); + } } } =20 --=20 2.14.3 From nobody Sat Oct 25 21:42:27 2025 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1521733071467151.31935791105127; Thu, 22 Mar 2018 08:37:51 -0700 (PDT) Received: from localhost ([::1]:33217 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ez2Hm-0006aJ-Kv for importer@patchew.org; Thu, 22 Mar 2018 11:37:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ez299-0000Ml-2P for qemu-devel@nongnu.org; Thu, 22 Mar 2018 11:28:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ez297-0008Cf-Vn for qemu-devel@nongnu.org; Thu, 22 Mar 2018 11:28:55 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:49896 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ez293-00088P-7f; Thu, 22 Mar 2018 11:28:49 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CCD298182D3A; Thu, 22 Mar 2018 15:28:48 +0000 (UTC) Received: from localhost (unknown [10.36.118.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 676C42023230; Thu, 22 Mar 2018 15:28:48 +0000 (UTC) From: Stefan Hajnoczi To: Date: Thu, 22 Mar 2018 15:28:34 +0000 Message-Id: <20180322152834.12656-4-stefanha@redhat.com> In-Reply-To: <20180322152834.12656-1-stefanha@redhat.com> References: <20180322152834.12656-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 22 Mar 2018 15:28:48 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 22 Mar 2018 15:28:48 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'stefanha@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 3/3] coroutine: add test-aio coroutine queue chaining test case 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 , Fam Zheng , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , Paolo Bonzini 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" Check that two coroutines can queue each other repeatedly without hitting stack exhaustion. Switch to qemu_init_main_loop() in main() because coroutines use qemu_get_aio_context() - they don't know about test-aio's ctx variable. Signed-off-by: Stefan Hajnoczi Reviewed-by: Paolo Bonzini --- tests/test-aio.c | 65 ++++++++++++++++++++++++++++++++++++++++++++--------= ---- 1 file changed, 52 insertions(+), 13 deletions(-) diff --git a/tests/test-aio.c b/tests/test-aio.c index 54e20d6ab1..86fb73b3d5 100644 --- a/tests/test-aio.c +++ b/tests/test-aio.c @@ -16,6 +16,8 @@ #include "qemu/timer.h" #include "qemu/sockets.h" #include "qemu/error-report.h" +#include "qemu/coroutine.h" +#include "qemu/main-loop.h" =20 static AioContext *ctx; =20 @@ -827,24 +829,59 @@ static void test_source_timer_schedule(void) timer_del(&data.timer); } =20 +/* + * Check that aio_co_enter() can chain many times + * + * Two coroutines should be able to invoke each other via aio_co_enter() m= any + * times without hitting a limit like stack exhaustion. In other words, t= he + * calls should be chained instead of nested. + */ + +typedef struct { + Coroutine *other; + unsigned i; + unsigned max; +} ChainData; + +static void coroutine_fn chain(void *opaque) +{ + ChainData *data =3D opaque; + + for (data->i =3D 0; data->i < data->max; data->i++) { + /* Queue up the other coroutine... */ + aio_co_enter(ctx, data->other); + + /* ...and give control to it */ + qemu_coroutine_yield(); + } +} + +static void test_queue_chaining(void) +{ + /* This number of iterations hit stack exhaustion in the past: */ + ChainData data_a =3D { .max =3D 25000 }; + ChainData data_b =3D { .max =3D 25000 }; + + data_b.other =3D qemu_coroutine_create(chain, &data_a); + data_a.other =3D qemu_coroutine_create(chain, &data_b); + + qemu_coroutine_enter(data_b.other); + + g_assert_cmpint(data_a.i, =3D=3D, data_a.max); + g_assert_cmpint(data_b.i, =3D=3D, data_b.max - 1); + + /* Allow the second coroutine to terminate */ + qemu_coroutine_enter(data_a.other); + + g_assert_cmpint(data_b.i, =3D=3D, data_b.max); +} =20 /* End of tests. */ =20 int main(int argc, char **argv) { - Error *local_error =3D NULL; - GSource *src; - - init_clocks(NULL); - - ctx =3D aio_context_new(&local_error); - if (!ctx) { - error_reportf_err(local_error, "Failed to create AIO Context: "); - exit(1); - } - src =3D aio_get_g_source(ctx); - g_source_attach(src, NULL); - g_source_unref(src); + qemu_init_main_loop(&error_fatal); + ctx =3D qemu_get_aio_context(); =20 while (g_main_context_iteration(NULL, false)); =20 @@ -864,6 +901,8 @@ int main(int argc, char **argv) g_test_add_func("/aio/external-client", test_aio_external_clie= nt); g_test_add_func("/aio/timer/schedule", test_timer_schedule); =20 + g_test_add_func("/aio/coroutine/queue-chaining", test_queue_chaining); + g_test_add_func("/aio-gsource/flush", test_source_fl= ush); g_test_add_func("/aio-gsource/bh/schedule", test_source_bh= _schedule); g_test_add_func("/aio-gsource/bh/schedule10", test_source_bh= _schedule10); --=20 2.14.3