qemu/system
Pierrick Bouvier fa3f3a33f3 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] f5ab12caba

Fixes: https://gitlab.com/qemu-project/qemu/-/issues/2907
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20250410225550.46807-2-pierrick.bouvier@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2025-04-14 11:03:16 -04:00
..
arch_init.c system: Replace arch_type global by qemu_arch_available() helper 2025-03-11 20:03:26 +01:00
async-teardown.c qemu/osdep: Add excluded fd parameter to qemu_close_all_open_fd() 2024-08-05 08:21:59 +10:00
balloon.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
bootdevice.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
cpu-timers.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
cpus.c accel: Forward-declare AccelOpsClass in 'qemu/typedefs.h' 2025-03-06 15:46:18 +01:00
datadir.c system: Rename softmmu/ directory as system/ 2023-10-08 21:08:08 +02:00
device_tree-stub.c hw/core/machine.c: Make -machine dumpdtb=file.dtb with no DTB an error 2025-02-25 15:32:57 +00:00
device_tree.c hw/core/machine.c: Make -machine dumpdtb=file.dtb with no DTB an error 2025-02-25 15:32:57 +00:00
dirtylimit.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
dma-helpers.c dma: use current AioContext for dma_blk_io() 2025-03-13 17:57:23 +01:00
globals-target.c system: Extract target-specific globals to their own compilation unit 2025-03-11 20:03:26 +01:00
globals.c accel/tcg: Restrict 'icount_align_option' global to TCG 2025-03-06 15:46:17 +01:00
ioport.c qdev: Use machine_get_container() 2025-01-09 18:16:24 +01:00
main.c system/main: transfer replay mutex ownership from main thread to main loop thread 2025-04-14 11:03:16 -04:00
memory.c physmem: qemu_ram_alloc_from_fd extensions 2025-01-29 11:43:03 -03:00
memory_ldst.c.inc memory: pass MemTxAttrs to memory_access_is_direct() 2025-02-12 11:33:05 -05:00
memory_mapping.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
meson.build system: Extract target-specific globals to their own compilation unit 2025-03-11 20:03:26 +01:00
physmem.c migration: Avoid SNP guest crash due to duplicate cpr blocker 2025-03-27 15:29:42 -03:00
qdev-monitor.c system: Replace arch_type global by qemu_arch_available() helper 2025-03-11 20:03:26 +01:00
qemu-seccomp.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
qtest.c tests/qtest: tighten up the checks on clock_step 2025-02-10 13:47:58 +00:00
rtc.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
runstate-action.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
runstate-hmp-cmds.c qapi: Move include/qapi/qmp/ to include/qobject/ 2025-02-10 15:33:16 +01:00
runstate.c system/runstate: Fix regression, clarify BQL status of exit notifiers 2025-01-15 18:05:19 +00:00
tpm-hmp-cmds.c system: Rename softmmu/ directory as system/ 2023-10-08 21:08:08 +02:00
tpm.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
trace-events physmem: fd-based shared memory 2025-01-29 11:43:04 -03:00
trace.h system: Rename softmmu/ directory as system/ 2023-10-08 21:08:08 +02:00
vl.c system: Replace arch_type global by qemu_arch_available() helper 2025-03-11 20:03:26 +01:00
watchpoint.c exec: Declare tlb_flush*() in 'exec/cputlb.h' 2025-03-08 07:56:14 -08:00