summaryrefslogtreecommitdiff
path: root/src/core/unit.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-12-12 21:05:32 +0100
committerLennart Poettering <lennart@poettering.net>2014-12-15 19:02:17 +0100
commit0faacd470dfbd24f4c6504da6f04213aa05f9d19 (patch)
tree9b13b654d993efc475f9209f8b1cf602850ee27b /src/core/unit.c
parent17d1f37d0dbd2d78b8866e1350c83a9755105144 (diff)
unit: handle nicely of certain unit types are not supported on specific systems
Containers do not really support .device, .automount or .swap units; Systems compiled without support for swap do not support .swap units; Systems without kdbus do not support .busname units. With this change attempts to start a unsupported unit types will result in an immediate "unsupported" job result, which is a lot more descriptive then before. Also, attempts to start device units in containers will now immediately fail instead of causing jobs to be enqueued that never go away.
Diffstat (limited to 'src/core/unit.c')
-rw-r--r--src/core/unit.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/core/unit.c b/src/core/unit.c
index fe0dfb2083..8cec0e7e7f 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1453,6 +1453,9 @@ int unit_start(Unit *u) {
unit_status_log_starting_stopping_reloading(u, JOB_START);
unit_status_print_starting_stopping(u, JOB_START);
+ if (UNIT_VTABLE(u)->supported && !UNIT_VTABLE(u)->supported(u->manager))
+ return -ENOTSUP;
+
/* If it is stopped, but we cannot start it, then fail */
if (!UNIT_VTABLE(u)->start)
return -EBADR;
@@ -1496,9 +1499,9 @@ int unit_stop(Unit *u) {
if (UNIT_IS_INACTIVE_OR_FAILED(state))
return -EALREADY;
- if ((following = unit_following(u))) {
- log_unit_debug(u->id, "Redirecting stop request from %s to %s.",
- u->id, following->id);
+ following = unit_following(u);
+ if (following) {
+ log_unit_debug(u->id, "Redirecting stop request from %s to %s.", u->id, following->id);
return unit_stop(following);
}
@@ -1535,15 +1538,13 @@ int unit_reload(Unit *u) {
return -EALREADY;
if (state != UNIT_ACTIVE) {
- log_unit_warning(u->id, "Unit %s cannot be reloaded because it is inactive.",
- u->id);
+ log_unit_warning(u->id, "Unit %s cannot be reloaded because it is inactive.", u->id);
return -ENOEXEC;
}
following = unit_following(u);
if (following) {
- log_unit_debug(u->id, "Redirecting reload request from %s to %s.",
- u->id, following->id);
+ log_unit_debug(u->id, "Redirecting reload request from %s to %s.", u->id, following->id);
return unit_reload(following);
}