Skip to content

Commit fa3f3a3

Browse files
pbo-linarostefanhaRH
authored andcommitted
system/main: transfer replay mutex ownership from main thread to main loop thread
On MacOS, UI event loop has to be ran in the main thread of a process. Because of that restriction, on this platform, qemu main event loop is ran on another thread [1]. This breaks record/replay feature, which expects thread running qemu_init to initialize hold this lock, breaking associated functional tests on MacOS. Thus, as a generalization, and similar to how BQL is handled, we release it after init, and reacquire the lock before entering main event loop, avoiding a special case if a separate thread is used. Tested on MacOS with: $ meson test -C build --setup thorough --print-errorlogs \ func-x86_64-x86_64_replay func-arm-arm_replay func-aarch64-aarch64_replay $ ./build/qemu-system-x86_64 -nographic -icount shift=auto,rr=record,rrfile=replay.log $ ./build/qemu-system-x86_64 -nographic -icount shift=auto,rr=replay,rrfile=replay.log [1] https://gitlab.com/qemu-project/qemu/-/commit/f5ab12caba4f1656479c1feb5248beac1c833243 Fixes: https://gitlab.com/qemu-project/qemu/-/issues/2907 Signed-off-by: Pierrick Bouvier <[email protected]> Reviewed-by: Nicholas Piggin <[email protected]> Tested-by: Philippe Mathieu-Daudé <[email protected]> Message-ID: <[email protected]> Signed-off-by: Stefan Hajnoczi <[email protected]>
1 parent 100e8e2 commit fa3f3a3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

system/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "qemu/osdep.h"
2626
#include "qemu-main.h"
2727
#include "qemu/main-loop.h"
28+
#include "system/replay.h"
2829
#include "system/system.h"
2930

3031
#ifdef CONFIG_SDL
@@ -44,10 +45,12 @@ static void *qemu_default_main(void *opaque)
4445
{
4546
int status;
4647

48+
replay_mutex_lock();
4749
bql_lock();
4850
status = qemu_main_loop();
4951
qemu_cleanup(status);
5052
bql_unlock();
53+
replay_mutex_unlock();
5154

5255
exit(status);
5356
}
@@ -67,6 +70,7 @@ int main(int argc, char **argv)
6770
{
6871
qemu_init(argc, argv);
6972
bql_unlock();
73+
replay_mutex_unlock();
7074
if (qemu_main) {
7175
QemuThread main_loop_thread;
7276
qemu_thread_create(&main_loop_thread, "qemu_main",

0 commit comments

Comments
 (0)