mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-18 23:52:14 -06:00
softmmu: add means to pass an exit code when requesting a shutdown
As of now, the exit code was either EXIT_FAILURE when a panic shutdown was requested or EXIT_SUCCESS otherwise. However, some hardware could want to pass more complex exit codes. Thus, introduce a new shutdown request function allowing that. Signed-off-by: Clément Chigot <chigot@adacore.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-ID: <20231003071427.188697-2-chigot@adacore.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
This commit is contained in:
parent
eb992b6091
commit
0386f39b46
2 changed files with 13 additions and 1 deletions
|
@ -68,6 +68,8 @@ void qemu_system_wakeup_request(WakeupReason reason, Error **errp);
|
||||||
void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
|
void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
|
||||||
void qemu_register_wakeup_notifier(Notifier *notifier);
|
void qemu_register_wakeup_notifier(Notifier *notifier);
|
||||||
void qemu_register_wakeup_support(void);
|
void qemu_register_wakeup_support(void);
|
||||||
|
void qemu_system_shutdown_request_with_code(ShutdownCause reason,
|
||||||
|
int exit_code);
|
||||||
void qemu_system_shutdown_request(ShutdownCause reason);
|
void qemu_system_shutdown_request(ShutdownCause reason);
|
||||||
void qemu_system_powerdown_request(void);
|
void qemu_system_powerdown_request(void);
|
||||||
void qemu_register_powerdown_notifier(Notifier *notifier);
|
void qemu_register_powerdown_notifier(Notifier *notifier);
|
||||||
|
|
|
@ -385,6 +385,7 @@ void vm_state_notify(bool running, RunState state)
|
||||||
|
|
||||||
static ShutdownCause reset_requested;
|
static ShutdownCause reset_requested;
|
||||||
static ShutdownCause shutdown_requested;
|
static ShutdownCause shutdown_requested;
|
||||||
|
static int shutdown_exit_code = EXIT_SUCCESS;
|
||||||
static int shutdown_signal;
|
static int shutdown_signal;
|
||||||
static pid_t shutdown_pid;
|
static pid_t shutdown_pid;
|
||||||
static int powerdown_requested;
|
static int powerdown_requested;
|
||||||
|
@ -664,6 +665,13 @@ void qemu_system_killed(int signal, pid_t pid)
|
||||||
qemu_notify_event();
|
qemu_notify_event();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void qemu_system_shutdown_request_with_code(ShutdownCause reason,
|
||||||
|
int exit_code)
|
||||||
|
{
|
||||||
|
shutdown_exit_code = exit_code;
|
||||||
|
qemu_system_shutdown_request(reason);
|
||||||
|
}
|
||||||
|
|
||||||
void qemu_system_shutdown_request(ShutdownCause reason)
|
void qemu_system_shutdown_request(ShutdownCause reason)
|
||||||
{
|
{
|
||||||
trace_qemu_system_shutdown_request(reason);
|
trace_qemu_system_shutdown_request(reason);
|
||||||
|
@ -725,7 +733,9 @@ static bool main_loop_should_exit(int *status)
|
||||||
if (shutdown_action == SHUTDOWN_ACTION_PAUSE) {
|
if (shutdown_action == SHUTDOWN_ACTION_PAUSE) {
|
||||||
vm_stop(RUN_STATE_SHUTDOWN);
|
vm_stop(RUN_STATE_SHUTDOWN);
|
||||||
} else {
|
} else {
|
||||||
if (request == SHUTDOWN_CAUSE_GUEST_PANIC &&
|
if (shutdown_exit_code != EXIT_SUCCESS) {
|
||||||
|
*status = shutdown_exit_code;
|
||||||
|
} else if (request == SHUTDOWN_CAUSE_GUEST_PANIC &&
|
||||||
panic_action == PANIC_ACTION_EXIT_FAILURE) {
|
panic_action == PANIC_ACTION_EXIT_FAILURE) {
|
||||||
*status = EXIT_FAILURE;
|
*status = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue