From 698da597e1d80724841a8e2ec672c8df60563525 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 26 Nov 2023 05:34:10 +0900 Subject: [PATCH 1/4] varlinkctl: add short comment --- src/varlinkctl/varlinkctl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/varlinkctl/varlinkctl.c b/src/varlinkctl/varlinkctl.c index 36556642d3..64105c7ab2 100644 --- a/src/varlinkctl/varlinkctl.c +++ b/src/varlinkctl/varlinkctl.c @@ -376,6 +376,7 @@ static int verb_call(int argc, char *argv[], void *userdata) { arg_json_format_flags &= ~JSON_FORMAT_OFF; if (parameter) { + /* is correct, as dispatch_verb() shifts arguments by one for the verb. */ r = json_parse_with_source(parameter, "", 0, &jp, &line, &column); if (r < 0) return log_error_errno(r, "Failed to parse parameters at :%u:%u: %m", line, column); From 2601482b8517c228d834341039cc7768da20ea76 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 26 Nov 2023 05:43:46 +0900 Subject: [PATCH 2/4] man: also SIGKILL is sent on soft-reboot --- man/systemd-soft-reboot.service.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/man/systemd-soft-reboot.service.xml b/man/systemd-soft-reboot.service.xml index 8884c24774..14178c423b 100644 --- a/man/systemd-soft-reboot.service.xml +++ b/man/systemd-soft-reboot.service.xml @@ -30,8 +30,8 @@ systemd-soft-reboot.service is a system service that is pulled in by soft-reboot.target and is responsible for performing a userspace-only reboot operation. When invoked, it will send the SIGTERM signal to any processes left - running (but does not follow up with SIGKILL, and does not wait for the processes to - exit). If the /run/nextroot/ directory exists (which may be a regular directory, a + running (but does not wait for the processes to exit), and follow up with SIGKILL. + If the /run/nextroot/ directory exists (which may be a regular directory, a directory mount point or a symlink to either) then it will switch the file system root to it. It then reexecutes the service manager off the (possibly now new) root file system, which will enqueue a new boot transaction as in a normal reboot. From f89985ca494b79b2beed47e1f10d46ef2d59ce3e Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 28 Nov 2023 08:32:22 +0900 Subject: [PATCH 3/4] unit: make journald stopped on soft-reboot before broadcasting SIGKILL Workaround for #30195. --- units/systemd-journald.service.in | 5 +++++ units/systemd-journald@.service.in | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/units/systemd-journald.service.in b/units/systemd-journald.service.in index 1c36ec8903..37eeabc510 100644 --- a/units/systemd-journald.service.in +++ b/units/systemd-journald.service.in @@ -15,6 +15,11 @@ Requires=systemd-journald.socket After=systemd-journald.socket systemd-journald-dev-log.socket systemd-journald-audit.socket syslog.socket Before=sysinit.target +# To avoid journald SIGKILLed during soft-reboot and corrupting journals. +# See https://github.com/systemd/systemd/issues/30195 +Before=soft-reboot.target +Conflicts=soft-reboot.target + # Mount and swap units need the journal socket units. If they were removed by # an isolate request the mount and swap units would be removed too, hence let's # exclude systemd-journald and its sockets from isolate requests. diff --git a/units/systemd-journald@.service.in b/units/systemd-journald@.service.in index b705ce08ff..c3bcb08533 100644 --- a/units/systemd-journald@.service.in +++ b/units/systemd-journald@.service.in @@ -13,6 +13,11 @@ Documentation=man:systemd-journald.service(8) man:journald.conf(5) Requires=systemd-journald@%i.socket systemd-journald-varlink@%i.socket After=systemd-journald@%i.socket systemd-journald-varlink@%i.socket +# To avoid journald SIGKILLed during soft-reboot and corrupting journals. +# See https://github.com/systemd/systemd/issues/30195 +Before=soft-reboot.target +Conflicts=soft-reboot.target + [Service] CapabilityBoundingSet=CAP_SYS_ADMIN CAP_DAC_OVERRIDE CAP_SYS_PTRACE CAP_CHOWN CAP_DAC_READ_SEARCH CAP_FOWNER CAP_SETUID CAP_SETGID CAP_MAC_OVERRIDE DevicePolicy=closed From 5edb35ef7ac765a62653af3f7583e2523c6821a6 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sun, 26 Nov 2023 09:25:22 +0900 Subject: [PATCH 4/4] test: check journal files are not corrupted after soft-reboot --- test/units/testsuite-82.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/units/testsuite-82.sh b/test/units/testsuite-82.sh index e0f9573f54..b5e6dedfed 100755 --- a/test/units/testsuite-82.sh +++ b/test/units/testsuite-82.sh @@ -3,6 +3,9 @@ set -ex set -o pipefail +# shellcheck source=test/units/util.sh +. "$(dirname "$0")"/util.sh + at_exit() { # Since the soft-reboot drops the enqueued end.service, we won't shutdown # the test VM if the test fails and have to wait for the watchdog to kill @@ -39,6 +42,10 @@ if [ -f /run/testsuite82.touch3 ]; then test "$(systemctl show -P ActiveState testsuite-82-nosurvive-sigterm.service)" != "active" test "$(systemctl show -P ActiveState testsuite-82-nosurvive.service)" != "active" + # Check journals + journalctl -o short-monotonic --no-hostname --grep '(will soft-reboot|KILL|corrupt)' + assert_eq "$(journalctl -q -o short-monotonic -u systemd-journald.service --grep 'corrupt')" "" + # All succeeded, exit cleanly now elif [ -f /run/testsuite82.touch2 ]; then