Skip to content

Commit

Permalink
Merge pull request #32902 from yuwata/emergency-action-fixes
Browse files Browse the repository at this point in the history
several fixes for emergency actions and document update
  • Loading branch information
yuwata committed May 18, 2024
2 parents e579017 + 6da7485 commit 762412f
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 25 deletions.
33 changes: 18 additions & 15 deletions man/bootup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -312,21 +312,23 @@ emergency.service | | |
v
final.target
|
___________________________/ \_________________
/ | | \
| | | |
v | | |
systemd-reboot.service | | |
| v | |
| systemd-poweroff.service | |
v | v |
<emphasis>reboot.target</emphasis> | systemd-halt.service |
v | v
<emphasis>poweroff.target</emphasis> | systemd-kexec.service
v |
<emphasis>halt.target</emphasis> |
v
<emphasis>kexec.target</emphasis></programlisting>
___________________________/ \_________________________________
/ | | | \
| | | | |
v | | | |
systemd-reboot.service | | | |
| v | | |
| systemd-poweroff.service | | |
v | v | |
<emphasis>reboot.target</emphasis> | systemd-halt.service | |
v | v |
<emphasis>poweroff.target</emphasis> | systemd-kexec.service |
v | |
<emphasis>halt.target</emphasis> | <emphasis>soft-reboot.target</emphasis>
v |
<emphasis>kexec.target</emphasis> |
v
systemd-soft-reboot.service</programlisting>

<para>Commonly used system shutdown targets are <emphasis>emphasized</emphasis>.</para>

Expand All @@ -350,6 +352,7 @@ systemd-reboot.service | | |
<member><citerefentry><refentrytitle>systemd.special</refentrytitle><manvolnum>7</manvolnum></citerefentry></member>
<member><citerefentry><refentrytitle>systemd.target</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
<member><citerefentry><refentrytitle>systemd-halt.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
<member><citerefentry><refentrytitle>systemd-soft-reboot.service</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
</simplelist></para>
</refsect1>

Expand Down
8 changes: 4 additions & 4 deletions man/systemd.unit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1083,9 +1083,8 @@
<option>exit-force</option>, <option>soft-reboot</option>, <option>soft-reboot-force</option>,
<option>kexec</option>, <option>kexec-force</option>, <option>halt</option>,
<option>halt-force</option> and <option>halt-immediate</option>. In system mode, all options are
allowed. In user mode, only <option>none</option>, <option>exit</option>,
<option>exit-force</option>, <option>soft-reboot</option> and <option>soft-reboot-force</option> are
allowed. Both options default to <option>none</option>.</para>
allowed. In user mode, only <option>none</option>, <option>exit</option>, and
<option>exit-force</option> are allowed. Both options default to <option>none</option>.</para>

<para>If <option>none</option> is set, no action will be triggered. <option>reboot</option> causes a
reboot following the normal shutdown procedure (i.e. equivalent to <command>systemctl
Expand Down Expand Up @@ -1160,7 +1159,8 @@
<listitem><para><varname>JobTimeoutAction=</varname> optionally configures an additional action to
take when the timeout is hit, see description of <varname>JobTimeoutSec=</varname> and
<varname>JobRunningTimeoutSec=</varname> above. It takes the same values as
<varname>StartLimitAction=</varname>. Defaults to <option>none</option>.</para>
<varname>FailureAction=</varname>/<varname>SuccessAction=</varname>. Defaults to
<option>none</option>.</para>

<para><varname>JobTimeoutRebootArgument=</varname> configures an optional reboot string to pass to
the <citerefentry><refentrytitle>reboot</refentrytitle><manvolnum>2</manvolnum></citerefentry> system
Expand Down
6 changes: 3 additions & 3 deletions src/core/emergency-action.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

static const char* const emergency_action_table[_EMERGENCY_ACTION_MAX] = {
[EMERGENCY_ACTION_NONE] = "none",
[EMERGENCY_ACTION_EXIT] = "exit",
[EMERGENCY_ACTION_EXIT_FORCE] = "exit-force",
[EMERGENCY_ACTION_REBOOT] = "reboot",
[EMERGENCY_ACTION_REBOOT_FORCE] = "reboot-force",
[EMERGENCY_ACTION_REBOOT_IMMEDIATE] = "reboot-immediate",
[EMERGENCY_ACTION_POWEROFF] = "poweroff",
[EMERGENCY_ACTION_POWEROFF_FORCE] = "poweroff-force",
[EMERGENCY_ACTION_POWEROFF_IMMEDIATE] = "poweroff-immediate",
[EMERGENCY_ACTION_EXIT] = "exit",
[EMERGENCY_ACTION_EXIT_FORCE] = "exit-force",
[EMERGENCY_ACTION_SOFT_REBOOT] = "soft-reboot",
[EMERGENCY_ACTION_SOFT_REBOOT_FORCE] = "soft-reboot-force",
[EMERGENCY_ACTION_KEXEC] = "kexec",
Expand Down Expand Up @@ -216,7 +216,7 @@ int parse_emergency_action(
if (x < 0)
return -EINVAL;

if (runtime_scope != RUNTIME_SCOPE_SYSTEM && x != EMERGENCY_ACTION_NONE && x < _EMERGENCY_ACTION_FIRST_USER_ACTION)
if (runtime_scope != RUNTIME_SCOPE_SYSTEM && x > _EMERGENCY_ACTION_LAST_USER_ACTION)
return -EOPNOTSUPP;

*ret = x;
Expand Down
6 changes: 3 additions & 3 deletions src/core/emergency-action.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

typedef enum EmergencyAction {
EMERGENCY_ACTION_NONE,
EMERGENCY_ACTION_EXIT,
EMERGENCY_ACTION_EXIT_FORCE,
_EMERGENCY_ACTION_LAST_USER_ACTION = EMERGENCY_ACTION_EXIT_FORCE,
EMERGENCY_ACTION_REBOOT,
EMERGENCY_ACTION_REBOOT_FORCE,
EMERGENCY_ACTION_REBOOT_IMMEDIATE,
EMERGENCY_ACTION_POWEROFF,
EMERGENCY_ACTION_POWEROFF_FORCE,
EMERGENCY_ACTION_POWEROFF_IMMEDIATE,
EMERGENCY_ACTION_EXIT,
_EMERGENCY_ACTION_FIRST_USER_ACTION = EMERGENCY_ACTION_EXIT,
EMERGENCY_ACTION_EXIT_FORCE,
EMERGENCY_ACTION_SOFT_REBOOT,
EMERGENCY_ACTION_SOFT_REBOOT_FORCE,
EMERGENCY_ACTION_KEXEC,
Expand Down
2 changes: 2 additions & 0 deletions units/exit.target
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ DefaultDependencies=no
Requires=systemd-exit.service
After=systemd-exit.service
AllowIsolate=yes
JobTimeoutSec=30min
JobTimeoutAction=exit-force

[Install]
Alias=ctrl-alt-del.target
2 changes: 2 additions & 0 deletions units/halt.target
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ DefaultDependencies=no
Requires=systemd-halt.service
After=systemd-halt.service
AllowIsolate=yes
JobTimeoutSec=30min
JobTimeoutAction=halt-force

[Install]
Alias=ctrl-alt-del.target
2 changes: 2 additions & 0 deletions units/kexec.target
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ DefaultDependencies=no
Requires=systemd-kexec.service
After=systemd-kexec.service
AllowIsolate=yes
JobTimeoutSec=30min
JobTimeoutAction=kexec-force

[Install]
Alias=ctrl-alt-del.target

0 comments on commit 762412f

Please sign in to comment.