Skip to content
Snippets Groups Projects
Commit 37fcee5d authored by Fam Zheng's avatar Fam Zheng Committed by Stefan Hajnoczi
Browse files

aio: Introduce aio_context_setup


This is the place to initialize platform specific bits of AioContext.

Signed-off-by: default avatarFam Zheng <famz@redhat.com>
Message-id: 1446177989-6702-3-git-send-email-famz@redhat.com
Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
parent 5ceb9e39
No related branches found
No related tags found
No related merge requests found
...@@ -302,3 +302,7 @@ bool aio_poll(AioContext *ctx, bool blocking) ...@@ -302,3 +302,7 @@ bool aio_poll(AioContext *ctx, bool blocking)
return progress; return progress;
} }
void aio_context_setup(AioContext *ctx, Error **errp)
{
}
...@@ -369,3 +369,7 @@ bool aio_poll(AioContext *ctx, bool blocking) ...@@ -369,3 +369,7 @@ bool aio_poll(AioContext *ctx, bool blocking)
aio_context_release(ctx); aio_context_release(ctx);
return progress; return progress;
} }
void aio_context_setup(AioContext *ctx, Error **errp)
{
}
...@@ -325,12 +325,18 @@ AioContext *aio_context_new(Error **errp) ...@@ -325,12 +325,18 @@ AioContext *aio_context_new(Error **errp)
{ {
int ret; int ret;
AioContext *ctx; AioContext *ctx;
Error *local_err = NULL;
ctx = (AioContext *) g_source_new(&aio_source_funcs, sizeof(AioContext)); 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); ret = event_notifier_init(&ctx->notifier, false);
if (ret < 0) { if (ret < 0) {
g_source_destroy(&ctx->source);
error_setg_errno(errp, -ret, "Failed to initialize event notifier"); error_setg_errno(errp, -ret, "Failed to initialize event notifier");
return NULL; goto fail;
} }
g_source_set_can_recurse(&ctx->source, true); g_source_set_can_recurse(&ctx->source, true);
aio_set_event_notifier(ctx, &ctx->notifier, aio_set_event_notifier(ctx, &ctx->notifier,
...@@ -345,6 +351,9 @@ AioContext *aio_context_new(Error **errp) ...@@ -345,6 +351,9 @@ AioContext *aio_context_new(Error **errp)
ctx->notify_dummy_bh = aio_bh_new(ctx, notify_dummy_bh, NULL); ctx->notify_dummy_bh = aio_bh_new(ctx, notify_dummy_bh, NULL);
return ctx; return ctx;
fail:
g_source_destroy(&ctx->source);
return NULL;
} }
void aio_context_ref(AioContext *ctx) void aio_context_ref(AioContext *ctx)
......
...@@ -429,4 +429,12 @@ static inline bool aio_node_check(AioContext *ctx, bool is_external) ...@@ -429,4 +429,12 @@ static inline bool aio_node_check(AioContext *ctx, bool is_external)
return !is_external || !atomic_read(&ctx->external_disable_cnt); return !is_external || !atomic_read(&ctx->external_disable_cnt);
} }
/**
* aio_context_setup:
* @ctx: the aio context
*
* Initialize the aio context.
*/
void aio_context_setup(AioContext *ctx, Error **errp);
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment