Exit QEMU with user-defined code.
Quit a running QEMU session with user-defined exit code. Useful for unit or integration tests using QEMU.
Pass the -semihosting
argument to QEMU invocation, e.g.:
qemu-system-aarch64 -M raspi3 -serial stdio -semihosting -kernel kernel8.img
Exit the QEMU session from anywhere in your code:
rust
qemu_exit::aarch64::exit_success() // QEMU binary executes `exit(0)`.
qemu_exit::aarch64::exit_failure() // QEMU binary executes `exit(1)`.
qemu_exit::aarch64::exit(arg) // Use a custom code. Argument must implement `Into<u64>`.
Add the special ISA debug exit device by passing the flags:
-device isa-debug-exit,iobase=0xf4,iosize=0x04
The iobase is given as a const generic
:
rust
qemu_exit::x86::exit<{ 0xf4 }>(arg) // Use a custom code. Argument must implement `Into<u32>`.
The QEMU binary will execute exit((arg << 1) | 1)
. This is hardcoded in the
QEMU sources. Therefore, with isa-debug-exit
, it is not possible to let QEMU
invoke exit(0)
.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.