naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
594167
From fa06a45fa2dc0b7d15dc1394e679a9043fa2fee4 Mon Sep 17 00:00:00 2001
594167
From: David Tardon <dtardon@redhat.com>
594167
Date: Sat, 16 Jul 2022 09:49:12 +0200
594167
Subject: [PATCH] core: allow to set default timeout for devices
594167
594167
Fixes: #19879
594167
(cherry picked from commit a0fe19f9f791c05af236265954b1d73e8fcf5468)
594167
594167
Resolves: #2116681
594167
---
594167
 src/core/dbus-manager.c | 1 +
594167
 src/core/device.c       | 2 +-
594167
 src/core/main.c         | 4 ++++
594167
 src/core/manager.c      | 1 +
594167
 src/core/manager.h      | 1 +
594167
 src/core/system.conf.in | 1 +
594167
 6 files changed, 9 insertions(+), 1 deletion(-)
594167
594167
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
594167
index 0ce2d73857..9d47d9c8a7 100644
594167
--- a/src/core/dbus-manager.c
594167
+++ b/src/core/dbus-manager.c
594167
@@ -2706,6 +2706,7 @@ const sd_bus_vtable bus_manager_vtable[] = {
594167
         SD_BUS_PROPERTY("DefaultTimeoutStartUSec", "t", bus_property_get_usec, offsetof(Manager, default_timeout_start_usec), SD_BUS_VTABLE_PROPERTY_CONST),
594167
         SD_BUS_PROPERTY("DefaultTimeoutStopUSec", "t", bus_property_get_usec, offsetof(Manager, default_timeout_stop_usec), SD_BUS_VTABLE_PROPERTY_CONST),
594167
         SD_BUS_PROPERTY("DefaultTimeoutAbortUSec", "t", property_get_default_timeout_abort_usec, 0, 0),
594167
+        SD_BUS_PROPERTY("DefaultDeviceTimeoutUSec", "t", bus_property_get_usec, offsetof(Manager, default_device_timeout_usec), SD_BUS_VTABLE_PROPERTY_CONST),
594167
         SD_BUS_PROPERTY("DefaultRestartUSec", "t", bus_property_get_usec, offsetof(Manager, default_restart_usec), SD_BUS_VTABLE_PROPERTY_CONST),
594167
         SD_BUS_PROPERTY("DefaultStartLimitIntervalUSec", "t", bus_property_get_usec, offsetof(Manager, default_start_limit_interval), SD_BUS_VTABLE_PROPERTY_CONST),
594167
         /* The following two items are obsolete alias */
594167
diff --git a/src/core/device.c b/src/core/device.c
594167
index d2c5febd3f..cb6021cbd8 100644
594167
--- a/src/core/device.c
594167
+++ b/src/core/device.c
594167
@@ -101,7 +101,7 @@ static void device_init(Unit *u) {
594167
          * indefinitely for plugged in devices, something which cannot
594167
          * happen for the other units since their operations time out
594167
          * anyway. */
594167
-        u->job_running_timeout = u->manager->default_timeout_start_usec;
594167
+        u->job_running_timeout = u->manager->default_device_timeout_usec;
594167
 
594167
         u->ignore_on_isolate = true;
594167
 
594167
diff --git a/src/core/main.c b/src/core/main.c
594167
index 03efaa03be..7dedc5163b 100644
594167
--- a/src/core/main.c
594167
+++ b/src/core/main.c
594167
@@ -132,6 +132,7 @@ static usec_t arg_default_restart_usec;
594167
 static usec_t arg_default_timeout_start_usec;
594167
 static usec_t arg_default_timeout_stop_usec;
594167
 static usec_t arg_default_timeout_abort_usec;
594167
+static usec_t arg_default_device_timeout_usec;
594167
 static bool arg_default_timeout_abort_set;
594167
 static usec_t arg_default_start_limit_interval;
594167
 static unsigned arg_default_start_limit_burst;
594167
@@ -725,6 +726,7 @@ static int parse_config_file(void) {
594167
                 { "Manager", "DefaultTimeoutStartSec",       config_parse_sec,                   0, &arg_default_timeout_start_usec        },
594167
                 { "Manager", "DefaultTimeoutStopSec",        config_parse_sec,                   0, &arg_default_timeout_stop_usec         },
594167
                 { "Manager", "DefaultTimeoutAbortSec",       config_parse_default_timeout_abort, 0, NULL                                   },
594167
+                { "Manager", "DefaultDeviceTimeoutSec",      config_parse_sec,                   0, &arg_default_device_timeout_usec       },
594167
                 { "Manager", "DefaultRestartSec",            config_parse_sec,                   0, &arg_default_restart_usec              },
594167
                 { "Manager", "DefaultStartLimitInterval",    config_parse_sec,                   0, &arg_default_start_limit_interval      }, /* obsolete alias */
594167
                 { "Manager", "DefaultStartLimitIntervalSec", config_parse_sec,                   0, &arg_default_start_limit_interval      },
594167
@@ -809,6 +811,7 @@ static void set_manager_defaults(Manager *m) {
594167
         m->default_timeout_stop_usec = arg_default_timeout_stop_usec;
594167
         m->default_timeout_abort_usec = arg_default_timeout_abort_usec;
594167
         m->default_timeout_abort_set = arg_default_timeout_abort_set;
594167
+        m->default_device_timeout_usec = arg_default_device_timeout_usec;
594167
         m->default_restart_usec = arg_default_restart_usec;
594167
         m->default_start_limit_interval = arg_default_start_limit_interval;
594167
         m->default_start_limit_burst = arg_default_start_limit_burst;
594167
@@ -2437,6 +2440,7 @@ static void reset_arguments(void) {
594167
         arg_default_timeout_stop_usec = DEFAULT_TIMEOUT_USEC;
594167
         arg_default_timeout_abort_usec = DEFAULT_TIMEOUT_USEC;
594167
         arg_default_timeout_abort_set = false;
594167
+        arg_default_device_timeout_usec = DEFAULT_TIMEOUT_USEC;
594167
         arg_default_start_limit_interval = DEFAULT_START_LIMIT_INTERVAL;
594167
         arg_default_start_limit_burst = DEFAULT_START_LIMIT_BURST;
594167
         arg_runtime_watchdog = 0;
594167
diff --git a/src/core/manager.c b/src/core/manager.c
594167
index 5b7f5f55aa..8057bafe61 100644
594167
--- a/src/core/manager.c
594167
+++ b/src/core/manager.c
594167
@@ -806,6 +806,7 @@ int manager_new(LookupScope scope, ManagerTestRunFlags test_run_flags, Manager *
594167
                 .default_timeout_start_usec = DEFAULT_TIMEOUT_USEC,
594167
                 .default_timeout_stop_usec = DEFAULT_TIMEOUT_USEC,
594167
                 .default_restart_usec = DEFAULT_RESTART_USEC,
594167
+                .default_device_timeout_usec = DEFAULT_TIMEOUT_USEC,
594167
 
594167
                 .original_log_level = -1,
594167
                 .original_log_target = _LOG_TARGET_INVALID,
594167
diff --git a/src/core/manager.h b/src/core/manager.h
594167
index 281d2a2138..e7a15e6b25 100644
594167
--- a/src/core/manager.h
594167
+++ b/src/core/manager.h
594167
@@ -354,6 +354,7 @@ struct Manager {
594167
         ExecOutput default_std_output, default_std_error;
594167
 
594167
         usec_t default_restart_usec, default_timeout_start_usec, default_timeout_stop_usec;
594167
+        usec_t default_device_timeout_usec;
594167
         usec_t default_timeout_abort_usec;
594167
         bool default_timeout_abort_set;
594167
 
594167
diff --git a/src/core/system.conf.in b/src/core/system.conf.in
594167
index 5913b5b0e4..7a150a482f 100644
594167
--- a/src/core/system.conf.in
594167
+++ b/src/core/system.conf.in
594167
@@ -44,6 +44,7 @@
594167
 #DefaultTimeoutStartSec=90s
594167
 #DefaultTimeoutStopSec=90s
594167
 #DefaultTimeoutAbortSec=
594167
+#DefaultDeviceTimeoutSec=90s
594167
 #DefaultRestartSec=100ms
594167
 #DefaultStartLimitIntervalSec=10s
594167
 #DefaultStartLimitBurst=5