summaryrefslogtreecommitdiffstats
path: root/src/shutdown
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2024-04-25 19:35:07 +0200
committerDaan De Meyer <daan.j.demeyer@gmail.com>2024-04-25 21:29:34 +0200
commit74e07b33b05f6a7a7124f6e3a27fcd228837264e (patch)
treef0e5fa8a5e7b744cf52d11e401e246d734830c19 /src/shutdown
parentMerge pull request #32484 from DaanDeMeyer/mkosi-ci (diff)
downloadsystemd-74e07b33b05f6a7a7124f6e3a27fcd228837264e.tar.xz
systemd-74e07b33b05f6a7a7124f6e3a27fcd228837264e.zip
sd-daemon: Set SO_LINGER on AF_VSOCK notify socket fds
We're still seeing problems in mkosi CI where we lose notify messages sent over vsock from virtual machines because the virtual machine shuts down before the socket buffers are flushed. Let's try setting SO_LINGER on vsock sockets so that the kernel waits until the buffers are flushed when we close the file descriptor. To make sure it works, let's get rid of our previous workaround that sends EXIT_STATUS earlier to reduce the chance of it not arriving. This way, if it doesn't work, we'll notice it immediately due to CI failures.
Diffstat (limited to 'src/shutdown')
-rw-r--r--src/shutdown/shutdown.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/shutdown/shutdown.c b/src/shutdown/shutdown.c
index 1ddda00941..67f44e16e9 100644
--- a/src/shutdown/shutdown.c
+++ b/src/shutdown/shutdown.c
@@ -344,13 +344,15 @@ static void notify_supervisor(void) {
if (reboot_parameter)
(void) sd_notifyf(/* unset_environment= */ false,
+ "EXIT_STATUS=%i\n"
"X_SYSTEMD_SHUTDOWN=%s\n"
"X_SYSTEMD_REBOOT_PARAMETER=%s",
- arg_verb, reboot_parameter);
+ arg_exit_code, arg_verb, reboot_parameter);
else
(void) sd_notifyf(/* unset_environment= */ false,
+ "EXIT_STATUS=%i\n"
"X_SYSTEMD_SHUTDOWN=%s",
- arg_verb);
+ arg_exit_code, arg_verb);
}
int main(int argc, char *argv[]) {
@@ -407,13 +409,6 @@ int main(int argc, char *argv[]) {
goto error;
}
- /* This is primarily useful when running systemd in a VM, as it provides the user running the VM with
- * a mechanism to pick up systemd's exit status in the VM. Note that we execute this as early as
- * possible since otherwise we might shut down the VM before the AF_VSOCK buffers have been flushed.
- * While this doesn't guarantee the message will arrive, in practice we do enough work after this
- * that the message should always arrive on the host */
- (void) sd_notifyf(0, "EXIT_STATUS=%i", arg_exit_code);
-
(void) cg_get_root_path(&cgroup);
bool in_container = detect_container() > 0;