Merge pull request #13760 from keszybz/unit-loading-unification
Unit loading unification
This commit is contained in:
+25
-20
@@ -164,9 +164,7 @@ static int automount_verify(Automount *a) {
|
||||
int r;
|
||||
|
||||
assert(a);
|
||||
|
||||
if (UNIT(a)->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
assert(UNIT(a)->load_state == UNIT_LOADED);
|
||||
|
||||
if (path_equal(a->where, "/")) {
|
||||
log_unit_error(UNIT(a), "Cannot have an automount unit for the root directory. Refusing.");
|
||||
@@ -201,6 +199,24 @@ static int automount_set_where(Automount *a) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int automount_add_extras(Automount *a) {
|
||||
int r;
|
||||
|
||||
r = automount_set_where(a);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = automount_add_trigger_dependencies(a);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = automount_add_mount_dependencies(a);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return automount_add_default_dependencies(a);
|
||||
}
|
||||
|
||||
static int automount_load(Unit *u) {
|
||||
Automount *a = AUTOMOUNT(u);
|
||||
int r;
|
||||
@@ -209,27 +225,16 @@ static int automount_load(Unit *u) {
|
||||
assert(u->load_state == UNIT_STUB);
|
||||
|
||||
/* Load a .automount file */
|
||||
r = unit_load_fragment_and_dropin(u);
|
||||
r = unit_load_fragment_and_dropin(u, true);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (u->load_state == UNIT_LOADED) {
|
||||
r = automount_set_where(a);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (u->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
|
||||
r = automount_add_trigger_dependencies(a);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = automount_add_mount_dependencies(a);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = automount_add_default_dependencies(a);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
r = automount_add_extras(a);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return automount_verify(a);
|
||||
}
|
||||
|
||||
+4
-4
@@ -970,10 +970,10 @@ static uint64_t cgroup_cpu_weight_to_shares(uint64_t weight) {
|
||||
CGROUP_CPU_SHARES_MIN, CGROUP_CPU_SHARES_MAX);
|
||||
}
|
||||
|
||||
static void cgroup_apply_unified_cpuset(Unit *u, CPUSet cpus, const char *name) {
|
||||
static void cgroup_apply_unified_cpuset(Unit *u, const CPUSet *cpus, const char *name) {
|
||||
_cleanup_free_ char *buf = NULL;
|
||||
|
||||
buf = cpu_set_to_range_string(&cpus);
|
||||
buf = cpu_set_to_range_string(cpus);
|
||||
if (!buf)
|
||||
return;
|
||||
|
||||
@@ -1221,8 +1221,8 @@ static void cgroup_context_apply(
|
||||
}
|
||||
|
||||
if ((apply_mask & CGROUP_MASK_CPUSET) && !is_local_root) {
|
||||
cgroup_apply_unified_cpuset(u, c->cpuset_cpus, "cpuset.cpus");
|
||||
cgroup_apply_unified_cpuset(u, c->cpuset_mems, "cpuset.mems");
|
||||
cgroup_apply_unified_cpuset(u, &c->cpuset_cpus, "cpuset.cpus");
|
||||
cgroup_apply_unified_cpuset(u, &c->cpuset_mems, "cpuset.mems");
|
||||
}
|
||||
|
||||
/* The 'io' controller attributes are not exported on the host's root cgroup (being a pure cgroup v2
|
||||
|
||||
+1
-1
@@ -116,7 +116,7 @@ static void device_done(Unit *u) {
|
||||
static int device_load(Unit *u) {
|
||||
int r;
|
||||
|
||||
r = unit_load_fragment_and_dropin_optional(u);
|
||||
r = unit_load_fragment_and_dropin(u, false);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
||||
+10
-18
@@ -513,9 +513,7 @@ static int mount_verify(Mount *m) {
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
||||
if (UNIT(m)->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
assert(UNIT(m)->load_state == UNIT_LOADED);
|
||||
|
||||
if (!m->from_fragment && !m->from_proc_self_mountinfo && !UNIT(m)->perpetual)
|
||||
return -ENOENT;
|
||||
@@ -606,11 +604,11 @@ static int mount_add_extras(Mount *m) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mount_load_root_mount(Unit *u) {
|
||||
static void mount_load_root_mount(Unit *u) {
|
||||
assert(u);
|
||||
|
||||
if (!unit_has_name(u, SPECIAL_ROOT_MOUNT))
|
||||
return 0;
|
||||
return;
|
||||
|
||||
u->perpetual = true;
|
||||
u->default_dependencies = false;
|
||||
@@ -621,39 +619,33 @@ static int mount_load_root_mount(Unit *u) {
|
||||
|
||||
if (!u->description)
|
||||
u->description = strdup("Root Mount");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int mount_load(Unit *u) {
|
||||
Mount *m = MOUNT(u);
|
||||
int r, q, w;
|
||||
int r, q = 0;
|
||||
|
||||
assert(u);
|
||||
assert(u->load_state == UNIT_STUB);
|
||||
|
||||
r = mount_load_root_mount(u);
|
||||
mount_load_root_mount(u);
|
||||
|
||||
if (m->from_proc_self_mountinfo || u->perpetual)
|
||||
q = unit_load_fragment_and_dropin_optional(u);
|
||||
else
|
||||
q = unit_load_fragment_and_dropin(u);
|
||||
bool fragment_optional = m->from_proc_self_mountinfo || u->perpetual;
|
||||
r = unit_load_fragment_and_dropin(u, !fragment_optional);
|
||||
|
||||
/* Add in some extras. Note we do this in all cases (even if we failed to load the unit) when announced by the
|
||||
* kernel, because we need some things to be set up no matter what when the kernel establishes a mount and thus
|
||||
* we need to update the state in our unit to track it. After all, consider that we don't allow changing the
|
||||
* 'slice' field for a unit once it is active. */
|
||||
if (u->load_state == UNIT_LOADED || m->from_proc_self_mountinfo || u->perpetual)
|
||||
w = mount_add_extras(m);
|
||||
else
|
||||
w = 0;
|
||||
q = mount_add_extras(m);
|
||||
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (q < 0)
|
||||
return q;
|
||||
if (w < 0)
|
||||
return w;
|
||||
if (u->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
|
||||
return mount_verify(m);
|
||||
}
|
||||
|
||||
+21
-17
@@ -284,9 +284,7 @@ static int path_add_mount_dependencies(Path *p) {
|
||||
|
||||
static int path_verify(Path *p) {
|
||||
assert(p);
|
||||
|
||||
if (UNIT(p)->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
assert(UNIT(p)->load_state == UNIT_LOADED);
|
||||
|
||||
if (!p->specs) {
|
||||
log_unit_error(UNIT(p), "Path unit lacks path setting. Refusing.");
|
||||
@@ -333,6 +331,20 @@ static int path_add_trigger_dependencies(Path *p) {
|
||||
return unit_add_two_dependencies(UNIT(p), UNIT_BEFORE, UNIT_TRIGGERS, x, true, UNIT_DEPENDENCY_IMPLICIT);
|
||||
}
|
||||
|
||||
static int path_add_extras(Path *p) {
|
||||
int r;
|
||||
|
||||
r = path_add_trigger_dependencies(p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = path_add_mount_dependencies(p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return path_add_default_dependencies(p);
|
||||
}
|
||||
|
||||
static int path_load(Unit *u) {
|
||||
Path *p = PATH(u);
|
||||
int r;
|
||||
@@ -340,24 +352,16 @@ static int path_load(Unit *u) {
|
||||
assert(u);
|
||||
assert(u->load_state == UNIT_STUB);
|
||||
|
||||
r = unit_load_fragment_and_dropin(u);
|
||||
r = unit_load_fragment_and_dropin(u, true);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (u->load_state == UNIT_LOADED) {
|
||||
if (u->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
|
||||
r = path_add_trigger_dependencies(p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = path_add_mount_dependencies(p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = path_add_default_dependencies(p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
r = path_add_extras(p);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return path_verify(p);
|
||||
}
|
||||
|
||||
+22
-16
@@ -125,9 +125,7 @@ static int scope_add_default_dependencies(Scope *s) {
|
||||
|
||||
static int scope_verify(Scope *s) {
|
||||
assert(s);
|
||||
|
||||
if (UNIT(s)->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
assert(UNIT(s)->load_state == UNIT_LOADED);
|
||||
|
||||
if (set_isempty(UNIT(s)->pids) &&
|
||||
!MANAGER_IS_RELOADING(UNIT(s)->manager) &&
|
||||
@@ -162,6 +160,20 @@ static int scope_load_init_scope(Unit *u) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int scope_add_extras(Scope *s) {
|
||||
int r;
|
||||
|
||||
r = unit_patch_contexts(UNIT(s));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = unit_set_default_slice(UNIT(s));
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return scope_add_default_dependencies(s);
|
||||
}
|
||||
|
||||
static int scope_load(Unit *u) {
|
||||
Scope *s = SCOPE(u);
|
||||
int r;
|
||||
@@ -176,23 +188,17 @@ static int scope_load(Unit *u) {
|
||||
r = scope_load_init_scope(u);
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = unit_load_fragment_and_dropin_optional(u);
|
||||
|
||||
r = unit_load_fragment_and_dropin(u, false);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (u->load_state == UNIT_LOADED) {
|
||||
r = unit_patch_contexts(u);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (u->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
|
||||
r = unit_set_default_slice(u);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = scope_add_default_dependencies(s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
r = scope_add_extras(s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return scope_verify(s);
|
||||
}
|
||||
|
||||
+7
-24
@@ -548,9 +548,7 @@ static int service_arm_timer(Service *s, usec_t usec) {
|
||||
|
||||
static int service_verify(Service *s) {
|
||||
assert(s);
|
||||
|
||||
if (UNIT(s)->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
assert(UNIT(s)->load_state == UNIT_LOADED);
|
||||
|
||||
if (!s->exec_command[SERVICE_EXEC_START] && !s->exec_command[SERVICE_EXEC_STOP]
|
||||
&& UNIT(s)->success_action == EMERGENCY_ACTION_NONE) {
|
||||
@@ -760,32 +758,17 @@ static int service_load(Unit *u) {
|
||||
Service *s = SERVICE(u);
|
||||
int r;
|
||||
|
||||
assert(s);
|
||||
|
||||
/* Load a .service file */
|
||||
r = unit_load_fragment(u);
|
||||
r = unit_load_fragment_and_dropin(u, true);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* Still nothing found? Then let's give up */
|
||||
if (u->load_state == UNIT_STUB)
|
||||
return -ENOENT;
|
||||
if (u->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
|
||||
/* This is a new unit? Then let's add in some extras */
|
||||
if (u->load_state == UNIT_LOADED) {
|
||||
|
||||
/* We were able to load something, then let's add in
|
||||
* the dropin directories. */
|
||||
r = unit_load_dropin(u);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* This is a new unit? Then let's add in some
|
||||
* extras */
|
||||
r = service_add_extras(s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
r = service_add_extras(s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return service_verify(s);
|
||||
}
|
||||
|
||||
+14
-16
@@ -91,9 +91,7 @@ static int slice_verify(Slice *s) {
|
||||
int r;
|
||||
|
||||
assert(s);
|
||||
|
||||
if (UNIT(s)->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
assert(UNIT(s)->load_state == UNIT_LOADED);
|
||||
|
||||
if (!slice_name_is_valid(UNIT(s)->id)) {
|
||||
log_unit_error(UNIT(s), "Slice name %s is not valid. Refusing.", UNIT(s)->id);
|
||||
@@ -170,25 +168,25 @@ static int slice_load(Unit *u) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = unit_load_fragment_and_dropin_optional(u);
|
||||
r = unit_load_fragment_and_dropin(u, false);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (u->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
|
||||
/* This is a new unit? Then let's add in some extras */
|
||||
if (u->load_state == UNIT_LOADED) {
|
||||
r = unit_patch_contexts(u);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = unit_patch_contexts(u);
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = slice_add_parent_slice(s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = slice_add_parent_slice(s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = slice_add_default_dependencies(s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
r = slice_add_default_dependencies(s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return slice_verify(s);
|
||||
}
|
||||
|
||||
+9
-10
@@ -433,9 +433,7 @@ static const char *socket_find_symlink_target(Socket *s) {
|
||||
|
||||
static int socket_verify(Socket *s) {
|
||||
assert(s);
|
||||
|
||||
if (UNIT(s)->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
assert(UNIT(s)->load_state == UNIT_LOADED);
|
||||
|
||||
if (!s->ports) {
|
||||
log_unit_error(UNIT(s), "Unit has no Listen setting (ListenStream=, ListenDatagram=, ListenFIFO=, ...). Refusing.");
|
||||
@@ -514,16 +512,17 @@ static int socket_load(Unit *u) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = unit_load_fragment_and_dropin(u);
|
||||
r = unit_load_fragment_and_dropin(u, true);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (u->load_state == UNIT_LOADED) {
|
||||
/* This is a new unit? Then let's add in some extras */
|
||||
r = socket_add_extras(s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
if (u->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
|
||||
/* This is a new unit? Then let's add in some extras */
|
||||
r = socket_add_extras(s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return socket_verify(s);
|
||||
}
|
||||
|
||||
+8
-11
@@ -232,8 +232,7 @@ static int swap_verify(Swap *s) {
|
||||
_cleanup_free_ char *e = NULL;
|
||||
int r;
|
||||
|
||||
if (UNIT(s)->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
assert(UNIT(s)->load_state == UNIT_LOADED);
|
||||
|
||||
r = unit_name_from_path(s->what, ".swap", &e);
|
||||
if (r < 0)
|
||||
@@ -340,28 +339,26 @@ static int swap_add_extras(Swap *s) {
|
||||
|
||||
static int swap_load(Unit *u) {
|
||||
Swap *s = SWAP(u);
|
||||
int r, q;
|
||||
int r, q = 0;
|
||||
|
||||
assert(s);
|
||||
assert(u->load_state == UNIT_STUB);
|
||||
|
||||
/* Load a .swap file */
|
||||
if (SWAP(u)->from_proc_swaps)
|
||||
r = unit_load_fragment_and_dropin_optional(u);
|
||||
else
|
||||
r = unit_load_fragment_and_dropin(u);
|
||||
bool fragment_optional = s->from_proc_swaps;
|
||||
r = unit_load_fragment_and_dropin(u, !fragment_optional);
|
||||
|
||||
/* Add in some extras, and do so either when we successfully loaded something or when /proc/swaps is already
|
||||
* active. */
|
||||
/* Add in some extras, and do so either when we successfully loaded something or when /proc/swaps is
|
||||
* already active. */
|
||||
if (u->load_state == UNIT_LOADED || s->from_proc_swaps)
|
||||
q = swap_add_extras(s);
|
||||
else
|
||||
q = 0;
|
||||
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (q < 0)
|
||||
return q;
|
||||
if (u->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
|
||||
return swap_verify(s);
|
||||
}
|
||||
|
||||
+5
-8
@@ -80,18 +80,15 @@ static int target_load(Unit *u) {
|
||||
|
||||
assert(t);
|
||||
|
||||
r = unit_load_fragment_and_dropin(u);
|
||||
r = unit_load_fragment_and_dropin(u, true);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
/* This is a new unit? Then let's add in some extras */
|
||||
if (u->load_state == UNIT_LOADED) {
|
||||
r = target_add_default_dependencies(t);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
if (u->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
/* This is a new unit? Then let's add in some extras */
|
||||
return target_add_default_dependencies(t);
|
||||
}
|
||||
|
||||
static int target_coldplug(Unit *u) {
|
||||
|
||||
+14
-15
@@ -73,9 +73,7 @@ static void timer_done(Unit *u) {
|
||||
|
||||
static int timer_verify(Timer *t) {
|
||||
assert(t);
|
||||
|
||||
if (UNIT(t)->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
assert(UNIT(t)->load_state == UNIT_LOADED);
|
||||
|
||||
if (!t->values && !t->on_clock_change && !t->on_timezone_change) {
|
||||
log_unit_error(UNIT(t), "Timer unit lacks value setting. Refusing.");
|
||||
@@ -178,24 +176,25 @@ static int timer_load(Unit *u) {
|
||||
assert(u);
|
||||
assert(u->load_state == UNIT_STUB);
|
||||
|
||||
r = unit_load_fragment_and_dropin(u);
|
||||
r = unit_load_fragment_and_dropin(u, true);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (u->load_state == UNIT_LOADED) {
|
||||
if (u->load_state != UNIT_LOADED)
|
||||
return 0;
|
||||
|
||||
r = timer_add_trigger_dependencies(t);
|
||||
if (r < 0)
|
||||
return r;
|
||||
/* This is a new unit? Then let's add in some extras */
|
||||
r = timer_add_trigger_dependencies(t);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = timer_setup_persistent(t);
|
||||
if (r < 0)
|
||||
return r;
|
||||
r = timer_setup_persistent(t);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = timer_add_default_dependencies(t);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
r = timer_add_default_dependencies(t);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return timer_verify(t);
|
||||
}
|
||||
|
||||
+11
-33
@@ -1361,7 +1361,7 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
|
||||
}
|
||||
|
||||
/* Common implementation for multiple backends */
|
||||
int unit_load_fragment_and_dropin(Unit *u) {
|
||||
int unit_load_fragment_and_dropin(Unit *u, bool fragment_required) {
|
||||
int r;
|
||||
|
||||
assert(u);
|
||||
@@ -1371,8 +1371,12 @@ int unit_load_fragment_and_dropin(Unit *u) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (u->load_state == UNIT_STUB)
|
||||
return -ENOENT;
|
||||
if (u->load_state == UNIT_STUB) {
|
||||
if (fragment_required)
|
||||
return -ENOENT;
|
||||
|
||||
u->load_state = UNIT_LOADED;
|
||||
}
|
||||
|
||||
/* Load drop-in directory data. If u is an alias, we might be reloading the
|
||||
* target unit needlessly. But we cannot be sure which drops-ins have already
|
||||
@@ -1381,27 +1385,6 @@ int unit_load_fragment_and_dropin(Unit *u) {
|
||||
return unit_load_dropin(unit_follow_merge(u));
|
||||
}
|
||||
|
||||
/* Common implementation for multiple backends */
|
||||
int unit_load_fragment_and_dropin_optional(Unit *u) {
|
||||
int r;
|
||||
|
||||
assert(u);
|
||||
|
||||
/* Same as unit_load_fragment_and_dropin(), but whether
|
||||
* something can be loaded or not doesn't matter. */
|
||||
|
||||
/* Load a .service/.socket/.slice/… file */
|
||||
r = unit_load_fragment(u);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (u->load_state == UNIT_STUB)
|
||||
u->load_state = UNIT_LOADED;
|
||||
|
||||
/* Load drop-in directory data */
|
||||
return unit_load_dropin(unit_follow_merge(u));
|
||||
}
|
||||
|
||||
void unit_add_to_target_deps_queue(Unit *u) {
|
||||
Manager *m = u->manager;
|
||||
|
||||
@@ -1559,16 +1542,11 @@ int unit_load(Unit *u) {
|
||||
u->fragment_mtime = now(CLOCK_REALTIME);
|
||||
}
|
||||
|
||||
if (UNIT_VTABLE(u)->load) {
|
||||
r = UNIT_VTABLE(u)->load(u);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (u->load_state == UNIT_STUB) {
|
||||
r = -ENOENT;
|
||||
r = UNIT_VTABLE(u)->load(u);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
assert(u->load_state != UNIT_STUB);
|
||||
|
||||
if (u->load_state == UNIT_LOADED) {
|
||||
unit_add_to_target_deps_queue(u);
|
||||
|
||||
+1
-2
@@ -670,8 +670,7 @@ int unit_merge_by_name(Unit *u, const char *other);
|
||||
|
||||
Unit *unit_follow_merge(Unit *u) _pure_;
|
||||
|
||||
int unit_load_fragment_and_dropin(Unit *u);
|
||||
int unit_load_fragment_and_dropin_optional(Unit *u);
|
||||
int unit_load_fragment_and_dropin(Unit *u, bool fragment_required);
|
||||
int unit_load(Unit *unit);
|
||||
|
||||
int unit_set_slice(Unit *u, Unit *slice);
|
||||
|
||||
@@ -419,21 +419,17 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
|
||||
int r;
|
||||
|
||||
if (STR_IN_SET(field, "DevicePolicy", "Slice"))
|
||||
|
||||
return bus_append_string(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field,
|
||||
"CPUAccounting", "MemoryAccounting", "IOAccounting", "BlockIOAccounting",
|
||||
"TasksAccounting", "IPAccounting"))
|
||||
|
||||
return bus_append_parse_boolean(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "CPUWeight", "StartupCPUWeight", "IOWeight", "StartupIOWeight"))
|
||||
|
||||
return bus_append_cg_weight_parse(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "CPUShares", "StartupCPUShares"))
|
||||
|
||||
return bus_append_cg_cpu_shares_parse(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "AllowedCPUs", "AllowedMemoryNodes")) {
|
||||
@@ -453,15 +449,12 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
|
||||
}
|
||||
|
||||
if (STR_IN_SET(field, "BlockIOWeight", "StartupBlockIOWeight"))
|
||||
|
||||
return bus_append_cg_blkio_weight_parse(m, field, eq);
|
||||
|
||||
if (streq(field, "DisableControllers"))
|
||||
|
||||
return bus_append_strv(m, "DisableControllers", eq, EXTRACT_UNQUOTE);
|
||||
|
||||
if (streq(field, "Delegate")) {
|
||||
|
||||
r = parse_boolean(eq);
|
||||
if (r < 0)
|
||||
return bus_append_strv(m, "DelegateControllers", eq, EXTRACT_UNQUOTE);
|
||||
@@ -473,7 +466,15 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (STR_IN_SET(field, "MemoryMin", "DefaultMemoryLow", "DefaultMemoryMin", "MemoryLow", "MemoryHigh", "MemoryMax", "MemorySwapMax", "MemoryLimit", "TasksMax")) {
|
||||
if (STR_IN_SET(field, "MemoryMin",
|
||||
"DefaultMemoryLow",
|
||||
"DefaultMemoryMin",
|
||||
"MemoryLow",
|
||||
"MemoryHigh",
|
||||
"MemoryMax",
|
||||
"MemorySwapMax",
|
||||
"MemoryLimit",
|
||||
"TasksMax")) {
|
||||
|
||||
if (isempty(eq) || streq(eq, "infinity")) {
|
||||
r = sd_bus_message_append(m, "(sv)", field, "t", CGROUP_LIMIT_MAX);
|
||||
@@ -505,7 +506,6 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
|
||||
}
|
||||
|
||||
if (streq(field, "CPUQuota")) {
|
||||
|
||||
if (isempty(eq))
|
||||
r = sd_bus_message_append(m, "(sv)", "CPUQuotaPerSecUSec", "t", USEC_INFINITY);
|
||||
else {
|
||||
@@ -540,7 +540,6 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
|
||||
}
|
||||
|
||||
if (streq(field, "DeviceAllow")) {
|
||||
|
||||
if (isempty(eq))
|
||||
r = sd_bus_message_append(m, "(sv)", field, "a(ss)", 0);
|
||||
else {
|
||||
@@ -562,7 +561,6 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
|
||||
}
|
||||
|
||||
if (cgroup_io_limit_type_from_string(field) >= 0 || STR_IN_SET(field, "BlockIOReadBandwidth", "BlockIOWriteBandwidth")) {
|
||||
|
||||
if (isempty(eq))
|
||||
r = sd_bus_message_append(m, "(sv)", field, "a(st)", 0);
|
||||
else {
|
||||
@@ -596,7 +594,6 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
|
||||
}
|
||||
|
||||
if (STR_IN_SET(field, "IODeviceWeight", "BlockIODeviceWeight")) {
|
||||
|
||||
if (isempty(eq))
|
||||
r = sd_bus_message_append(m, "(sv)", field, "a(st)", 0);
|
||||
else {
|
||||
@@ -792,17 +789,13 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons
|
||||
}
|
||||
|
||||
static int bus_append_automount_property(sd_bus_message *m, const char *field, const char *eq) {
|
||||
|
||||
if (streq(field, "Where"))
|
||||
|
||||
return bus_append_string(m, field, eq);
|
||||
|
||||
if (streq(field, "DirectoryMode"))
|
||||
|
||||
return bus_append_parse_mode(m, field, eq);
|
||||
|
||||
if (streq(field, "TimeoutIdleSec"))
|
||||
|
||||
return bus_append_parse_sec_rename(m, field, eq);
|
||||
|
||||
return 0;
|
||||
@@ -818,7 +811,6 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
|
||||
"WorkingDirectory", "RootDirectory", "SyslogIdentifier",
|
||||
"ProtectSystem", "ProtectHome", "SELinuxContext", "RootImage",
|
||||
"RuntimeDirectoryPreserve", "Personality", "KeyringMode", "NetworkNamespacePath"))
|
||||
|
||||
return bus_append_string(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field,
|
||||
@@ -828,7 +820,6 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
|
||||
"DynamicUser", "RemoveIPC", "ProtectKernelTunables", "ProtectKernelModules",
|
||||
"ProtectControlGroups", "MountAPIVFS", "CPUSchedulingResetOnFork", "LockPersonality",
|
||||
"ProtectHostname", "RestrictSUIDSGID"))
|
||||
|
||||
return bus_append_parse_boolean(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field,
|
||||
@@ -836,73 +827,56 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
|
||||
"ReadWritePaths", "ReadOnlyPaths", "InaccessiblePaths",
|
||||
"RuntimeDirectory", "StateDirectory", "CacheDirectory", "LogsDirectory", "ConfigurationDirectory",
|
||||
"SupplementaryGroups", "SystemCallArchitectures"))
|
||||
|
||||
return bus_append_strv(m, field, eq, EXTRACT_UNQUOTE);
|
||||
|
||||
if (STR_IN_SET(field, "SyslogLevel", "LogLevelMax"))
|
||||
|
||||
return bus_append_log_level_from_string(m, field, eq);
|
||||
|
||||
if (streq(field, "SyslogFacility"))
|
||||
|
||||
return bus_append_log_facility_unshifted_from_string(m, field, eq);
|
||||
|
||||
if (streq(field, "SecureBits"))
|
||||
|
||||
return bus_append_secure_bits_from_string(m, field, eq);
|
||||
|
||||
if (streq(field, "CPUSchedulingPolicy"))
|
||||
|
||||
return bus_append_sched_policy_from_string(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "CPUSchedulingPriority", "OOMScoreAdjust"))
|
||||
|
||||
return bus_append_safe_atoi(m, field, eq);
|
||||
|
||||
if (streq(field, "Nice"))
|
||||
|
||||
return bus_append_parse_nice(m, field, eq);
|
||||
|
||||
if (streq(field, "SystemCallErrorNumber"))
|
||||
|
||||
return bus_append_parse_errno(m, field, eq);
|
||||
|
||||
if (streq(field, "IOSchedulingClass"))
|
||||
|
||||
return bus_append_ioprio_class_from_string(m, field, eq);
|
||||
|
||||
if (streq(field, "IOSchedulingPriority"))
|
||||
|
||||
return bus_append_ioprio_parse_priority(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field,
|
||||
"RuntimeDirectoryMode", "StateDirectoryMode", "CacheDirectoryMode",
|
||||
"LogsDirectoryMode", "ConfigurationDirectoryMode", "UMask"))
|
||||
|
||||
return bus_append_parse_mode(m, field, eq);
|
||||
|
||||
if (streq(field, "TimerSlackNSec"))
|
||||
|
||||
return bus_append_parse_nsec(m, field, eq);
|
||||
|
||||
if (streq(field, "LogRateLimitIntervalSec"))
|
||||
|
||||
return bus_append_parse_sec_rename(m, field, eq);
|
||||
|
||||
if (streq(field, "LogRateLimitBurst"))
|
||||
|
||||
return bus_append_safe_atou(m, field, eq);
|
||||
|
||||
if (streq(field, "MountFlags"))
|
||||
|
||||
return bus_append_mount_propagation_flags_from_string(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "Environment", "UnsetEnvironment", "PassEnvironment"))
|
||||
|
||||
return bus_append_strv(m, field, eq, EXTRACT_UNQUOTE|EXTRACT_CUNESCAPE);
|
||||
|
||||
if (streq(field, "EnvironmentFile")) {
|
||||
|
||||
if (isempty(eq))
|
||||
r = sd_bus_message_append(m, "(sv)", "EnvironmentFiles", "a(sb)", 0);
|
||||
else
|
||||
@@ -916,7 +890,6 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
|
||||
}
|
||||
|
||||
if (streq(field, "LogExtraFields")) {
|
||||
|
||||
r = sd_bus_message_open_container(m, 'r', "sv");
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
@@ -1354,7 +1327,6 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
|
||||
}
|
||||
|
||||
static int bus_append_kill_property(sd_bus_message *m, const char *field, const char *eq) {
|
||||
|
||||
if (streq(field, "KillMode"))
|
||||
return bus_append_string(m, field, eq);
|
||||
|
||||
@@ -1370,19 +1342,15 @@ static int bus_append_kill_property(sd_bus_message *m, const char *field, const
|
||||
static int bus_append_mount_property(sd_bus_message *m, const char *field, const char *eq) {
|
||||
|
||||
if (STR_IN_SET(field, "What", "Where", "Options", "Type"))
|
||||
|
||||
return bus_append_string(m, field, eq);
|
||||
|
||||
if (streq(field, "TimeoutSec"))
|
||||
|
||||
return bus_append_parse_sec_rename(m, field, eq);
|
||||
|
||||
if (streq(field, "DirectoryMode"))
|
||||
|
||||
return bus_append_parse_mode(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "SloppyOptions", "LazyUnmount", "ForceUnmount"))
|
||||
|
||||
return bus_append_parse_boolean(m, field, eq);
|
||||
|
||||
return 0;
|
||||
@@ -1392,17 +1360,14 @@ static int bus_append_path_property(sd_bus_message *m, const char *field, const
|
||||
int r;
|
||||
|
||||
if (streq(field, "MakeDirectory"))
|
||||
|
||||
return bus_append_parse_boolean(m, field, eq);
|
||||
|
||||
if (streq(field, "DirectoryMode"))
|
||||
|
||||
return bus_append_parse_mode(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field,
|
||||
"PathExists", "PathExistsGlob", "PathChanged",
|
||||
"PathModified", "DirectoryNotEmpty")) {
|
||||
|
||||
if (isempty(eq))
|
||||
r = sd_bus_message_append(m, "(sv)", "Paths", "a(ss)", 0);
|
||||
else
|
||||
@@ -1422,19 +1387,15 @@ static int bus_append_service_property(sd_bus_message *m, const char *field, con
|
||||
if (STR_IN_SET(field,
|
||||
"PIDFile", "Type", "Restart", "BusName", "NotifyAccess",
|
||||
"USBFunctionDescriptors", "USBFunctionStrings", "OOMPolicy"))
|
||||
|
||||
return bus_append_string(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "PermissionsStartOnly", "RootDirectoryStartOnly", "RemainAfterExit", "GuessMainPID"))
|
||||
|
||||
return bus_append_parse_boolean(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "RestartSec", "TimeoutStartSec", "TimeoutStopSec", "RuntimeMaxSec", "WatchdogSec"))
|
||||
|
||||
return bus_append_parse_sec_rename(m, field, eq);
|
||||
|
||||
if (streq(field, "TimeoutSec")) {
|
||||
|
||||
r = bus_append_parse_sec_rename(m, "TimeoutStartSec", eq);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@@ -1443,7 +1404,6 @@ static int bus_append_service_property(sd_bus_message *m, const char *field, con
|
||||
}
|
||||
|
||||
if (streq(field, "FileDescriptorStoreMax"))
|
||||
|
||||
return bus_append_safe_atou(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field,
|
||||
@@ -1543,60 +1503,47 @@ static int bus_append_socket_property(sd_bus_message *m, const char *field, cons
|
||||
if (STR_IN_SET(field,
|
||||
"Accept", "Writable", "KeepAlive", "NoDelay", "FreeBind", "Transparent", "Broadcast",
|
||||
"PassCredentials", "PassSecurity", "ReusePort", "RemoveOnStop", "SELinuxContextFromNet"))
|
||||
|
||||
return bus_append_parse_boolean(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "Priority", "IPTTL", "Mark"))
|
||||
|
||||
return bus_append_safe_atoi(m, field, eq);
|
||||
|
||||
if (streq(field, "IPTOS"))
|
||||
|
||||
return bus_append_ip_tos_from_string(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "Backlog", "MaxConnections", "MaxConnectionsPerSource", "KeepAliveProbes", "TriggerLimitBurst"))
|
||||
|
||||
return bus_append_safe_atou(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "SocketMode", "DirectoryMode"))
|
||||
|
||||
return bus_append_parse_mode(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "MessageQueueMaxMessages", "MessageQueueMessageSize"))
|
||||
|
||||
return bus_append_safe_atoi64(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "TimeoutSec", "KeepAliveTimeSec", "KeepAliveIntervalSec", "DeferAcceptSec", "TriggerLimitIntervalSec"))
|
||||
|
||||
return bus_append_parse_sec_rename(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "ReceiveBuffer", "SendBuffer", "PipeSize"))
|
||||
|
||||
return bus_append_parse_size(m, field, eq, 1024);
|
||||
|
||||
if (STR_IN_SET(field, "ExecStartPre", "ExecStartPost", "ExecReload", "ExecStopPost"))
|
||||
|
||||
return bus_append_exec_command(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field,
|
||||
"SmackLabel", "SmackLabelIPIn", "SmackLabelIPOut", "TCPCongestion",
|
||||
"BindToDevice", "BindIPv6Only", "FileDescriptorName",
|
||||
"SocketUser", "SocketGroup"))
|
||||
|
||||
return bus_append_string(m, field, eq);
|
||||
|
||||
if (streq(field, "Symlinks"))
|
||||
|
||||
return bus_append_strv(m, field, eq, EXTRACT_UNQUOTE);
|
||||
|
||||
if (streq(field, "SocketProtocol"))
|
||||
|
||||
return bus_append_parse_ip_protocol(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field,
|
||||
"ListenStream", "ListenDatagram", "ListenSequentialPacket", "ListenNetlink",
|
||||
"ListenSpecial", "ListenMessageQueue", "ListenFIFO", "ListenUSBFunction")) {
|
||||
|
||||
if (isempty(eq))
|
||||
r = sd_bus_message_append(m, "(sv)", "Listen", "a(ss)", 0);
|
||||
else
|
||||
@@ -1614,17 +1561,14 @@ static int bus_append_timer_property(sd_bus_message *m, const char *field, const
|
||||
|
||||
if (STR_IN_SET(field, "WakeSystem", "RemainAfterElapse", "Persistent",
|
||||
"OnTimezoneChange", "OnClockChange"))
|
||||
|
||||
return bus_append_parse_boolean(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "AccuracySec", "RandomizedDelaySec"))
|
||||
|
||||
return bus_append_parse_sec_rename(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field,
|
||||
"OnActiveSec", "OnBootSec", "OnStartupSec",
|
||||
"OnUnitActiveSec","OnUnitInactiveSec")) {
|
||||
|
||||
if (isempty(eq))
|
||||
r = sd_bus_message_append(m, "(sv)", "TimersMonotonic", "a(st)", 0);
|
||||
else {
|
||||
@@ -1642,7 +1586,6 @@ static int bus_append_timer_property(sd_bus_message *m, const char *field, const
|
||||
}
|
||||
|
||||
if (streq(field, "OnCalendar")) {
|
||||
|
||||
if (isempty(eq))
|
||||
r = sd_bus_message_append(m, "(sv)", "TimersCalendar", "a(ss)", 0);
|
||||
else
|
||||
@@ -1666,25 +1609,20 @@ static int bus_append_unit_property(sd_bus_message *m, const char *field, const
|
||||
"JobTimeoutAction", "JobTimeoutRebootArgument",
|
||||
"StartLimitAction", "FailureAction", "SuccessAction",
|
||||
"RebootArgument", "CollectMode"))
|
||||
|
||||
return bus_append_string(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field,
|
||||
"StopWhenUnneeded", "RefuseManualStart", "RefuseManualStop",
|
||||
"AllowIsolate", "IgnoreOnIsolate", "DefaultDependencies"))
|
||||
|
||||
return bus_append_parse_boolean(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "JobTimeoutSec", "JobRunningTimeoutSec", "StartLimitIntervalSec"))
|
||||
|
||||
return bus_append_parse_sec_rename(m, field, eq);
|
||||
|
||||
if (streq(field, "StartLimitBurst"))
|
||||
|
||||
return bus_append_safe_atou(m, field, eq);
|
||||
|
||||
if (STR_IN_SET(field, "SuccessActionExitStatus", "FailureActionExitStatus")) {
|
||||
|
||||
if (isempty(eq))
|
||||
r = sd_bus_message_append(m, "(sv)", field, "i", -1);
|
||||
else {
|
||||
@@ -1704,7 +1642,6 @@ static int bus_append_unit_property(sd_bus_message *m, const char *field, const
|
||||
|
||||
if (unit_dependency_from_string(field) >= 0 ||
|
||||
STR_IN_SET(field, "Documentation", "RequiresMountsFor"))
|
||||
|
||||
return bus_append_strv(m, field, eq, EXTRACT_UNQUOTE);
|
||||
|
||||
t = condition_type_from_string(field);
|
||||
|
||||
Reference in New Issue
Block a user