summaryrefslogtreecommitdiffstats
path: root/softmmu
diff options
context:
space:
mode:
authorAkihiko Odaki2022-08-19 15:27:54 +0200
committerGerd Hoffmann2022-09-23 14:36:33 +0200
commitbab6a301c58286229ca8fbc36728d1469f243260 (patch)
tree82377727d84f3d0a6c8348fe9073d530d1b4c3d9 /softmmu
parentui/console: Get tab completion working again in the SDL monitor vc (diff)
downloadqemu-bab6a301c58286229ca8fbc36728d1469f243260.tar.gz
qemu-bab6a301c58286229ca8fbc36728d1469f243260.tar.xz
qemu-bab6a301c58286229ca8fbc36728d1469f243260.zip
ui/cocoa: Run qemu_init in the main thread
This work is based on: https://patchew.org/QEMU/20220317125534.38706-1-philippe.mathieu.daude@gmail.com/ Simplify the initialization dance by running qemu_init() in the main thread before the Cocoa event loop starts. The secondary thread only runs only qemu_main_loop() and qemu_cleanup(). This fixes a case where addRemovableDevicesMenuItems() calls qmp_query_block() while expecting the main thread to still hold the BQL. Overriding the code after calling qemu_init() is done by dynamically replacing a function pointer variable, qemu_main when initializing ui/cocoa, which unifies the static implementation of main() for builds with ui/cocoa and ones without ui/cocoa. Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com> Message-Id: <20220819132756.74641-2-akihiko.odaki@gmail.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'softmmu')
-rw-r--r--softmmu/main.c10
-rw-r--r--softmmu/vl.c2
2 files changed, 6 insertions, 6 deletions
diff --git a/softmmu/main.c b/softmmu/main.c
index 1b675a8c03..694388bd7f 100644
--- a/softmmu/main.c
+++ b/softmmu/main.c
@@ -30,20 +30,20 @@
#include <SDL.h>
#endif
-int qemu_main(int argc, char **argv, char **envp)
+int qemu_default_main(void)
{
int status;
- qemu_init(argc, argv, envp);
status = qemu_main_loop();
qemu_cleanup();
return status;
}
-#ifndef CONFIG_COCOA
+int (*qemu_main)(void) = qemu_default_main;
+
int main(int argc, char **argv)
{
- return qemu_main(argc, argv, NULL);
+ qemu_init(argc, argv);
+ return qemu_main();
}
-#endif
diff --git a/softmmu/vl.c b/softmmu/vl.c
index e62b9cc35d..9abadcc150 100644
--- a/softmmu/vl.c
+++ b/softmmu/vl.c
@@ -2605,7 +2605,7 @@ void qmp_x_exit_preconfig(Error **errp)
}
}
-void qemu_init(int argc, char **argv, char **envp)
+void qemu_init(int argc, char **argv)
{
QemuOpts *opts;
QemuOpts *icount_opts = NULL, *accel_opts = NULL;