]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
watchdog: rename special string "infinity" taken by the watchdog timeout options... 20787/head
authorFranck Bui <fbui@suse.com>
Fri, 1 Oct 2021 08:42:11 +0000 (10:42 +0200)
committerFranck Bui <fbui@suse.com>
Wed, 13 Oct 2021 06:58:36 +0000 (08:58 +0200)
man/systemd-system.conf.xml
src/core/load-fragment.c
src/core/load-fragment.h
src/core/main.c

index 4172ec00ab26f41dcbcacfe746adc8ca60127fde..dfd4e245a88297e1f537a486419c3b8f8fbc5f59 100644 (file)
         seconds (or in other time units if suffixed with <literal>ms</literal>, <literal>min</literal>,
         <literal>h</literal>, <literal>d</literal>, <literal>w</literal>). If set to zero the watchdog logic
         is disabled: no watchdog device is opened, configured, or pinged. If set to the special string
-        <literal>infinity</literal> the watchdog is opened and pinged in regular intervals, but the timeout
+        <literal>default</literal> 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).</para>
 
index f971084c28ee6c555168ccedc948c7568367df25..c5adef6c1f2a65d93783389e03954dc69f409e51 100644 (file)
@@ -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);
+}
index e84f9ee39107619121f7eff002d296fe3b62a761..06f703e21863ff5ab7c73e63604e1cc4d13f7395 100644 (file)
@@ -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);
index e2fc6fae61b5d2b31878031de53146b87a6ea74b..67710f752870b8da16a69a5faefe990a37ad7b97 100644 (file)
@@ -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                      },