From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39856) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZqbRw-0000OR-TI for qemu-devel@nongnu.org; Mon, 26 Oct 2015 02:40:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZqbRw-0000Gg-2s for qemu-devel@nongnu.org; Mon, 26 Oct 2015 02:40:08 -0400 From: Fam Zheng Date: Mon, 26 Oct 2015 14:39:41 +0800 Message-Id: <1445841582-17755-2-git-send-email-famz@redhat.com> In-Reply-To: <1445841582-17755-1-git-send-email-famz@redhat.com> References: <1445841582-17755-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v3 1/2] aio: Introduce aio_context_setup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , pbonzini@redhat.com, qemu-block@nongnu.org, Stefan Hajnoczi This is the place to initialize platform specific bits of AioContext. Signed-off-by: Fam Zheng --- aio-posix.c | 4 ++++ aio-win32.c | 4 ++++ async.c | 13 +++++++++++-- include/block/aio.h | 8 ++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/aio-posix.c b/aio-posix.c index d477033..597cb35 100644 --- a/aio-posix.c +++ b/aio-posix.c @@ -297,3 +297,7 @@ bool aio_poll(AioContext *ctx, bool blocking) return progress; } + +void aio_context_setup(AioContext *ctx, Error **errp) +{ +} diff --git a/aio-win32.c b/aio-win32.c index 50a6867..4742af3 100644 --- a/aio-win32.c +++ b/aio-win32.c @@ -363,3 +363,7 @@ bool aio_poll(AioContext *ctx, bool blocking) aio_context_release(ctx); return progress; } + +void aio_context_setup(AioContext *ctx, Error **errp) +{ +} diff --git a/async.c b/async.c index efce14b..f4b1410 100644 --- a/async.c +++ b/async.c @@ -320,12 +320,18 @@ AioContext *aio_context_new(Error **errp) { int ret; AioContext *ctx; + Error *local_err = NULL; + ctx = (AioContext *) g_source_new(&aio_source_funcs, sizeof(AioContext)); + aio_context_setup(ctx, &local_err); + if (local_err) { + error_propagate(errp, local_err); + goto fail; + } ret = event_notifier_init(&ctx->notifier, false); if (ret < 0) { - g_source_destroy(&ctx->source); error_setg_errno(errp, -ret, "Failed to initialize event notifier"); - return NULL; + goto fail; } g_source_set_can_recurse(&ctx->source, true); aio_set_event_notifier(ctx, &ctx->notifier, @@ -339,6 +345,9 @@ AioContext *aio_context_new(Error **errp) ctx->notify_dummy_bh = aio_bh_new(ctx, notify_dummy_bh, NULL); return ctx; +fail: + g_source_destroy(&ctx->source); + return NULL; } void aio_context_ref(AioContext *ctx) diff --git a/include/block/aio.h b/include/block/aio.h index 400b1b0..a6fd5ad 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -373,4 +373,12 @@ static inline void aio_timer_init(AioContext *ctx, */ int64_t aio_compute_timeout(AioContext *ctx); +/** + * aio_context_setup: + * @ctx: the aio context + * + * Initialize the aio context. + */ +void aio_context_setup(AioContext *ctx, Error **errp); + #endif -- 2.4.3