unit_notify(UNIT(t), state_translation_table[old_state], state_translation_table[state], true);
}
-static int slice_add_slice_link(Slice *s) {
+static int slice_add_parent_slice(Slice *s) {
char *a, *dash;
- int r;
Unit *parent;
+ int r;
assert(s);
- if (UNIT_DEREF(UNIT(s)->slice))
+ if (UNIT_ISSET(UNIT(s)->slice))
return 0;
- a = strdupa(UNIT(s)->id);
-
- dash = strrchr(a, '-');
- if (!dash)
+ if (unit_has_name(UNIT(s), SPECIAL_ROOT_SLICE))
return 0;
- strcpy(dash, ".slice");
+ a = strdupa(UNIT(s)->id);
+ dash = strrchr(a, '-');
+ if (dash)
+ strcpy(dash, ".slice");
+ else
+ a = (char*) SPECIAL_ROOT_SLICE;
r = manager_load_unit(UNIT(s)->manager, a, NULL, NULL, &parent);
if (r < 0)
assert(s);
/* Make sure slices are unloaded on shutdown */
- r = unit_add_dependency_by_name(UNIT(s), UNIT_CONFLICTS, SPECIAL_SHUTDOWN_TARGET, NULL, true);
+ r = unit_add_two_dependencies_by_name(
+ UNIT(s),
+ UNIT_BEFORE, UNIT_CONFLICTS,
+ SPECIAL_SHUTDOWN_TARGET, NULL, true);
if (r < 0)
return r;
a = strdupa(UNIT(s)->id);
dash = strrchr(a, '-');
- if (dash) {
+ if (dash)
strcpy(dash, ".slice");
+ else
+ a = (char*) SPECIAL_ROOT_SLICE;
- if (!unit_has_name(UNIT_DEREF(UNIT(s)->slice), a)) {
- log_error_unit(UNIT(s)->id,
- "%s located outside its parent slice. Refusing.", UNIT(s)->id);
- return -EINVAL;
- }
+ if (!unit_has_name(UNIT_DEREF(UNIT(s)->slice), a)) {
+ log_unit_error(UNIT(s)->id,
+ "%s located outside its parent slice. Refusing.", UNIT(s)->id);
+ return -EINVAL;
}
}
assert(s);
- r = unit_load_fragment_and_dropin(u);
+ r = unit_load_fragment_and_dropin_optional(u);
if (r < 0)
return r;
/* This is a new unit? Then let's add in some extras */
if (u->load_state == UNIT_LOADED) {
- r = slice_add_slice_link(s);
+ r = unit_patch_contexts(u);
+ if (r < 0)
+ return r;
+
+ r = slice_add_parent_slice(s);
if (r < 0)
return r;
if (r < 0)
return r;
}
-
- r = unit_add_default_cgroups(UNIT(s));
- if (r < 0)
- return r;
}
return slice_verify(s);
fprintf(f,
"%sSlice State: %s\n",
prefix, slice_state_to_string(t->state));
+
+ cgroup_context_dump(&t->cgroup_context, f, prefix);
}
static int slice_start(Unit *u) {
Slice *t = SLICE(u);
- int r;
assert(t);
assert(t->state == SLICE_DEAD);
- r = cgroup_bonding_realize_list(u->cgroup_bondings);
- if (r < 0)
- return r;
-
- cgroup_attribute_apply_list(u->cgroup_attributes, u->cgroup_bondings);
+ unit_realize_cgroup(u);
slice_set_state(t, SLICE_ACTIVE);
return 0;
assert(t);
assert(t->state == SLICE_ACTIVE);
- /* We do not need to trim the cgroup explicitly, unit_notify()
- * will do that for us anyway. */
+ /* We do not need to destroy the cgroup explicitly,
+ * unit_notify() will do that for us anyway. */
slice_set_state(t, SLICE_DEAD);
return 0;
}
-static int slice_kill(Unit *u, KillWho who, int signo, DBusError *error) {
+static int slice_kill(Unit *u, KillWho who, int signo, sd_bus_error *error) {
return unit_kill_common(u, who, signo, -1, -1, error);
}
const UnitVTable slice_vtable = {
.object_size = sizeof(Slice),
+ .cgroup_context_offset = offsetof(Slice, cgroup_context),
+
.sections =
"Unit\0"
"Slice\0"
"Install\0",
+ .private_section = "Slice",
.no_alias = true,
.no_instances = true,
.load = slice_load,
+
.coldplug = slice_coldplug,
.dump = slice_dump,
.sub_state_to_string = slice_sub_state_to_string,
.bus_interface = "org.freedesktop.systemd1.Slice",
- .bus_message_handler = bus_slice_message_handler,
+ .bus_vtable = bus_slice_vtable,
+ .bus_set_property = bus_slice_set_property,
+ .bus_commit_properties = bus_slice_commit_properties,
.status_message_formats = {
.finished_start_job = {
- [JOB_DONE] = "Installed slice %s.",
+ [JOB_DONE] = "Created slice %s.",
[JOB_DEPENDENCY] = "Dependency failed for %s.",
},
.finished_stop_job = {
- [JOB_DONE] = "Deinstalled slice %s.",
+ [JOB_DONE] = "Removed slice %s.",
},
},
};