From: Franck Bui Date: Fri, 1 Oct 2021 08:42:11 +0000 (+0200) Subject: watchdog: rename special string "infinity" taken by the watchdog timeout options... X-Git-Tag: v250-rc1~510^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8a85c5b6160b76125413e021b0e6b3eab4afa49c;p=thirdparty%2Fsystemd.git watchdog: rename special string "infinity" taken by the watchdog timeout options to "default" --- diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml index 4172ec00ab2..dfd4e245a88 100644 --- a/man/systemd-system.conf.xml +++ b/man/systemd-system.conf.xml @@ -137,7 +137,7 @@ 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 - infinity the watchdog is opened and pinged in regular intervals, but the timeout + 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). diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index f971084c28e..c5adef6c1f2 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -6262,3 +6262,32 @@ int config_parse_swap_priority( s->parameters_fragment.priority_set = true; return 0; } + +int config_parse_watchdog_sec( + const char *unit, + const char *filename, + unsigned line, + const char *section, + unsigned section_line, + const char *lvalue, + int ltype, + const char *rvalue, + void *data, + void *userdata) { + + assert(filename); + assert(lvalue); + assert(rvalue); + + /* This is called for {Runtime,Reboot,KExec}WatchdogSec= where "default" maps to + * USEC_INFINITY internally. */ + + if (streq(rvalue, "default")) { + usec_t *usec = data; + + *usec = USEC_INFINITY; + return 0; + } + + return config_parse_sec(unit, filename, line, section, section_line, lvalue, ltype, rvalue, data, userdata); +} diff --git a/src/core/load-fragment.h b/src/core/load-fragment.h index e84f9ee3910..06f703e2186 100644 --- a/src/core/load-fragment.h +++ b/src/core/load-fragment.h @@ -142,6 +142,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_extension_images); CONFIG_PARSER_PROTOTYPE(config_parse_bpf_foreign_program); CONFIG_PARSER_PROTOTYPE(config_parse_cgroup_socket_bind); CONFIG_PARSER_PROTOTYPE(config_parse_restrict_network_interfaces); +CONFIG_PARSER_PROTOTYPE(config_parse_watchdog_sec); /* gperf prototypes */ const struct ConfigPerfItem* load_fragment_gperf_lookup(const char *key, GPERF_LEN_TYPE length); diff --git a/src/core/main.c b/src/core/main.c index e2fc6fae61b..67710f75287 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -536,11 +536,17 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat if (proc_cmdline_value_missing(key, value)) return 0; - r = parse_sec(value, &arg_runtime_watchdog); - if (r < 0) - log_warning_errno(r, "Failed to parse systemd.watchdog_sec= argument '%s', ignoring: %m", value); - else - arg_kexec_watchdog = arg_reboot_watchdog = arg_runtime_watchdog; + if (streq(value, "default")) + arg_runtime_watchdog = USEC_INFINITY; + else { + r = parse_sec(value, &arg_runtime_watchdog); + if (r < 0) { + log_warning_errno(r, "Failed to parse systemd.watchdog_sec= argument '%s', ignoring: %m", value); + return 0; + } + } + + arg_kexec_watchdog = arg_reboot_watchdog = arg_runtime_watchdog; } else if (proc_cmdline_key_streq(key, "systemd.clock_usec")) { @@ -662,10 +668,10 @@ static int parse_config_file(void) { { "Manager", "NUMAPolicy", config_parse_numa_policy, 0, &arg_numa_policy.type }, { "Manager", "NUMAMask", config_parse_numa_mask, 0, &arg_numa_policy }, { "Manager", "JoinControllers", config_parse_warn_compat, DISABLED_CONFIGURATION, NULL }, - { "Manager", "RuntimeWatchdogSec", config_parse_sec, 0, &arg_runtime_watchdog }, - { "Manager", "RebootWatchdogSec", config_parse_sec, 0, &arg_reboot_watchdog }, - { "Manager", "ShutdownWatchdogSec", config_parse_sec, 0, &arg_reboot_watchdog }, /* obsolete alias */ - { "Manager", "KExecWatchdogSec", config_parse_sec, 0, &arg_kexec_watchdog }, + { "Manager", "RuntimeWatchdogSec", config_parse_watchdog_sec, 0, &arg_runtime_watchdog }, + { "Manager", "RebootWatchdogSec", config_parse_watchdog_sec, 0, &arg_reboot_watchdog }, + { "Manager", "ShutdownWatchdogSec", config_parse_watchdog_sec, 0, &arg_reboot_watchdog }, /* obsolete alias */ + { "Manager", "KExecWatchdogSec", config_parse_watchdog_sec, 0, &arg_kexec_watchdog }, { "Manager", "WatchdogDevice", config_parse_path, 0, &arg_watchdog_device }, { "Manager", "CapabilityBoundingSet", config_parse_capability_set, 0, &arg_capability_bounding_set }, { "Manager", "NoNewPrivileges", config_parse_bool, 0, &arg_no_new_privs },