I was wondering if there is a way to exit from qemu from within the guest system in the aarch64 version. For instance the x86 has the isa-debug-exit device which is used for this purpose.
Any ideas?
Cheers
The general answer to this question is "do whatever you would do on the real hardware to cause a power-off". The details of this depend on which machine QEMU is emulating. For the aarch64 "virt" board, you can use the emulated PSCI firmware interface to request a powerdown using the SYSTEM_OFF function.
The PSCI API documentation is here: http://infocenter.arm.com/help/topic/com.arm.doc.den0022d/Power_State_Coordination_Interface_PDD_v1_1_DEN0022D.pdf
For debug/test purposes you might also be interested in the semihosting API (https://developer.arm.com/docs/dui0003/b) which has a SYS_EXIT function, but some caveats: for QEMU you can only use semihosting if you enable it via the -semihosting commandline argument, and only from kernel mode in the guest, and you must only use it if you absolutely trust the guest code, because it provides access to functions that allow the guest to read and write any host file. But for explicitly trusted small test programs it can be a nice way to do easy debug printing and exit with a given exit status.
来源:https://stackoverflow.com/questions/51282334/qemu-system-aarch64-exit-from-within-the-guest-system