This replaces the exit calls by shutdown requests, ensuring a proper
cleanup of Qemu. Features like net/vhost-vdpa.c are expecting
qemu_cleanup to be called to remove their last residuals.
Signed-off-by: Clément Chigot <chigot@adacore.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <
20231003071427.188697-6-chigot@adacore.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
gdb_put_packet("OK");
error_report("QEMU: Terminated via GDBstub");
gdb_exit(0);
- exit(0);
+ gdb_qemu_exit(0);
}
static const GdbCmdParseEntry gdb_v_commands_table[] = {
/* Kill the target */
error_report("QEMU: Terminated via GDBstub");
gdb_exit(0);
- exit(0);
+ gdb_qemu_exit(0);
+ break;
case 'D':
{
static const GdbCmdParseEntry detach_cmd_desc = {
qemu_chr_fe_deinit(&gdbserver_system_state.chr, true);
}
+void gdb_qemu_exit(int code)
+{
+ qemu_system_shutdown_request_with_code(SHUTDOWN_CAUSE_GUEST_SHUTDOWN,
+ code);
+}
+
/*
* Memory access
*/
gdb_put_packet(buf);
gdbserver_state.allow_stop_reply = false;
}
+
+}
+
+void gdb_qemu_exit(int code)
+{
+ exit(code);
}
int gdb_handlesig(CPUState *cpu, int sig)
*/
void gdb_exit(int code);
+/**
+ * gdb_qemu_exit: ask qemu to exit
+ * @code: exit code reported
+ *
+ * This requests qemu to exit. This function is allowed to return as
+ * the exit request might be processed asynchronously by qemu backend.
+ */
+void gdb_qemu_exit(int code);
+
#endif /* _SYSCALLS_H_ */