a19bc6
From 2b787d523662b91334da24f1c77a7d803e53fab9 Mon Sep 17 00:00:00 2001
a19bc6
From: Lukas Nykryn <lnykryn@redhat.com>
a19bc6
Date: Tue, 3 Jan 2017 16:05:42 +0100
a19bc6
Subject: [PATCH] failure-action: generalize failure action to emergency action
a19bc6
a19bc6
Cherry-picked from: 87a47f99bc8e576a63581ad2593c62eb10a53814
a19bc6
Resolves: #1353028
a19bc6
---
23b3cf
 Makefile.am                                   |  4 +-
23b3cf
 src/core/dbus-service.c                       |  6 +-
23b3cf
 src/core/dbus-unit.c                          |  4 +-
23b3cf
 .../{failure-action.c => emergency-action.c}  | 65 ++++++++++---------
23b3cf
 .../{failure-action.h => emergency-action.h}  | 28 ++++----
23b3cf
 src/core/job.c                                |  2 +-
23b3cf
 src/core/load-fragment-gperf.gperf.m4         |  6 +-
23b3cf
 src/core/load-fragment.c                      |  4 +-
23b3cf
 src/core/load-fragment.h                      |  2 +-
23b3cf
 src/core/manager.h                            |  2 +-
23b3cf
 src/core/service.c                            |  4 +-
23b3cf
 src/core/service.h                            |  6 +-
23b3cf
 src/core/unit.c                               |  4 +-
23b3cf
 src/core/unit.h                               |  4 +-
23b3cf
 src/test/test-tables.c                        |  2 +-
a19bc6
 15 files changed, 72 insertions(+), 71 deletions(-)
a19bc6
 rename src/core/{failure-action.c => emergency-action.c} (63%)
a19bc6
 rename src/core/{failure-action.h => emergency-action.h} (58%)
a19bc6
a19bc6
diff --git a/Makefile.am b/Makefile.am
Pablo Greco 48fc63
index 3848338a23..b347aed7db 100644
a19bc6
--- a/Makefile.am
a19bc6
+++ b/Makefile.am
a19bc6
@@ -1182,8 +1182,8 @@ libsystemd_core_la_SOURCES = \
a19bc6
 	src/core/audit-fd.h \
a19bc6
 	src/core/show-status.c \
a19bc6
 	src/core/show-status.h \
a19bc6
-	src/core/failure-action.c \
a19bc6
-	src/core/failure-action.h
a19bc6
+	src/core/emergency-action.c \
a19bc6
+	src/core/emergency-action.h
a19bc6
 
a19bc6
 nodist_libsystemd_core_la_SOURCES = \
a19bc6
 	src/core/load-fragment-gperf.c \
a19bc6
diff --git a/src/core/dbus-service.c b/src/core/dbus-service.c
Pablo Greco 48fc63
index 6d4713babc..325ed13f58 100644
a19bc6
--- a/src/core/dbus-service.c
a19bc6
+++ b/src/core/dbus-service.c
a19bc6
@@ -34,7 +34,7 @@ static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_type, service_type, ServiceType
a19bc6
 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_result, service_result, ServiceResult);
a19bc6
 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_restart, service_restart, ServiceRestart);
a19bc6
 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_notify_access, notify_access, NotifyAccess);
a19bc6
-static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_failure_action, failure_action, FailureAction);
a19bc6
+static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_emergency_action, emergency_action, EmergencyAction);
a19bc6
 
a19bc6
 const sd_bus_vtable bus_service_vtable[] = {
a19bc6
         SD_BUS_VTABLE_START(0),
a19bc6
@@ -49,9 +49,9 @@ const sd_bus_vtable bus_service_vtable[] = {
a19bc6
         BUS_PROPERTY_DUAL_TIMESTAMP("WatchdogTimestamp", offsetof(Service, watchdog_timestamp), 0),
a19bc6
         SD_BUS_PROPERTY("StartLimitInterval", "t", bus_property_get_usec, offsetof(Service, start_limit.interval), SD_BUS_VTABLE_PROPERTY_CONST),
a19bc6
         SD_BUS_PROPERTY("StartLimitBurst", "u", bus_property_get_unsigned, offsetof(Service, start_limit.burst), SD_BUS_VTABLE_PROPERTY_CONST),
a19bc6
-        SD_BUS_PROPERTY("StartLimitAction", "s", property_get_failure_action, offsetof(Service, start_limit_action), SD_BUS_VTABLE_PROPERTY_CONST),
a19bc6
+        SD_BUS_PROPERTY("StartLimitAction", "s", property_get_emergency_action, offsetof(Service, start_limit_action), SD_BUS_VTABLE_PROPERTY_CONST),
a19bc6
         SD_BUS_PROPERTY("RebootArgument", "s", NULL, offsetof(Service, reboot_arg), SD_BUS_VTABLE_PROPERTY_CONST),
a19bc6
-        SD_BUS_PROPERTY("FailureAction", "s", property_get_failure_action, offsetof(Service, failure_action), SD_BUS_VTABLE_PROPERTY_CONST),
a19bc6
+        SD_BUS_PROPERTY("FailureAction", "s", property_get_emergency_action, offsetof(Service, emergency_action), SD_BUS_VTABLE_PROPERTY_CONST),
a19bc6
         SD_BUS_PROPERTY("PermissionsStartOnly", "b", bus_property_get_bool, offsetof(Service, permissions_start_only), SD_BUS_VTABLE_PROPERTY_CONST),
a19bc6
         SD_BUS_PROPERTY("RootDirectoryStartOnly", "b", bus_property_get_bool, offsetof(Service, root_directory_start_only), SD_BUS_VTABLE_PROPERTY_CONST),
a19bc6
         SD_BUS_PROPERTY("RemainAfterExit", "b", bus_property_get_bool, offsetof(Service, remain_after_exit), SD_BUS_VTABLE_PROPERTY_CONST),
a19bc6
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
Pablo Greco 48fc63
index c3654db9ea..89b00e94c6 100644
a19bc6
--- a/src/core/dbus-unit.c
a19bc6
+++ b/src/core/dbus-unit.c
a19bc6
@@ -33,7 +33,7 @@
a19bc6
 
a19bc6
 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_load_state, unit_load_state, UnitLoadState);
a19bc6
 static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_job_mode, job_mode, JobMode);
a19bc6
-static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_failure_action, failure_action, FailureAction);
a19bc6
+static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_emergency_action, emergency_action, EmergencyAction);
a19bc6
 
a19bc6
 static int property_get_names(
a19bc6
                 sd_bus *bus,
a19bc6
@@ -595,7 +595,7 @@ const sd_bus_vtable bus_unit_vtable[] = {
a19bc6
         SD_BUS_PROPERTY("IgnoreOnSnapshot", "b", bus_property_get_bool, offsetof(Unit, ignore_on_snapshot), SD_BUS_VTABLE_PROPERTY_CONST),
a19bc6
         SD_BUS_PROPERTY("NeedDaemonReload", "b", property_get_need_daemon_reload, 0, SD_BUS_VTABLE_PROPERTY_CONST),
a19bc6
         SD_BUS_PROPERTY("JobTimeoutUSec", "t", bus_property_get_usec, offsetof(Unit, job_timeout), SD_BUS_VTABLE_PROPERTY_CONST),
a19bc6
-        SD_BUS_PROPERTY("JobTimeoutAction", "s", property_get_failure_action, offsetof(Unit, job_timeout_action), SD_BUS_VTABLE_PROPERTY_CONST),
a19bc6
+        SD_BUS_PROPERTY("JobTimeoutAction", "s", property_get_emergency_action, offsetof(Unit, job_timeout_action), SD_BUS_VTABLE_PROPERTY_CONST),
a19bc6
         SD_BUS_PROPERTY("JobTimeoutRebootArgument", "s", NULL, offsetof(Unit, job_timeout_reboot_arg), SD_BUS_VTABLE_PROPERTY_CONST),
a19bc6
         SD_BUS_PROPERTY("ConditionResult", "b", bus_property_get_bool, offsetof(Unit, condition_result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
a19bc6
         SD_BUS_PROPERTY("AssertResult", "b", bus_property_get_bool, offsetof(Unit, assert_result), SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
a19bc6
diff --git a/src/core/failure-action.c b/src/core/emergency-action.c
a19bc6
similarity index 63%
a19bc6
rename from src/core/failure-action.c
a19bc6
rename to src/core/emergency-action.c
Pablo Greco 48fc63
index ce522a4e4f..f07b1257a0 100644
a19bc6
--- a/src/core/failure-action.c
a19bc6
+++ b/src/core/emergency-action.c
a19bc6
@@ -27,44 +27,45 @@
a19bc6
 #include "bus-util.h"
a19bc6
 #include "bus-error.h"
a19bc6
 #include "special.h"
a19bc6
-#include "failure-action.h"
a19bc6
+#include "emergency-action.h"
a19bc6
 
a19bc6
-static void log_and_status(Manager *m, const char *message) {
a19bc6
-        log_warning("%s", message);
a19bc6
+static void log_and_status(Manager *m, const char *message, const char *reason) {
a19bc6
+        log_warning("%s: %s", message, reason);
a19bc6
         manager_status_printf(m, STATUS_TYPE_EMERGENCY,
a19bc6
                               ANSI_HIGHLIGHT_RED_ON " !!  " ANSI_HIGHLIGHT_OFF,
a19bc6
-                              "%s", message);
a19bc6
+                              "%s: %s", message, reason);
a19bc6
 }
a19bc6
 
a19bc6
-int failure_action(
a19bc6
+int emergency_action(
a19bc6
                 Manager *m,
a19bc6
-                FailureAction action,
a19bc6
-                const char *reboot_arg) {
a19bc6
+                EmergencyAction action,
a19bc6
+                const char *reboot_arg,
a19bc6
+                const char *reason) {
a19bc6
 
a19bc6
         int r;
a19bc6
 
a19bc6
         assert(m);
a19bc6
         assert(action >= 0);
a19bc6
-        assert(action < _FAILURE_ACTION_MAX);
a19bc6
+        assert(action < _EMERGENCY_ACTION_MAX);
a19bc6
 
a19bc6
-        if (action == FAILURE_ACTION_NONE)
a19bc6
+        if (action == EMERGENCY_ACTION_NONE)
a19bc6
                 return -ECANCELED;
a19bc6
 
a19bc6
         if (m->running_as == SYSTEMD_USER) {
a19bc6
                 /* Downgrade all options to simply exiting if we run
a19bc6
                  * in user mode */
a19bc6
 
a19bc6
-                log_warning("Exiting as result of failure.");
a19bc6
+                log_warning("Exiting: %s", reason);
a19bc6
                 m->exit_code = MANAGER_EXIT;
a19bc6
                 return -ECANCELED;
a19bc6
         }
a19bc6
 
a19bc6
         switch (action) {
a19bc6
 
a19bc6
-        case FAILURE_ACTION_REBOOT: {
a19bc6
+        case EMERGENCY_ACTION_REBOOT: {
a19bc6
                 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
a19bc6
 
a19bc6
-                log_and_status(m, "Rebooting as result of failure.");
a19bc6
+                log_and_status(m, "Rebooting", reason);
a19bc6
 
a19bc6
                 update_reboot_param_file(reboot_arg);
a19bc6
                 r = manager_add_job_by_name(m, JOB_START, SPECIAL_REBOOT_TARGET, JOB_REPLACE, true, &error, NULL);
a19bc6
@@ -74,15 +75,15 @@ int failure_action(
a19bc6
                 break;
a19bc6
         }
a19bc6
 
a19bc6
-        case FAILURE_ACTION_REBOOT_FORCE:
a19bc6
-                log_and_status(m, "Forcibly rebooting as result of failure.");
a19bc6
+        case EMERGENCY_ACTION_REBOOT_FORCE:
a19bc6
+                log_and_status(m, "Forcibly rebooting", reason);
a19bc6
 
a19bc6
                 update_reboot_param_file(reboot_arg);
a19bc6
                 m->exit_code = MANAGER_REBOOT;
a19bc6
                 break;
a19bc6
 
a19bc6
-        case FAILURE_ACTION_REBOOT_IMMEDIATE:
a19bc6
-                log_and_status(m, "Rebooting immediately as result of failure.");
a19bc6
+        case EMERGENCY_ACTION_REBOOT_IMMEDIATE:
a19bc6
+                log_and_status(m, "Rebooting immediately", reason);
a19bc6
 
a19bc6
                 sync();
a19bc6
 
a19bc6
@@ -95,10 +96,10 @@ int failure_action(
a19bc6
                 reboot(RB_AUTOBOOT);
a19bc6
                 break;
a19bc6
 
a19bc6
-        case FAILURE_ACTION_POWEROFF: {
a19bc6
+        case EMERGENCY_ACTION_POWEROFF: {
a19bc6
                 _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
a19bc6
 
a19bc6
-                log_and_status(m, "Powering off as result of failure.");
a19bc6
+                log_and_status(m, "Powering off", reason);
a19bc6
 
a19bc6
                 r = manager_add_job_by_name(m, JOB_START, SPECIAL_POWEROFF_TARGET, JOB_REPLACE, true, &error, NULL);
a19bc6
                 if (r < 0)
a19bc6
@@ -107,13 +108,13 @@ int failure_action(
a19bc6
                 break;
a19bc6
         }
a19bc6
 
a19bc6
-        case FAILURE_ACTION_POWEROFF_FORCE:
a19bc6
-                log_and_status(m, "Forcibly powering off as result of failure.");
a19bc6
+        case EMERGENCY_ACTION_POWEROFF_FORCE:
a19bc6
+                log_and_status(m, "Forcibly powering off", reason);
a19bc6
                 m->exit_code = MANAGER_POWEROFF;
a19bc6
                 break;
a19bc6
 
a19bc6
-        case FAILURE_ACTION_POWEROFF_IMMEDIATE:
a19bc6
-                log_and_status(m, "Powering off immediately as result of failure.");
a19bc6
+        case EMERGENCY_ACTION_POWEROFF_IMMEDIATE:
a19bc6
+                log_and_status(m, "Powering off immediately", reason);
a19bc6
 
a19bc6
                 sync();
a19bc6
 
a19bc6
@@ -122,19 +123,19 @@ int failure_action(
a19bc6
                 break;
a19bc6
 
a19bc6
         default:
a19bc6
-                assert_not_reached("Unknown failure action");
a19bc6
+                assert_not_reached("Unknown emergency action");
a19bc6
         }
a19bc6
 
a19bc6
         return -ECANCELED;
a19bc6
 }
a19bc6
 
a19bc6
-static const char* const failure_action_table[_FAILURE_ACTION_MAX] = {
a19bc6
-        [FAILURE_ACTION_NONE] = "none",
a19bc6
-        [FAILURE_ACTION_REBOOT] = "reboot",
a19bc6
-        [FAILURE_ACTION_REBOOT_FORCE] = "reboot-force",
a19bc6
-        [FAILURE_ACTION_REBOOT_IMMEDIATE] = "reboot-immediate",
a19bc6
-        [FAILURE_ACTION_POWEROFF] = "poweroff",
a19bc6
-        [FAILURE_ACTION_POWEROFF_FORCE] = "poweroff-force",
a19bc6
-        [FAILURE_ACTION_POWEROFF_IMMEDIATE] = "poweroff-immediate"
a19bc6
+static const char* const emergency_action_table[_EMERGENCY_ACTION_MAX] = {
a19bc6
+        [EMERGENCY_ACTION_NONE] = "none",
a19bc6
+        [EMERGENCY_ACTION_REBOOT] = "reboot",
a19bc6
+        [EMERGENCY_ACTION_REBOOT_FORCE] = "reboot-force",
a19bc6
+        [EMERGENCY_ACTION_REBOOT_IMMEDIATE] = "reboot-immediate",
a19bc6
+        [EMERGENCY_ACTION_POWEROFF] = "poweroff",
a19bc6
+        [EMERGENCY_ACTION_POWEROFF_FORCE] = "poweroff-force",
a19bc6
+        [EMERGENCY_ACTION_POWEROFF_IMMEDIATE] = "poweroff-immediate"
a19bc6
 };
a19bc6
-DEFINE_STRING_TABLE_LOOKUP(failure_action, FailureAction);
a19bc6
+DEFINE_STRING_TABLE_LOOKUP(emergency_action, EmergencyAction);
a19bc6
diff --git a/src/core/failure-action.h b/src/core/emergency-action.h
a19bc6
similarity index 58%
a19bc6
rename from src/core/failure-action.h
a19bc6
rename to src/core/emergency-action.h
Pablo Greco 48fc63
index 1af4dd987b..d3ac0f31c9 100644
a19bc6
--- a/src/core/failure-action.h
a19bc6
+++ b/src/core/emergency-action.h
a19bc6
@@ -22,22 +22,22 @@
a19bc6
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
a19bc6
 ***/
a19bc6
 
a19bc6
-typedef enum FailureAction {
a19bc6
-        FAILURE_ACTION_NONE,
a19bc6
-        FAILURE_ACTION_REBOOT,
a19bc6
-        FAILURE_ACTION_REBOOT_FORCE,
a19bc6
-        FAILURE_ACTION_REBOOT_IMMEDIATE,
a19bc6
-        FAILURE_ACTION_POWEROFF,
a19bc6
-        FAILURE_ACTION_POWEROFF_FORCE,
a19bc6
-        FAILURE_ACTION_POWEROFF_IMMEDIATE,
a19bc6
-        _FAILURE_ACTION_MAX,
a19bc6
-        _FAILURE_ACTION_INVALID = -1
a19bc6
-} FailureAction;
a19bc6
+typedef enum EmergencyAction {
a19bc6
+        EMERGENCY_ACTION_NONE,
a19bc6
+        EMERGENCY_ACTION_REBOOT,
a19bc6
+        EMERGENCY_ACTION_REBOOT_FORCE,
a19bc6
+        EMERGENCY_ACTION_REBOOT_IMMEDIATE,
a19bc6
+        EMERGENCY_ACTION_POWEROFF,
a19bc6
+        EMERGENCY_ACTION_POWEROFF_FORCE,
a19bc6
+        EMERGENCY_ACTION_POWEROFF_IMMEDIATE,
a19bc6
+        _EMERGENCY_ACTION_MAX,
a19bc6
+        _EMERGENCY_ACTION_INVALID = -1
a19bc6
+} EmergencyAction;
a19bc6
 
a19bc6
 #include "macro.h"
a19bc6
 #include "manager.h"
a19bc6
 
a19bc6
-int failure_action(Manager *m, FailureAction action, const char *reboot_arg);
a19bc6
+int emergency_action(Manager *m, EmergencyAction action, const char *reboot_arg, const char *reason);
a19bc6
 
a19bc6
-const char* failure_action_to_string(FailureAction i) _const_;
a19bc6
-FailureAction failure_action_from_string(const char *s) _pure_;
a19bc6
+const char* emergency_action_to_string(EmergencyAction i) _const_;
a19bc6
+EmergencyAction emergency_action_from_string(const char *s) _pure_;
a19bc6
diff --git a/src/core/job.c b/src/core/job.c
Pablo Greco 48fc63
index c2876dec18..703286496f 100644
a19bc6
--- a/src/core/job.c
a19bc6
+++ b/src/core/job.c
a19bc6
@@ -916,7 +916,7 @@ static int job_dispatch_timer(sd_event_source *s, uint64_t monotonic, void *user
a19bc6
         u = j->unit;
a19bc6
         job_finish_and_invalidate(j, JOB_TIMEOUT, true, false);
a19bc6
 
a19bc6
-        failure_action(u->manager, u->job_timeout_action, u->job_timeout_reboot_arg);
a19bc6
+        emergency_action(u->manager, u->job_timeout_action, u->job_timeout_reboot_arg, "job timed out");
a19bc6
 
a19bc6
         return 0;
a19bc6
 }
a19bc6
diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
Pablo Greco 48fc63
index ce1397c7e8..45d1ead45b 100644
a19bc6
--- a/src/core/load-fragment-gperf.gperf.m4
a19bc6
+++ b/src/core/load-fragment-gperf.gperf.m4
a19bc6
@@ -156,7 +156,7 @@ Unit.OnFailureIsolate,           config_parse_job_mode_isolate,      0,
a19bc6
 Unit.IgnoreOnIsolate,            config_parse_bool,                  0,                             offsetof(Unit, ignore_on_isolate)
a19bc6
 Unit.IgnoreOnSnapshot,           config_parse_bool,                  0,                             offsetof(Unit, ignore_on_snapshot)
a19bc6
 Unit.JobTimeoutSec,              config_parse_sec,                   0,                             offsetof(Unit, job_timeout)
a19bc6
-Unit.JobTimeoutAction,           config_parse_failure_action,        0,                             offsetof(Unit, job_timeout_action)
a19bc6
+Unit.JobTimeoutAction,           config_parse_emergency_action,        0,                             offsetof(Unit, job_timeout_action)
a19bc6
 Unit.JobTimeoutRebootArgument,   config_parse_string,                0,                             offsetof(Unit, job_timeout_reboot_arg)
a19bc6
 Unit.ConditionPathExists,        config_parse_unit_condition_path,   CONDITION_PATH_EXISTS,         offsetof(Unit, conditions)
a19bc6
 Unit.ConditionPathExistsGlob,    config_parse_unit_condition_path,   CONDITION_PATH_EXISTS_GLOB,    offsetof(Unit, conditions)
a19bc6
@@ -211,9 +211,9 @@ Service.TimeoutStopSec,          config_parse_service_timeout,       0,
a19bc6
 Service.WatchdogSec,             config_parse_sec,                   0,                             offsetof(Service, watchdog_usec)
a19bc6
 Service.StartLimitInterval,      config_parse_sec,                   0,                             offsetof(Service, start_limit.interval)
a19bc6
 Service.StartLimitBurst,         config_parse_unsigned,              0,                             offsetof(Service, start_limit.burst)
a19bc6
-Service.StartLimitAction,        config_parse_failure_action,        0,                             offsetof(Service, start_limit_action)
a19bc6
+Service.StartLimitAction,        config_parse_emergency_action,      0,                             offsetof(Service, start_limit_action)
a19bc6
 Service.RebootArgument,          config_parse_string,                0,                             offsetof(Service, reboot_arg)
a19bc6
-Service.FailureAction,           config_parse_failure_action,        0,                             offsetof(Service, failure_action)
a19bc6
+Service.FailureAction,           config_parse_emergency_action,      0,                             offsetof(Service, emergency_action)
a19bc6
 Service.Type,                    config_parse_service_type,          0,                             offsetof(Service, type)
a19bc6
 Service.Restart,                 config_parse_service_restart,       0,                             offsetof(Service, restart)
a19bc6
 Service.PermissionsStartOnly,    config_parse_bool,                  0,                             offsetof(Service, permissions_start_only)
a19bc6
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
Pablo Greco 48fc63
index 83b6e7efca..4fecb83142 100644
a19bc6
--- a/src/core/load-fragment.c
a19bc6
+++ b/src/core/load-fragment.c
a19bc6
@@ -2382,7 +2382,7 @@ int config_parse_unit_condition_null(
a19bc6
 }
a19bc6
 
a19bc6
 DEFINE_CONFIG_PARSE_ENUM(config_parse_notify_access, notify_access, NotifyAccess, "Failed to parse notify access specifier");
a19bc6
-DEFINE_CONFIG_PARSE_ENUM(config_parse_failure_action, failure_action, FailureAction, "Failed to parse failure action specifier");
a19bc6
+DEFINE_CONFIG_PARSE_ENUM(config_parse_emergency_action, emergency_action, EmergencyAction, "Failed to parse failure action specifier");
a19bc6
 
a19bc6
 int config_parse_unit_requires_mounts_for(
a19bc6
                 const char *unit,
a19bc6
@@ -3931,7 +3931,7 @@ void unit_dump_config_items(FILE *f) {
a19bc6
                 { config_parse_unit_slice,            "SLICE" },
a19bc6
                 { config_parse_documentation,         "URL" },
a19bc6
                 { config_parse_service_timeout,       "SECONDS" },
a19bc6
-                { config_parse_failure_action,        "ACTION" },
a19bc6
+                { config_parse_emergency_action,      "ACTION" },
a19bc6
                 { config_parse_set_status,            "STATUS" },
a19bc6
                 { config_parse_service_sockets,       "SOCKETS" },
a19bc6
                 { config_parse_environ,               "ENVIRON" },
a19bc6
diff --git a/src/core/load-fragment.h b/src/core/load-fragment.h
Pablo Greco 48fc63
index 359794d0ac..6114796126 100644
a19bc6
--- a/src/core/load-fragment.h
a19bc6
+++ b/src/core/load-fragment.h
a19bc6
@@ -78,7 +78,7 @@ int config_parse_unit_condition_string(const char *unit, const char *filename, u
a19bc6
 int config_parse_unit_condition_null(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
a19bc6
 int config_parse_kill_mode(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
a19bc6
 int config_parse_notify_access(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
a19bc6
-int config_parse_failure_action(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
a19bc6
+int config_parse_emergency_action(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
a19bc6
 int config_parse_unit_requires_mounts_for(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
a19bc6
 int config_parse_syscall_filter(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
a19bc6
 int config_parse_syscall_archs(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
a19bc6
diff --git a/src/core/manager.h b/src/core/manager.h
Pablo Greco 48fc63
index 42be1fc437..59913f4896 100644
a19bc6
--- a/src/core/manager.h
a19bc6
+++ b/src/core/manager.h
a19bc6
@@ -85,7 +85,7 @@ typedef enum StatusType {
a19bc6
 #include "unit-name.h"
a19bc6
 #include "exit-status.h"
a19bc6
 #include "show-status.h"
a19bc6
-#include "failure-action.h"
a19bc6
+#include "emergency-action.h"
a19bc6
 
a19bc6
 struct Manager {
a19bc6
         /* Note that the set of units we know of is allowed to be
a19bc6
diff --git a/src/core/service.c b/src/core/service.c
Pablo Greco 48fc63
index babd3c52ae..6e7baa76c6 100644
a19bc6
--- a/src/core/service.c
a19bc6
+++ b/src/core/service.c
a19bc6
@@ -1280,7 +1280,7 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
a19bc6
 
a19bc6
         if (s->result != SERVICE_SUCCESS) {
a19bc6
                 log_unit_warning(UNIT(s)->id, "%s failed.", UNIT(s)->id);
a19bc6
-                failure_action(UNIT(s)->manager, s->failure_action, s->reboot_arg);
a19bc6
+                emergency_action(UNIT(s)->manager, s->emergency_action, s->reboot_arg, "service failed");
a19bc6
         }
a19bc6
 
a19bc6
         if (allow_restart &&
a19bc6
@@ -1821,7 +1821,7 @@ static int service_start_limit_test(Service *s) {
a19bc6
 
a19bc6
         log_unit_warning(UNIT(s)->id, "start request repeated too quickly for %s", UNIT(s)->id);
a19bc6
 
a19bc6
-        return failure_action(UNIT(s)->manager, s->start_limit_action, s->reboot_arg);
a19bc6
+        return emergency_action(UNIT(s)->manager, s->start_limit_action, s->reboot_arg, "service failed");
a19bc6
 }
a19bc6
 
a19bc6
 static int service_start(Unit *u) {
a19bc6
diff --git a/src/core/service.h b/src/core/service.h
Pablo Greco 48fc63
index dfeee6a68c..1f937dfe57 100644
a19bc6
--- a/src/core/service.h
a19bc6
+++ b/src/core/service.h
a19bc6
@@ -29,7 +29,7 @@ typedef struct ServiceFDStore ServiceFDStore;
a19bc6
 #include "ratelimit.h"
a19bc6
 #include "kill.h"
a19bc6
 #include "exit-status.h"
a19bc6
-#include "failure-action.h"
a19bc6
+#include "emergency-action.h"
a19bc6
 
a19bc6
 typedef enum ServiceState {
a19bc6
         SERVICE_DEAD,
a19bc6
@@ -197,8 +197,8 @@ struct Service {
a19bc6
         int status_errno;
a19bc6
 
a19bc6
         RateLimit start_limit;
a19bc6
-        FailureAction start_limit_action;
a19bc6
-        FailureAction failure_action;
a19bc6
+        EmergencyAction start_limit_action;
a19bc6
+        EmergencyAction emergency_action;
a19bc6
         char *reboot_arg;
a19bc6
 
a19bc6
         UnitRef accept_socket;
a19bc6
diff --git a/src/core/unit.c b/src/core/unit.c
Pablo Greco 48fc63
index a7d6d2f45b..4eb0d78f44 100644
a19bc6
--- a/src/core/unit.c
a19bc6
+++ b/src/core/unit.c
a19bc6
@@ -937,8 +937,8 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
a19bc6
         if (u->job_timeout > 0)
a19bc6
                 fprintf(f, "%s\tJob Timeout: %s\n", prefix, format_timespan(timespan, sizeof(timespan), u->job_timeout, 0));
a19bc6
 
a19bc6
-        if (u->job_timeout_action != FAILURE_ACTION_NONE)
a19bc6
-                fprintf(f, "%s\tJob Timeout Action: %s\n", prefix, failure_action_to_string(u->job_timeout_action));
a19bc6
+        if (u->job_timeout_action != EMERGENCY_ACTION_NONE)
a19bc6
+                fprintf(f, "%s\tJob Timeout Action: %s\n", prefix, emergency_action_to_string(u->job_timeout_action));
a19bc6
 
a19bc6
         if (u->job_timeout_reboot_arg)
a19bc6
                 fprintf(f, "%s\tJob Timeout Reboot Argument: %s\n", prefix, u->job_timeout_reboot_arg);
a19bc6
diff --git a/src/core/unit.h b/src/core/unit.h
Pablo Greco 48fc63
index 35287a5b75..85f52df187 100644
a19bc6
--- a/src/core/unit.h
a19bc6
+++ b/src/core/unit.h
a19bc6
@@ -41,7 +41,7 @@ typedef struct UnitStatusMessageFormats UnitStatusMessageFormats;
a19bc6
 #include "condition.h"
a19bc6
 #include "install.h"
a19bc6
 #include "unit-name.h"
a19bc6
-#include "failure-action.h"
a19bc6
+#include "emergency-action.h"
a19bc6
 
a19bc6
 enum UnitActiveState {
a19bc6
         UNIT_ACTIVE,
a19bc6
@@ -121,7 +121,7 @@ struct Unit {
a19bc6
 
a19bc6
         /* Job timeout and action to take */
a19bc6
         usec_t job_timeout;
a19bc6
-        FailureAction job_timeout_action;
a19bc6
+        EmergencyAction job_timeout_action;
a19bc6
         char *job_timeout_reboot_arg;
a19bc6
 
a19bc6
         /* References to this */
a19bc6
diff --git a/src/test/test-tables.c b/src/test/test-tables.c
Pablo Greco 48fc63
index bda224bec6..e4097903c4 100644
a19bc6
--- a/src/test/test-tables.c
a19bc6
+++ b/src/test/test-tables.c
a19bc6
@@ -67,7 +67,7 @@ int main(int argc, char **argv) {
a19bc6
         test_table(device_state, DEVICE_STATE);
a19bc6
         test_table(exec_input, EXEC_INPUT);
a19bc6
         test_table(exec_output, EXEC_OUTPUT);
a19bc6
-        test_table(failure_action, FAILURE_ACTION);
a19bc6
+        test_table(emergency_action, EMERGENCY_ACTION);
a19bc6
         test_table(job_mode, JOB_MODE);
a19bc6
         test_table(job_result, JOB_RESULT);
a19bc6
         test_table(job_state, JOB_STATE);