core: enable transient unit support for slice units
authorLennart Poettering <lennart@poettering.net>
Fri, 13 Nov 2015 17:46:50 +0000 (18:46 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 13 Nov 2015 18:50:52 +0000 (19:50 +0100)
src/core/dbus-manager.c
src/core/slice.c

index 72ad612..67e4e8b 100644 (file)
@@ -655,7 +655,18 @@ static int transient_unit_from_message(
         if (r < 0)
                 return r;
 
-        if (u->load_state != UNIT_NOT_FOUND ||
+        /* Check if the unit already exists or is already referenced,
+         * in a number of different ways. Note that to cater for unit
+         * types such as slice, we are generally fine with units that
+         * are marked UNIT_LOADED even even though nothing was
+         * actually loaded, as those unit types don't require a file
+         * on disk to validly load. */
+
+        if (!IN_SET(u->load_state, UNIT_NOT_FOUND, UNIT_LOADED) ||
+            u->fragment_path ||
+            u->source_path ||
+            !strv_isempty(u->dropin_paths) ||
+            u->refs ||
             set_size(u->dependencies[UNIT_REFERENCED_BY]) > 0)
                 return sd_bus_error_setf(error, BUS_ERROR_UNIT_EXISTS, "Unit %s already exists.", name);
 
index 39dabae..9c488f0 100644 (file)
@@ -305,6 +305,7 @@ const UnitVTable slice_vtable = {
 
         .no_alias = true,
         .no_instances = true,
+        .can_transient = true,
 
         .load = slice_load,