[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 1/5] softmmu: add means to pass an exit code when requesti
From: |
Alistair Francis |
Subject: |
Re: [PATCH v3 1/5] softmmu: add means to pass an exit code when requesting a shutdown |
Date: |
Mon, 18 Sep 2023 12:03:46 +1000 |
On Thu, Sep 7, 2023 at 9:26 PM Clément Chigot <chigot@adacore.com> wrote:
>
> 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>
Alistair
> ---
> include/sysemu/runstate.h | 2 ++
> softmmu/runstate.c | 12 +++++++++++-
> 2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h
> index 7beb29c2e2..1e59e0b12b 100644
> --- a/include/sysemu/runstate.h
> +++ b/include/sysemu/runstate.h
> @@ -61,6 +61,8 @@ void qemu_system_wakeup_request(WakeupReason reason, Error
> **errp);
> void qemu_system_wakeup_enable(WakeupReason reason, bool enabled);
> void qemu_register_wakeup_notifier(Notifier *notifier);
> 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_powerdown_request(void);
> void qemu_register_powerdown_notifier(Notifier *notifier);
> diff --git a/softmmu/runstate.c b/softmmu/runstate.c
> index f3bd862818..ee27e26048 100644
> --- a/softmmu/runstate.c
> +++ b/softmmu/runstate.c
> @@ -345,6 +345,7 @@ void vm_state_notify(bool running, RunState state)
>
> static ShutdownCause reset_requested;
> static ShutdownCause shutdown_requested;
> +static int shutdown_exit_code = EXIT_SUCCESS;
> static int shutdown_signal;
> static pid_t shutdown_pid;
> static int powerdown_requested;
> @@ -624,6 +625,13 @@ void qemu_system_killed(int signal, pid_t pid)
> 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)
> {
> trace_qemu_system_shutdown_request(reason);
> @@ -685,7 +693,9 @@ static bool main_loop_should_exit(int *status)
> if (shutdown_action == SHUTDOWN_ACTION_PAUSE) {
> vm_stop(RUN_STATE_SHUTDOWN);
> } 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) {
> *status = EXIT_FAILURE;
> }
> --
> 2.25.1
>
- [PATCH v3 4/5] hw/char: riscv_htif: replace exit calls with proper shutdown, (continued)
- [PATCH v3 4/5] hw/char: riscv_htif: replace exit calls with proper shutdown, Clément Chigot, 2023/09/07
- [PATCH v3 5/5] gdbstub: replace exit calls with proper shutdown for softmmu, Clément Chigot, 2023/09/07
- [PATCH v3 2/5] softmmu: pass the main loop status to gdb "Wxx" packet, Clément Chigot, 2023/09/07
- [PATCH v3 3/5] hw/misc/sifive_test.c: replace exit calls with proper shutdown, Clément Chigot, 2023/09/07
- [PATCH v3 1/5] softmmu: add means to pass an exit code when requesting a shutdown, Clément Chigot, 2023/09/07
- Re: [PATCH v3 1/5] softmmu: add means to pass an exit code when requesting a shutdown,
Alistair Francis <=