Skip to content

Commit 291c669

Browse files
authored
Merge pull request #28498 from bluca/softreboot
softreboot: ensure all processes are killed
2 parents 2bfe726 + 7f0bf48 commit 291c669

20 files changed

+56
-182
lines changed

NEWS

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,7 @@ CHANGES WITH 254 in spe:
187187
system reset involves. Moreover, open file descriptors may be passed
188188
across the soft reboot into the new system where they will be passed
189189
back to the originating services. This allows pinning resources
190-
across the reboot, thus minimizing grey-out time further. Moreover,
191-
it is possible to allow specific crucial services to survive the
192-
reboot process, if they run off a separate root file system (i.e. use
193-
RootDirectory= or RootImage=, or are portable services). This new
190+
across the reboot, thus minimizing grey-out time further. This new
194191
reboot mechanism is accessible via the new "systemctl soft-reboot"
195192
command.
196193

man/org.freedesktop.systemd1.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,8 +1977,6 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
19771977
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
19781978
readonly b DefaultDependencies = ...;
19791979
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
1980-
readonly b IgnoreOnSoftReboot = ...;
1981-
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
19821980
readonly s OnSuccessJobMode = '...';
19831981
@org.freedesktop.DBus.Property.EmitsChangedSignal("const")
19841982
readonly s OnFailureJobMode = '...';
@@ -2093,8 +2091,6 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
20932091

20942092
<!--property CanFreeze is not documented!-->
20952093

2096-
<!--property IgnoreOnSoftReboot is not documented!-->
2097-
20982094
<!--property OnSuccessJobMode is not documented!-->
20992095

21002096
<!--property OnFailureJobMode is not documented!-->
@@ -2307,8 +2303,6 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
23072303

23082304
<variablelist class="dbus-property" generated="True" extra-ref="DefaultDependencies"/>
23092305

2310-
<variablelist class="dbus-property" generated="True" extra-ref="IgnoreOnSoftReboot"/>
2311-
23122306
<variablelist class="dbus-property" generated="True" extra-ref="OnSuccessJobMode"/>
23132307

23142308
<variablelist class="dbus-property" generated="True" extra-ref="OnFailureJobMode"/>

man/systemd-soft-reboot.service.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,6 @@
122122
url="https://systemd.io/PORTABLE_SERVICES">Portable Services</ulink>, but make sure no resource from
123123
the host's root filesystem is pinned via <varname>BindPaths=</varname> or similar unit settings,
124124
otherwise the old root filesystem will be kept in memory as long as the unit is running.</para>
125-
126-
<para>If units shall be left running until the very end of shutdown during a soft reboot operation, but
127-
shall be terminated regularly during other forms of shutdown, <varname>IgnoreOnSoftReboot=yes</varname>
128-
can be set. This will ensure that soft reboot operations do not affect it, but other types of reboot
129-
or shutdown stop it as expected.</para>
130125
</refsect1>
131126

132127
<refsect1>

man/systemd.unit.xml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -979,16 +979,6 @@
979979
ones.</para></listitem>
980980
</varlistentry>
981981

982-
<varlistentry>
983-
<term><varname>IgnoreOnSoftReboot=</varname></term>
984-
985-
<listitem><para>Takes a boolean argument. Defaults to <option>no</option>. If <option>yes</option>,
986-
the unit will be configured to survive a soft reboot operation (see:
987-
<citerefentry><refentrytitle>systemd-soft-reboot.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>).
988-
This will ensure the unit is stopped normally during reboot or shutdown operations, but it survives
989-
a soft reboot by not being stopped on the way down or on the way back up.</para></listitem>
990-
</varlistentry>
991-
992982
<varlistentry>
993983
<term><varname>CollectMode=</varname></term>
994984

src/core/dbus-unit.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,6 @@ const sd_bus_vtable bus_unit_vtable[] = {
921921
SD_BUS_PROPERTY("RefuseManualStop", "b", bus_property_get_bool, offsetof(Unit, refuse_manual_stop), SD_BUS_VTABLE_PROPERTY_CONST),
922922
SD_BUS_PROPERTY("AllowIsolate", "b", bus_property_get_bool, offsetof(Unit, allow_isolate), SD_BUS_VTABLE_PROPERTY_CONST),
923923
SD_BUS_PROPERTY("DefaultDependencies", "b", bus_property_get_bool, offsetof(Unit, default_dependencies), SD_BUS_VTABLE_PROPERTY_CONST),
924-
SD_BUS_PROPERTY("IgnoreOnSoftReboot", "b", bus_property_get_bool, offsetof(Unit, ignore_on_soft_reboot), SD_BUS_VTABLE_PROPERTY_CONST),
925924
SD_BUS_PROPERTY("OnSuccesJobMode", "s", property_get_job_mode, offsetof(Unit, on_success_job_mode), SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN), /* deprecated */
926925
SD_BUS_PROPERTY("OnSuccessJobMode", "s", property_get_job_mode, offsetof(Unit, on_success_job_mode), SD_BUS_VTABLE_PROPERTY_CONST),
927926
SD_BUS_PROPERTY("OnFailureJobMode", "s", property_get_job_mode, offsetof(Unit, on_failure_job_mode), SD_BUS_VTABLE_PROPERTY_CONST),
@@ -2176,9 +2175,6 @@ static int bus_unit_set_transient_property(
21762175
if (streq(name, "DefaultDependencies"))
21772176
return bus_set_transient_bool(u, name, &u->default_dependencies, message, flags, error);
21782177

2179-
if (streq(name, "IgnoreOnSoftReboot"))
2180-
return bus_set_transient_bool(u, name, &u->ignore_on_soft_reboot, message, flags, error);
2181-
21822178
if (streq(name, "OnSuccessJobMode"))
21832179
return bus_set_transient_job_mode(u, name, &u->on_success_job_mode, message, flags, error);
21842180

src/core/load-fragment-gperf.gperf.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ Unit.RefuseManualStart, config_parse_bool,
312312
Unit.RefuseManualStop, config_parse_bool, 0, offsetof(Unit, refuse_manual_stop)
313313
Unit.AllowIsolate, config_parse_bool, 0, offsetof(Unit, allow_isolate)
314314
Unit.DefaultDependencies, config_parse_bool, 0, offsetof(Unit, default_dependencies)
315-
Unit.IgnoreOnSoftReboot, config_parse_bool, 0, offsetof(Unit, ignore_on_soft_reboot)
316315
Unit.OnSuccessJobMode, config_parse_job_mode, 0, offsetof(Unit, on_success_job_mode)
317316
Unit.OnFailureJobMode, config_parse_job_mode, 0, offsetof(Unit, on_failure_job_mode)
318317
{# The following is a legacy alias name for compatibility #}

src/core/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,6 +1871,9 @@ static int do_reexecute(
18711871
* SIGCHLD for them after deserializing. */
18721872
if (IN_SET(objective, MANAGER_SWITCH_ROOT, MANAGER_SOFT_REBOOT))
18731873
broadcast_signal(SIGTERM, /* wait_for_exit= */ false, /* send_sighup= */ true, arg_default_timeout_stop_usec);
1874+
/* On soft reboot really make sure nothing is left */
1875+
if (objective == MANAGER_SOFT_REBOOT)
1876+
broadcast_signal(SIGKILL, /* wait_for_exit= */ false, /* send_sighup= */ false, arg_default_timeout_stop_usec);
18741877

18751878
if (!switch_root_dir && objective == MANAGER_SOFT_REBOOT) {
18761879
/* If no switch root dir is specified, then check if /run/nextroot/ qualifies and use that */

src/core/path.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -342,24 +342,12 @@ static int path_add_default_dependencies(Path *p) {
342342
return r;
343343

344344
if (MANAGER_IS_SYSTEM(UNIT(p)->manager)) {
345-
r = unit_add_two_dependencies_by_name(UNIT(p),
346-
UNIT_AFTER,
347-
UNIT(p)->ignore_on_soft_reboot ? -EINVAL : UNIT_REQUIRES,
348-
SPECIAL_SYSINIT_TARGET,
349-
true,
350-
UNIT_DEPENDENCY_DEFAULT);
345+
r = unit_add_two_dependencies_by_name(UNIT(p), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, true, UNIT_DEPENDENCY_DEFAULT);
351346
if (r < 0)
352347
return r;
353348
}
354349

355-
if (!UNIT(p)->ignore_on_soft_reboot)
356-
return unit_add_two_dependencies_by_name(
357-
UNIT(p),
358-
UNIT_BEFORE, UNIT_CONFLICTS,
359-
SPECIAL_SHUTDOWN_TARGET, true,
360-
UNIT_DEPENDENCY_DEFAULT);
361-
362-
return unit_add_dependencies_on_real_shutdown_targets(UNIT(p));
350+
return unit_add_two_dependencies_by_name(UNIT(p), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, true, UNIT_DEPENDENCY_DEFAULT);
363351
}
364352

365353
static int path_add_trigger_dependencies(Path *p) {

src/core/scope.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,22 +131,23 @@ static void scope_set_state(Scope *s, ScopeState state) {
131131
}
132132

133133
static int scope_add_default_dependencies(Scope *s) {
134+
int r;
135+
134136
assert(s);
135137

136138
if (!UNIT(s)->default_dependencies)
137139
return 0;
138140

139141
/* Make sure scopes are unloaded on shutdown */
140-
if (!UNIT(s)->ignore_on_soft_reboot)
141-
return unit_add_two_dependencies_by_name(
142-
UNIT(s),
143-
UNIT_BEFORE, UNIT_CONFLICTS,
144-
SPECIAL_SHUTDOWN_TARGET, true,
145-
UNIT_DEPENDENCY_DEFAULT);
142+
r = unit_add_two_dependencies_by_name(
143+
UNIT(s),
144+
UNIT_BEFORE, UNIT_CONFLICTS,
145+
SPECIAL_SHUTDOWN_TARGET, true,
146+
UNIT_DEPENDENCY_DEFAULT);
147+
if (r < 0)
148+
return r;
146149

147-
/* Unless we are meant to survive soft reboot, in which case we need to conflict with
148-
* non-soft-reboot targets. */
149-
return unit_add_dependencies_on_real_shutdown_targets(UNIT(s));
150+
return 0;
150151
}
151152

152153
static int scope_verify(Scope *s) {

src/core/service.c

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -722,16 +722,11 @@ static int service_add_default_dependencies(Service *s) {
722722
* majority of services. */
723723

724724
if (MANAGER_IS_SYSTEM(UNIT(s)->manager)) {
725-
/* First, pull in the really early boot stuff, and require it, so that we fail if we can't
726-
* acquire it. But only add ordering if this is meant to survive a soft reboot, otherwise
727-
* it will be pulled down. */
728-
729-
r = unit_add_two_dependencies_by_name(UNIT(s),
730-
UNIT_AFTER,
731-
UNIT(s)->ignore_on_soft_reboot ? -EINVAL : UNIT_REQUIRES,
732-
SPECIAL_SYSINIT_TARGET,
733-
true,
734-
UNIT_DEPENDENCY_DEFAULT);
725+
/* First, pull in the really early boot stuff, and
726+
* require it, so that we fail if we can't acquire
727+
* it. */
728+
729+
r = unit_add_two_dependencies_by_name(UNIT(s), UNIT_AFTER, UNIT_REQUIRES, SPECIAL_SYSINIT_TARGET, true, UNIT_DEPENDENCY_DEFAULT);
735730
if (r < 0)
736731
return r;
737732
} else {
@@ -752,17 +747,7 @@ static int service_add_default_dependencies(Service *s) {
752747
return r;
753748

754749
/* Third, add us in for normal shutdown. */
755-
if (!UNIT(s)->ignore_on_soft_reboot)
756-
return unit_add_two_dependencies_by_name(UNIT(s),
757-
UNIT_BEFORE,
758-
UNIT_CONFLICTS,
759-
SPECIAL_SHUTDOWN_TARGET,
760-
true,
761-
UNIT_DEPENDENCY_DEFAULT);
762-
763-
/* Unless we are meant to survive soft reboot, in which case we need to conflict with
764-
* non-soft-reboot targets. */
765-
return unit_add_dependencies_on_real_shutdown_targets(UNIT(s));
750+
return unit_add_two_dependencies_by_name(UNIT(s), UNIT_BEFORE, UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, true, UNIT_DEPENDENCY_DEFAULT);
766751
}
767752

768753
static void service_fix_stdio(Service *s) {

0 commit comments

Comments
 (0)