[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V9 20/46] vl: helper to request re-exec
From: |
Steve Sistare |
Subject: |
[PATCH V9 20/46] vl: helper to request re-exec |
Date: |
Tue, 26 Jul 2022 09:10:17 -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 | 1 +
softmmu/runstate.c | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/include/sysemu/runstate.h b/include/sysemu/runstate.h
index f3ed525..a5f0738 100644
--- a/include/sysemu/runstate.h
+++ b/include/sysemu/runstate.h
@@ -62,6 +62,7 @@ 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(ShutdownCause reason);
+void qemu_system_exec_request(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/softmmu/runstate.c b/softmmu/runstate.c
index 168e1b7..14b43df 100644
--- a/softmmu/runstate.c
+++ b/softmmu/runstate.c
@@ -37,6 +37,7 @@
#include "monitor/monitor.h"
#include "net/net.h"
#include "net/vhost_net.h"
+#include "qapi/util.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-run-state.h"
#include "qapi/qapi-events-run-state.h"
@@ -353,6 +354,7 @@ static NotifierList wakeup_notifiers =
static NotifierList shutdown_notifiers =
NOTIFIER_LIST_INITIALIZER(shutdown_notifiers);
static uint32_t wakeup_reason_mask = ~(1 << QEMU_WAKEUP_REASON_NONE);
+static GStrv exec_argv;
ShutdownCause qemu_shutdown_requested_get(void)
{
@@ -369,6 +371,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) {
@@ -627,6 +634,13 @@ void qemu_system_shutdown_request(ShutdownCause reason)
qemu_notify_event();
}
+void qemu_system_exec_request(const strList *args)
+{
+ exec_argv = strv_from_strList(args);
+ shutdown_requested = 1;
+ qemu_notify_event();
+}
+
static void qemu_system_powerdown(void)
{
qapi_event_send_powerdown();
@@ -675,6 +689,16 @@ static bool main_loop_should_exit(void)
}
request = qemu_shutdown_requested();
if (request) {
+
+ if (qemu_exec_requested()) {
+ Error *err = NULL;
+ execvp(exec_argv[0], exec_argv);
+ error_setg_errno(&err, errno, "execvp %s failed", exec_argv[0]);
+ error_report_err(err);
+ g_strfreev(exec_argv);
+ exec_argv = NULL;
+ return false;
+ }
qemu_kill_report();
qemu_system_shutdown(request);
if (shutdown_action == SHUTDOWN_ACTION_PAUSE) {
--
1.8.3.1
- [PATCH V9 01/46] migration: fix populate_vfio_info, (continued)
- [PATCH V9 01/46] migration: fix populate_vfio_info, Steve Sistare, 2022/07/26
- [PATCH V9 14/46] qapi: strList unit tests, Steve Sistare, 2022/07/26
- [PATCH V9 13/46] qapi: strv_from_strList, Steve Sistare, 2022/07/26
- [PATCH V9 18/46] memory: flat section iterator, Steve Sistare, 2022/07/26
- [PATCH V9 04/46] migration: mode parameter, Steve Sistare, 2022/07/26
- [PATCH V9 21/46] cpr: preserve extra state, Steve Sistare, 2022/07/26
- [PATCH V9 19/46] oslib: qemu_clear_cloexec, Steve Sistare, 2022/07/26
- [PATCH V9 30/46] vfio-pci: refactor for cpr, Steve Sistare, 2022/07/26
- [PATCH V9 27/46] hostmem-memfd: cpr support, Steve Sistare, 2022/07/26
- [PATCH V9 25/46] cpr: only-cpr-capable, Steve Sistare, 2022/07/26
- [PATCH V9 20/46] vl: helper to request re-exec,
Steve Sistare <=
- [PATCH V9 05/46] migration: migrate-enable-mode option, Steve Sistare, 2022/07/26
- [PATCH V9 24/46] cpr: ram block blockers, Steve Sistare, 2022/07/26
- [PATCH V9 08/46] cpr: relax some blockers, Steve Sistare, 2022/07/26
- [PATCH V9 28/46] hostmem-epc: cpr support, Steve Sistare, 2022/07/26
- [PATCH V9 33/46] vfio-pci: cpr part 3 (intx), Steve Sistare, 2022/07/26
- [PATCH V9 06/46] migration: simplify blockers, Steve Sistare, 2022/07/26
- [PATCH V9 10/46] qdev-properties: strList, Steve Sistare, 2022/07/26
- [PATCH V9 29/46] pci: export msix_is_pending, Steve Sistare, 2022/07/26
- [PATCH V9 11/46] qapi: strList_from_string, Steve Sistare, 2022/07/26
- [PATCH V9 07/46] migration: per-mode blockers, Steve Sistare, 2022/07/26