Merge pull request #32902 from yuwata/emergency-action-fixes

several fixes for emergency actions and document update
This commit is contained in:
Yu Watanabe 2024-05-18 16:32:36 +09:00 committed by GitHub
commit 762412f2bb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 34 additions and 25 deletions

View file

@ -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>
@ -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>

View file

@ -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
@ -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

View file

@ -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",
@ -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;

View file

@ -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,

View file

@ -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

View file

@ -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

View file

@ -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