diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:45 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 03:50:45 +0000 |
commit | efeb864cb547a2cbf96dc0053a8bdb4d9190b364 (patch) | |
tree | c0b83368f18be983fcc763200c4c24d633244588 /src/shutdown | |
parent | Releasing progress-linux version 255.5-1~progress7.99u1. (diff) | |
download | systemd-efeb864cb547a2cbf96dc0053a8bdb4d9190b364.tar.xz systemd-efeb864cb547a2cbf96dc0053a8bdb4d9190b364.zip |
Merging upstream version 256.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/shutdown')
-rw-r--r-- | src/shutdown/detach-dm.c | 2 | ||||
-rw-r--r-- | src/shutdown/detach-md.c | 2 | ||||
-rw-r--r-- | src/shutdown/shutdown.c | 36 | ||||
-rw-r--r-- | src/shutdown/umount.c | 2 |
4 files changed, 31 insertions, 11 deletions
diff --git a/src/shutdown/detach-dm.c b/src/shutdown/detach-dm.c index 8b8f72d..f6f672c 100644 --- a/src/shutdown/detach-dm.c +++ b/src/shutdown/detach-dm.c @@ -132,7 +132,7 @@ static int dm_points_list_detach(DeviceMapper **head, bool *changed, bool last_t if ((major(rootdev) != 0 && rootdev == m->devnum) || (major(usrdev) != 0 && usrdev == m->devnum)) { log_debug("Not detaching DM %s that backs the OS itself, skipping.", m->path); - n_failed ++; + n_failed++; continue; } diff --git a/src/shutdown/detach-md.c b/src/shutdown/detach-md.c index cf3130d..ac46670 100644 --- a/src/shutdown/detach-md.c +++ b/src/shutdown/detach-md.c @@ -153,7 +153,7 @@ static int md_points_list_detach(RaidDevice **head, bool *changed, bool last_try if ((major(rootdev) != 0 && rootdev == m->devnum) || (major(usrdev) != 0 && usrdev == m->devnum)) { log_debug("Not detaching MD %s that backs the OS itself, skipping.", m->path); - n_failed ++; + n_failed++; continue; } diff --git a/src/shutdown/shutdown.c b/src/shutdown/shutdown.c index b709078..d998bc5 100644 --- a/src/shutdown/shutdown.c +++ b/src/shutdown/shutdown.c @@ -333,6 +333,28 @@ static void init_watchdog(void) { } } +static void notify_supervisor(void) { + /* Notify VMM/container manager of the desired mode of reboot and the boot parameter */ + _cleanup_free_ char *reboot_parameter = NULL; + int r; + + r = read_reboot_parameter(&reboot_parameter); + if (r < 0 && r != -ENOENT) + log_debug_errno(r, "Failed to read reboot parameter, ignoring: %m"); + + if (reboot_parameter) + (void) sd_notifyf(/* unset_environment= */ false, + "EXIT_STATUS=%i\n" + "X_SYSTEMD_SHUTDOWN=%s\n" + "X_SYSTEMD_REBOOT_PARAMETER=%s", + arg_exit_code, arg_verb, reboot_parameter); + else + (void) sd_notifyf(/* unset_environment= */ false, + "EXIT_STATUS=%i\n" + "X_SYSTEMD_SHUTDOWN=%s", + arg_exit_code, arg_verb); +} + int main(int argc, char *argv[]) { static const char* const dirs[] = { SYSTEM_SHUTDOWN_PATH, @@ -387,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; @@ -546,7 +561,10 @@ int main(int argc, char *argv[]) { } /* We're done with the watchdog. Note that the watchdog is explicitly not stopped here. It remains - * active to guard against any issues during the rest of the shutdown sequence. */ + * active to guard against any issues during the rest of the shutdown sequence. Note that we + * explicitly close the device with disarm=false here, before releasing the rest of the watchdog + * data. */ + watchdog_close(/* disarm= */ false); watchdog_free_device(); arguments[0] = NULL; /* Filled in by execute_directories(), when needed */ @@ -589,6 +607,8 @@ int main(int argc, char *argv[]) { if (!in_container) sync_with_progress(); + notify_supervisor(); + if (streq(arg_verb, "exit")) { if (in_container) { log_info("Exiting container."); diff --git a/src/shutdown/umount.c b/src/shutdown/umount.c index 1a9b99d..ca6d36e 100644 --- a/src/shutdown/umount.c +++ b/src/shutdown/umount.c @@ -95,7 +95,7 @@ int mount_points_list_get(const char *mountinfo, MountPoint **head) { * we might lack the rights to unmount these things, hence don't bother. */ if (mount_point_is_api(path) || mount_point_ignore(path) || - PATH_STARTSWITH_SET(path, "/dev", "/sys", "/proc")) + path_below_api_vfs(path)) continue; is_api_vfs = fstype_is_api_vfs(fstype); |