[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V1 02/26] vl: helper to request re-exec
|
From: |
Steve Sistare |
|
Subject: |
[PATCH V1 02/26] vl: helper to request re-exec |
|
Date: |
Mon, 29 Apr 2024 08:55:11 -0700 |
Add a qemu_system_exec_request() hook that causes the main loop to exit and
re-exec qemu using the specified arguments.
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
include/sysemu/runstate.h | 3 +++
system/runstate.c | 29 +++++++++++++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h
index 0117d24..cb669cf 100644
--- a/include/sysemu/runstate.h
+++ b/include/sysemu/runstate.h
@@ -80,6 +80,8 @@ typedef enum WakeupReason {
QEMU_WAKEUP_REASON_OTHER,
} WakeupReason;
+typedef void (*qemu_exec_func)(char **exec_argv);
+
void qemu_system_reset_request(ShutdownCause reason);
void qemu_system_suspend_request(void);
void qemu_register_suspend_notifier(Notifier *notifier);
@@ -91,6 +93,7 @@ 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_exec_request(qemu_exec_func func, const strList *args);
void qemu_system_powerdown_request(void);
void qemu_register_powerdown_notifier(Notifier *notifier);
void qemu_register_shutdown_notifier(Notifier *notifier);
diff --git a/system/runstate.c b/system/runstate.c
index cb4905a..0de0c6e 100644
--- a/system/runstate.c
+++ b/system/runstate.c
@@ -40,6 +40,7 @@
#include "qapi/error.h"
#include "qapi/qapi-commands-run-state.h"
#include "qapi/qapi-events-run-state.h"
+#include "qapi/type-helpers.h"
#include "qemu/accel.h"
#include "qemu/error-report.h"
#include "qemu/job.h"
@@ -401,6 +402,8 @@ static NotifierList wakeup_notifiers =
static NotifierList shutdown_notifiers =
NOTIFIER_LIST_INITIALIZER(shutdown_notifiers);
static uint32_t wakeup_reason_mask = ~(1 << QEMU_WAKEUP_REASON_NONE);
+qemu_exec_func exec_func;
+static char **exec_argv;
ShutdownCause qemu_shutdown_requested_get(void)
{
@@ -417,6 +420,11 @@ static int qemu_shutdown_requested(void)
return qatomic_xchg(&shutdown_requested, SHUTDOWN_CAUSE_NONE);
}
+static int qemu_exec_requested(void)
+{
+ return exec_argv != NULL;
+}
+
static void qemu_kill_report(void)
{
if (!qtest_driver() && shutdown_signal) {
@@ -694,6 +702,23 @@ void qemu_system_shutdown_request(ShutdownCause reason)
qemu_notify_event();
}
+static void qemu_system_exec(void)
+{
+ exec_func(exec_argv);
+
+ /* exec failed */
+ g_strfreev(exec_argv);
+ exec_argv = NULL;
+ exec_func = NULL;
+}
+
+void qemu_system_exec_request(qemu_exec_func func, const strList *args)
+{
+ exec_func = func;
+ exec_argv = strv_from_str_list(args);
+ qemu_notify_event();
+}
+
static void qemu_system_powerdown(void)
{
qapi_event_send_powerdown();
@@ -740,6 +765,10 @@ static bool main_loop_should_exit(int *status)
if (qemu_suspend_requested()) {
qemu_system_suspend();
}
+ if (qemu_exec_requested()) {
+ qemu_system_exec();
+ return false;
+ }
request = qemu_shutdown_requested();
if (request) {
qemu_kill_report();
--
1.8.3.1
- [PATCH V1 00/26] Live update: cpr-exec, Steve Sistare, 2024/04/29
- [PATCH V1 02/26] vl: helper to request re-exec,
Steve Sistare <=
- [PATCH V1 01/26] oslib: qemu_clear_cloexec, Steve Sistare, 2024/04/29
- [PATCH V1 06/26] migration: precreate vmstate for exec, Steve Sistare, 2024/04/29
- [PATCH V1 11/26] migration: vmstate_register at init time, Steve Sistare, 2024/04/29
- [PATCH V1 12/26] migration: vmstate factory object, Steve Sistare, 2024/04/29
- [PATCH V1 04/26] migration: delete unused parameter mis, Steve Sistare, 2024/04/29
- [PATCH V1 03/26] migration: SAVEVM_FOREACH, Steve Sistare, 2024/04/29
- [PATCH V1 05/26] migration: precreate vmstate, Steve Sistare, 2024/04/29
- [PATCH V1 22/26] migration: ram block cpr-exec blockers, Steve Sistare, 2024/04/29
- [PATCH V1 10/26] migration: vmstate_unregister_named, Steve Sistare, 2024/04/29
- [PATCH V1 24/26] seccomp: cpr-exec blocker, Steve Sistare, 2024/04/29