qemu-riscv
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v3 5/5] gdbstub: replace exit calls with proper shutdown for


From: Alistair Francis
Subject: Re: [PATCH v3 5/5] gdbstub: replace exit calls with proper shutdown for softmmu
Date: Mon, 18 Sep 2023 12:09:59 +1000

On Thu, Sep 7, 2023 at 9:26 PM Clément Chigot <chigot@adacore.com> wrote:
>
> 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>

Alistair

> ---
>  gdbstub/gdbstub.c          | 5 +++--
>  gdbstub/softmmu.c          | 6 ++++++
>  gdbstub/user.c             | 6 ++++++
>  include/gdbstub/syscalls.h | 9 +++++++++
>  4 files changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/gdbstub/gdbstub.c b/gdbstub/gdbstub.c
> index 349d348c7b..1cb6d65306 100644
> --- a/gdbstub/gdbstub.c
> +++ b/gdbstub/gdbstub.c
> @@ -1327,7 +1327,7 @@ static void handle_v_kill(GArray *params, void 
> *user_ctx)
>      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[] = {
> @@ -1846,7 +1846,8 @@ static int gdb_handle_packet(const char *line_buf)
>          /* 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 = {
> diff --git a/gdbstub/softmmu.c b/gdbstub/softmmu.c
> index 9f0b8b5497..a5d6e04c79 100644
> --- a/gdbstub/softmmu.c
> +++ b/gdbstub/softmmu.c
> @@ -435,6 +435,12 @@ void gdb_exit(int code)
>      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
>   */
> diff --git a/gdbstub/user.c b/gdbstub/user.c
> index 7ab6e5d975..dbe1d9b887 100644
> --- a/gdbstub/user.c
> +++ b/gdbstub/user.c
> @@ -113,6 +113,12 @@ void gdb_exit(int code)
>          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)
> diff --git a/include/gdbstub/syscalls.h b/include/gdbstub/syscalls.h
> index 243eaf8ce4..54ff7245a1 100644
> --- a/include/gdbstub/syscalls.h
> +++ b/include/gdbstub/syscalls.h
> @@ -110,4 +110,13 @@ int use_gdb_syscalls(void);
>   */
>  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_ */
> --
> 2.25.1
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]