From c91c95e66c50b590fbc0d4b7b464c56978100596 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 13 Oct 2021 13:06:03 +0200 Subject: [PATCH 1/3] core: allow "off" as special watchdog time to be specified Right now we already understand "default" as special string for enabling the watchdog but not reconfiguring its timeout (it is internally mapped to USEC_MAX). To be systematic this adds "off" as special string for disabling the watchdog logic (it is internally mapped to 0, which is how this behaviour was previously requested). --- src/core/load-fragment.c | 14 ++++++++------ src/core/main.c | 2 ++ src/core/system.conf.in | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 7c844a29df..18d9bb377c 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -6347,6 +6347,8 @@ int config_parse_watchdog_sec( void *data, void *userdata) { + usec_t *usec = data; + assert(filename); assert(lvalue); assert(rvalue); @@ -6354,12 +6356,12 @@ int config_parse_watchdog_sec( /* This is called for {Runtime,Reboot,KExec}WatchdogSec= where "default" maps to * USEC_INFINITY internally. */ - if (streq(rvalue, "default")) { - usec_t *usec = data; - + if (streq(rvalue, "default")) *usec = USEC_INFINITY; - return 0; - } + else if (streq(rvalue, "off")) + *usec = 0; + else + return config_parse_sec(unit, filename, line, section, section_line, lvalue, ltype, rvalue, data, userdata); - return config_parse_sec(unit, filename, line, section, section_line, lvalue, ltype, rvalue, data, userdata); + return 0; } diff --git a/src/core/main.c b/src/core/main.c index 4b8e923a1e..6e01398523 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -544,6 +544,8 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat if (streq(value, "default")) arg_runtime_watchdog = USEC_INFINITY; + else if (streq(value, "off")) + arg_runtime_watchdog = 0; else { r = parse_sec(value, &arg_runtime_watchdog); if (r < 0) { diff --git a/src/core/system.conf.in b/src/core/system.conf.in index e88280bd0a..96fb64d2c1 100644 --- a/src/core/system.conf.in +++ b/src/core/system.conf.in @@ -29,9 +29,9 @@ #CPUAffinity= #NUMAPolicy=default #NUMAMask= -#RuntimeWatchdogSec=0 +#RuntimeWatchdogSec=off #RebootWatchdogSec=10min -#KExecWatchdogSec=0 +#KExecWatchdogSec=off #WatchdogDevice= #CapabilityBoundingSet= #NoNewPrivileges=no From 5254d15896458b390037d7390699ddf4e7b9c8b4 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 13 Oct 2021 13:07:27 +0200 Subject: [PATCH 2/3] man: document new "off" setting for systemd-system.conf watchdog settings --- man/systemd-system.conf.xml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml index 7288c3b712..2307a8f5c9 100644 --- a/man/systemd-system.conf.xml +++ b/man/systemd-system.conf.xml @@ -135,11 +135,13 @@ Configure the hardware watchdog at runtime and at reboot. Takes a timeout value in seconds (or in other time units if suffixed with ms, min, - h, d, w). If set to zero the watchdog logic - is disabled: no watchdog device is opened, configured, or pinged. If set to the special string - default the watchdog is opened and pinged in regular intervals, but the timeout - is not changed from the default. If set to any other time value the watchdog timeout is configured to - the specified value (or a value close to it, depending on hardware capabilities). + h, d, w), or the special strings + off or default. If set to off + (alternatively: 0) the watchdog logic is disabled: no watchdog device is opened, + configured, or pinged. If set to the special string default the watchdog is opened + and pinged in regular intervals, but the timeout is not changed from the default. If set to any other + time value the watchdog timeout is configured to the specified value (or a value close to it, + depending on hardware capabilities). If RuntimeWatchdogSec= is set to a non-zero value, the watchdog hardware (/dev/watchdog or the path specified with WatchdogDevice= or From 9c5ea4b1432864e8ca40e4c9df61576fd9e18fe3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 13 Oct 2021 13:07:50 +0200 Subject: [PATCH 3/3] man: document new systemd.watchdog_sec= kernel cmdline option Follow-up for: b3aa73e4de614c06c4a27e5635967a0392654fbc --- man/kernel-command-line.xml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/man/kernel-command-line.xml b/man/kernel-command-line.xml index f546a1161a..2093edd05c 100644 --- a/man/kernel-command-line.xml +++ b/man/kernel-command-line.xml @@ -386,8 +386,9 @@ systemd.default_timeout_start_sec= - Overwrites the default start job timeout DefaultTimeoutStartSec= at boot. For details, - see systemd-system.conf5. + Overrrides the default start job timeout DefaultTimeoutStartSec= at + boot. For details, see + systemd-system.conf5. @@ -395,7 +396,20 @@ systemd.watchdog_device= - Overwrites the watchdog device path WatchdogDevice=. For details, see + Overrrides the watchdog device path WatchdogDevice=. For details, see + systemd-system.conf5. + + + + + systemd.watchdog_sec= + + + Overrrides the watchdog timeout settings otherwise configured with + RuntimeWatchdog=, RebootWatchdog= and + KExecWatchdogSec=. Takes a time value (if no unit is specified, seconds is the + implicitly assumed time unit) or the special strings off or + default. For details, see systemd-system.conf5.