summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorAarushi Mehta2020-01-20 15:18:49 +0100
committerStefan Hajnoczi2020-01-30 21:59:41 +0100
commitfcb7a4a4e8ae8938e86a669dd9c276ee98aa4203 (patch)
treed1862d5389414fb74c3fd0fd6b015f8f388cb42d /util
parentstubs: add stubs for io_uring interface (diff)
downloadqemu-fcb7a4a4e8ae8938e86a669dd9c276ee98aa4203.tar.gz
qemu-fcb7a4a4e8ae8938e86a669dd9c276ee98aa4203.tar.xz
qemu-fcb7a4a4e8ae8938e86a669dd9c276ee98aa4203.zip
util/async: add aio interfaces for io_uring
Signed-off-by: Aarushi Mehta <mehta.aaru20@gmail.com> Acked-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Message-id: 20200120141858.587874-7-stefanha@redhat.com Message-Id: <20200120141858.587874-7-stefanha@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'util')
-rw-r--r--util/async.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/util/async.c b/util/async.c
index b1fa5319e5..c192a24a61 100644
--- a/util/async.c
+++ b/util/async.c
@@ -276,6 +276,14 @@ aio_ctx_finalize(GSource *source)
}
#endif
+#ifdef CONFIG_LINUX_IO_URING
+ if (ctx->linux_io_uring) {
+ luring_detach_aio_context(ctx->linux_io_uring, ctx);
+ luring_cleanup(ctx->linux_io_uring);
+ ctx->linux_io_uring = NULL;
+ }
+#endif
+
assert(QSLIST_EMPTY(&ctx->scheduled_coroutines));
qemu_bh_delete(ctx->co_schedule_bh);
@@ -340,6 +348,29 @@ LinuxAioState *aio_get_linux_aio(AioContext *ctx)
}
#endif
+#ifdef CONFIG_LINUX_IO_URING
+LuringState *aio_setup_linux_io_uring(AioContext *ctx, Error **errp)
+{
+ if (ctx->linux_io_uring) {
+ return ctx->linux_io_uring;
+ }
+
+ ctx->linux_io_uring = luring_init(errp);
+ if (!ctx->linux_io_uring) {
+ return NULL;
+ }
+
+ luring_attach_aio_context(ctx->linux_io_uring, ctx);
+ return ctx->linux_io_uring;
+}
+
+LuringState *aio_get_linux_io_uring(AioContext *ctx)
+{
+ assert(ctx->linux_io_uring);
+ return ctx->linux_io_uring;
+}
+#endif
+
void aio_notify(AioContext *ctx)
{
/* Write e.g. bh->scheduled before reading ctx->notify_me. Pairs
@@ -434,6 +465,11 @@ AioContext *aio_context_new(Error **errp)
#ifdef CONFIG_LINUX_AIO
ctx->linux_aio = NULL;
#endif
+
+#ifdef CONFIG_LINUX_IO_URING
+ ctx->linux_io_uring = NULL;
+#endif
+
ctx->thread_pool = NULL;
qemu_rec_mutex_init(&ctx->lock);
timerlistgroup_init(&ctx->tlg, aio_timerlist_notify, ctx);