Brett Neumeier schrob: > 2. patch QEMU to add a signal handler so that it will gracefully > shutdown when it receives a specific signal (and then tell s6 to use > that signal to take the service down); or A patch to do that has been available since 2017 at least, but the qemu developers apparently can't agree to any signal to use. See https://patchwork.kernel.org/project/qemu-devel/patch/23d89ab3bd16ebf7a864ab75c300de7b@whitewinterwolf.com/ and https://gitlab.com/qemu-project/qemu/-/issues/148 . Here's a current version with SIGPWR. HTH, Jan diff --git a/os-posix.c b/os-posix.c index 43f9a43f3..55fb3999a 100644 --- a/os-posix.c +++ b/os-posix.c @@ -64,6 +64,9 @@ void os_setup_signal_handling(void) sigaction(SIGINT, &act, NULL); sigaction(SIGHUP, &act, NULL); sigaction(SIGTERM, &act, NULL); +#ifdef SIGPWR + sigaction(SIGPWR, &act, NULL); +#endif } void os_set_proc_name(const char *s) diff --git a/system/runstate.c b/system/runstate.c index c833316f6..a75c10aa6 100644 --- a/system/runstate.c +++ b/system/runstate.c @@ -680,8 +680,18 @@ void qemu_system_killed(int signal, pid_t pid) /* Cannot call qemu_system_shutdown_request directly because * we are in a signal handler. */ - shutdown_requested = SHUTDOWN_CAUSE_HOST_SIGNAL; - qemu_notify_event(); +#ifdef SIGPWR + if (signal==SIGPWR) + { + powerdown_requested = 1; + qemu_notify_event(); + } + else +#endif + { + shutdown_requested = SHUTDOWN_CAUSE_HOST_SIGNAL; + qemu_notify_event(); + } } void qemu_system_shutdown_request_with_code(ShutdownCause reason,