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