From a5034584c0e81054b44570978c26b42d26715195 Mon Sep 17 00:00:00 2001
From: Matt Borgerson <contact@mborgerson.com>
Date: Fri, 28 Jul 2023 14:38:00 -0700
Subject: [PATCH] vl: Move input init to exit_preconfig

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

diff --git a/softmmu/vl.c b/softmmu/vl.c
index cdc485e3d3..c1a3246349 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2651,6 +2651,8 @@ void qmp_x_exit_preconfig(Error **errp)
     qemu_create_cli_devices();
     qemu_machine_creation_done();
 
+    xemu_input_init();
+
     if (loadvm) {
         load_snapshot(loadvm, NULL, false, NULL, &error_fatal);
     }
diff --git a/ui/xemu.c b/ui/xemu.c
index b06e19eb1c..5fa4ae2573 100644
--- a/ui/xemu.c
+++ b/ui/xemu.c
@@ -1540,12 +1540,6 @@ 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);
         assert(glGetError() == GL_NO_ERROR);