[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 1/7] softmmu: add qemu_[set|get]_exit_status functions
From: |
Luc Michel |
Subject: |
[PATCH v2 1/7] softmmu: add qemu_[set|get]_exit_status functions |
Date: |
Tue, 21 Jun 2022 14:59:10 +0200 |
Add the two function qemu_set_exit_status() and qemu_get_exit_status().
Use qemu_get_exit_status() in main instead of 0 as the return value.
This is in preparation for the semihosting exit request implementation.
Signed-off-by: Luc Michel <lmichel@kalray.eu>
---
include/sysemu/sysemu.h | 2 ++
softmmu/main.c | 2 +-
softmmu/runstate.c | 13 ++++++++++++-
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index 812f66a31a..49b6970d0e 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -103,10 +103,12 @@ void qemu_boot_set(const char *boot_order, Error **errp);
bool defaults_enabled(void);
void qemu_init(int argc, char **argv, char **envp);
void qemu_main_loop(void);
void qemu_cleanup(void);
+void qemu_set_exit_status(int status);
+int qemu_get_exit_status(void);
extern QemuOptsList qemu_legacy_drive_opts;
extern QemuOptsList qemu_common_drive_opts;
extern QemuOptsList qemu_drive_opts;
extern QemuOptsList bdrv_runtime_opts;
diff --git a/softmmu/main.c b/softmmu/main.c
index c00432ff09..67b4bb111e 100644
--- a/softmmu/main.c
+++ b/softmmu/main.c
@@ -34,11 +34,11 @@ int qemu_main(int argc, char **argv, char **envp)
{
qemu_init(argc, argv, envp);
qemu_main_loop();
qemu_cleanup();
- return 0;
+ return qemu_get_exit_status();
}
#ifndef CONFIG_COCOA
int main(int argc, char **argv)
{
diff --git a/softmmu/runstate.c b/softmmu/runstate.c
index fac7b63259..a86ffa91e5 100644
--- a/softmmu/runstate.c
+++ b/softmmu/runstate.c
@@ -336,10 +336,11 @@ void vm_state_notify(bool running, RunState state)
}
static ShutdownCause reset_requested;
static ShutdownCause shutdown_requested;
static int shutdown_signal;
+static int exit_status;
static pid_t shutdown_pid;
static int powerdown_requested;
static int debug_requested;
static int suspend_requested;
static WakeupReason wakeup_reason;
@@ -351,10 +352,20 @@ static NotifierList wakeup_notifiers =
NOTIFIER_LIST_INITIALIZER(wakeup_notifiers);
static NotifierList shutdown_notifiers =
NOTIFIER_LIST_INITIALIZER(shutdown_notifiers);
static uint32_t wakeup_reason_mask = ~(1 << QEMU_WAKEUP_REASON_NONE);
+void qemu_set_exit_status(int status)
+{
+ exit_status = status;
+}
+
+int qemu_get_exit_status(void)
+{
+ return exit_status;
+}
+
ShutdownCause qemu_shutdown_requested_get(void)
{
return shutdown_requested;
}
@@ -779,11 +790,11 @@ void qemu_init_subsystems(void)
}
void qemu_cleanup(void)
{
- gdb_exit(0);
+ gdb_exit(qemu_get_exit_status());
/*
* cleaning up the migration object cancels any existing migration
* try to do this early so that it also stops using devices.
*/
--
2.17.1
- [PATCH v2 0/7] semihosting: proper QEMU exit on semihosted exit syscall, Luc Michel, 2022/06/21
- [PATCH v2 2/7] semihosting: add the semihosting_exit_request function, Luc Michel, 2022/06/21
- [PATCH v2 3/7] semihosting/arm-compat-semi: use semihosting_exit_request, Luc Michel, 2022/06/21
- [PATCH v2 4/7] target/m68k: use semihosting_exit_request on semihosted exit syscall, Luc Michel, 2022/06/21
- [PATCH v2 1/7] softmmu: add qemu_[set|get]_exit_status functions,
Luc Michel <=
- [PATCH v2 5/7] target/mips: use semihosting_exit_request on semihosted exit syscall, Luc Michel, 2022/06/21
- [PATCH v2 7/7] target/xtensa: use semihosting_exit_request on semihosted exit syscall, Luc Michel, 2022/06/21
- [PATCH v2 6/7] target/nios2: use semihosting_exit_request on semihosted exit syscall, Luc Michel, 2022/06/21
- Re: [PATCH v2 0/7] semihosting: proper QEMU exit on semihosted exit syscall, Richard Henderson, 2022/06/21