aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorAarushi Mehta <mehta.aaru20@gmail.com>2020-01-20 14:18:49 +0000
committerStefan Hajnoczi <stefanha@redhat.com>2020-01-30 20:59:41 +0000
commitfcb7a4a4e8ae8938e86a669dd9c276ee98aa4203 (patch)
treed1862d5389414fb74c3fd0fd6b015f8f388cb42d /util
parent06a47ef57c3baa9b06006cd424afe89bbaf162b5 (diff)
downloadqemu-fcb7a4a4e8ae8938e86a669dd9c276ee98aa4203.zip
qemu-fcb7a4a4e8ae8938e86a669dd9c276ee98aa4203.tar.gz
qemu-fcb7a4a4e8ae8938e86a669dd9c276ee98aa4203.tar.bz2
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 b1fa531..c192a24 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);