Use `qemu_exit()` function instead of `exit()`
Goal
Reduce the amount of changes for Unicorn (and alike) frameworks
Technical details
Currently, there is a plenty of exit(0)
calls across QEMU codebase. Some projects, e.g. Unicorn convert QEMU into a library, for which calls like that are obviously undesirable. While QEMU doesn't aim to become a library mainstream (at least yet), a simple refactoring of just one function could make this much easier and reduce the amount of necessary changes.
Additional information
I just saw the similar refactoring for the GDB part of QEMU and thought it might be useful in more general case too: https://lore.kernel.org/qemu-devel/20230907112640.292104-1-chigot@adacore.com/T/#m540552946cfa960b34c4d76d2302324f5de8627f
$ rg "exit\(0" -t c -l
gdbstub/gdbstub.c
qemu-edid.c
subprojects/libvhost-user/libvhost-user.c
semihosting/arm-compat-semi.c
softmmu/async-teardown.c
softmmu/device_tree.c
softmmu/vl.c
softmmu/runstate.c
os-posix.c
dtc/util.c
dtc/dtc.c
dtc/tests/dumptrees.c
qemu-keymap.c
qemu-io.c
contrib/ivshmem-server/main.c
contrib/rdmacm-mux/main.c
tests/qtest/vhost-user-blk-test.c
tests/qtest/fuzz/fuzz.c
tests/qtest/fuzz/generic_fuzz.c
tests/unit/test-seccomp.c
tests/unit/test-rcu-list.c
tests/unit/rcutorture.c
tests/bench/qht-bench.c
tests/bench/atomic64-bench.c
tests/bench/atomic_add-bench.c
tests/unit/test-iov.c
tests/tcg/multiarch/linux/linux-test.c
tests/tcg/aarch64/mte-3.c
tests/tcg/aarch64/pauth-2.c
tests/tcg/aarch64/mte-5.c
tests/tcg/aarch64/mte-6.c
tests/tcg/aarch64/mte-2.c
tests/tcg/cris/libc/check_glibc_kernelversion.c
tests/tcg/cris/libc/check_lz.c
tests/tcg/s390x/signals-s390x.c
tests/tcg/i386/hello-i386.c
tests/tcg/cris/bare/sys.c
tests/tcg/ppc64/mtfsf.c
qemu-nbd.c
net/net.c
hw/nvram/eeprom93xx.c
hw/arm/allwinner-r40.c
hw/rdma/rdma_backend.c
hw/watchdog/watchdog.c
trace/control.c
hw/pci/pci.c
hw/misc/sifive_test.c
Edited by Anton Kochkov