chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
localectl: fix localectl set-x11-keymap syntax description
[elogind.git]
/
src
/
core
/
slice.c
diff --git
a/src/core/slice.c
b/src/core/slice.c
index c1c33fe5c60b256c4e38d2f04b744a49b316d59d..057feefa0fd67889d75f74e3bec3e47da642fe99 100644
(file)
--- a/
src/core/slice.c
+++ b/
src/core/slice.c
@@
-52,23
+52,25
@@
static void slice_set_state(Slice *t, SliceState state) {
unit_notify(UNIT(t), state_translation_table[old_state], state_translation_table[state], true);
}
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;
char *a, *dash;
- int r;
Unit *parent;
Unit *parent;
+ int r;
assert(s);
assert(s);
- if (UNIT_
DEREF
(UNIT(s)->slice))
+ if (UNIT_
ISSET
(UNIT(s)->slice))
return 0;
return 0;
- a = strdupa(UNIT(s)->id);
-
- dash = strrchr(a, '-');
- if (!dash)
+ if (unit_has_name(UNIT(s), SPECIAL_ROOT_SLICE))
return 0;
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)
r = manager_load_unit(UNIT(s)->manager, a, NULL, NULL, &parent);
if (r < 0)
@@
-84,7
+86,10
@@
static int slice_add_default_dependencies(Slice *s) {
assert(s);
/* Make sure slices are unloaded on shutdown */
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;
if (r < 0)
return r;
@@
-102,14
+107,15
@@
static int slice_verify(Slice *s) {
a = strdupa(UNIT(s)->id);
dash = strrchr(a, '-');
a = strdupa(UNIT(s)->id);
dash = strrchr(a, '-');
- if (dash)
{
+ if (dash)
strcpy(dash, ".slice");
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_error_unit(UNIT(s)->id,
+ "%s located outside its parent slice. Refusing.", UNIT(s)->id);
+ return -EINVAL;
}
}
}
}
@@
-122,14
+128,18
@@
static int slice_load(Unit *u) {
assert(s);
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) {
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;
@@
-138,10
+148,6
@@
static int slice_load(Unit *u) {
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);
}
return slice_verify(s);
@@
-168,20
+174,17
@@
static void slice_dump(Unit *u, FILE *f, const char *prefix) {
fprintf(f,
"%sSlice State: %s\n",
prefix, slice_state_to_string(t->state));
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);
}
static int slice_start(Unit *u) {
Slice *t = SLICE(u);
- int r;
assert(t);
assert(t->state == SLICE_DEAD);
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;
slice_set_state(t, SLICE_ACTIVE);
return 0;
@@
-193,14
+196,14
@@
static int slice_stop(Unit *u) {
assert(t);
assert(t->state == SLICE_ACTIVE);
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;
}
slice_set_state(t, SLICE_DEAD);
return 0;
}
-static int slice_kill(Unit *u, KillWho who, int signo,
DBusE
rror *error) {
+static int slice_kill(Unit *u, KillWho who, int signo,
sd_bus_e
rror *error) {
return unit_kill_common(u, who, signo, -1, -1, error);
}
return unit_kill_common(u, who, signo, -1, -1, error);
}
@@
-259,15
+262,19
@@
DEFINE_STRING_TABLE_LOOKUP(slice_state, SliceState);
const UnitVTable slice_vtable = {
.object_size = sizeof(Slice),
const UnitVTable slice_vtable = {
.object_size = sizeof(Slice),
+ .cgroup_context_offset = offsetof(Slice, cgroup_context),
+
.sections =
"Unit\0"
"Slice\0"
"Install\0",
.sections =
"Unit\0"
"Slice\0"
"Install\0",
+ .private_section = "Slice",
.no_alias = true,
.no_instances = true,
.load = slice_load,
.no_alias = true,
.no_instances = true,
.load = slice_load,
+
.coldplug = slice_coldplug,
.dump = slice_dump,
.coldplug = slice_coldplug,
.dump = slice_dump,
@@
-284,15
+291,17
@@
const UnitVTable slice_vtable = {
.sub_state_to_string = slice_sub_state_to_string,
.bus_interface = "org.freedesktop.systemd1.Slice",
.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 = {
.status_message_formats = {
.finished_start_job = {
- [JOB_DONE] = "
Install
ed slice %s.",
+ [JOB_DONE] = "
Creat
ed slice %s.",
[JOB_DEPENDENCY] = "Dependency failed for %s.",
},
.finished_stop_job = {
[JOB_DEPENDENCY] = "Dependency failed for %s.",
},
.finished_stop_job = {
- [JOB_DONE] = "
Deinstall
ed slice %s.",
+ [JOB_DONE] = "
Remov
ed slice %s.",
},
},
};
},
},
};