From 294437a28c3b7542d752b76b8f7833702794e422 Mon Sep 17 00:00:00 2001
From: Matt Borgerson <contact@mborgerson.com>
Date: Sat, 23 Apr 2022 14:19:36 -0700
Subject: [PATCH] input: Move input init to main thread

---
 softmmu/vl.c | 4 ----
 ui/xemu.c    | 6 ++++++
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/softmmu/vl.c b/softmmu/vl.c
index 9f33e526df..64b0330d57 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2719,10 +2719,6 @@ static void qemu_machine_creation_done(void)
 
     qdev_machine_creation_done();
 
-#ifdef XBOX
-    xemu_input_init();
-#endif
-
     if (machine->cgs) {
         /*
          * Verify that Confidential Guest Support has actually been initialized
diff --git a/ui/xemu.c b/ui/xemu.c
index 401b8f2a92..d3fd6c7249 100644
--- a/ui/xemu.c
+++ b/ui/xemu.c
@@ -1561,6 +1561,12 @@ int main(int argc, char **argv)
 
     DPRINTF("Main thread: initializing app\n");
 
+    qemu_mutex_lock_main_loop();
+    qemu_mutex_lock_iothread();
+    xemu_input_init();
+    qemu_mutex_unlock_iothread();
+    qemu_mutex_unlock_main_loop();
+
     while (1) {
         sdl2_gl_refresh(&sdl2_console[0].dcl);
     }