aboutsummaryrefslogtreecommitdiff
path: root/util/async.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/async.c')
-rw-r--r--util/async.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/util/async.c b/util/async.c
index 674dbefb7c..5d9b7cc1eb 100644
--- a/util/async.c
+++ b/util/async.c
@@ -649,3 +649,23 @@ void aio_context_release(AioContext *ctx)
{
qemu_rec_mutex_unlock(&ctx->lock);
}
+
+static __thread AioContext *my_aiocontext;
+
+AioContext *qemu_get_current_aio_context(void)
+{
+ if (my_aiocontext) {
+ return my_aiocontext;
+ }
+ if (qemu_mutex_iothread_locked()) {
+ /* Possibly in a vCPU thread. */
+ return qemu_get_aio_context();
+ }
+ return NULL;
+}
+
+void qemu_set_current_aio_context(AioContext *ctx)
+{
+ assert(!my_aiocontext);
+ my_aiocontext = ctx;
+}