summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authormsizanoen1 <msizanoen@qtmlabs.xyz>2022-12-07 16:32:05 +0700
committermsizanoen1 <msizanoen@qtmlabs.xyz>2022-12-08 00:54:53 +0100
commita14137d90e5f50ad8627c85ae94731a5c9948227 (patch)
tree13b02e04255eccc905a8ec1585449f8dd7a3e9a3 /src/core
parentfcb0878f7563df9701a4d066378995c0b7ec32be (diff)
downloadsystemd-a14137d90e5f50ad8627c85ae94731a5c9948227.tar.gz
core/cgroup: thaw slice of unit when thawing unit
This ensures starting a new unit under a frozen slice work as expected.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/cgroup.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/cgroup.c b/src/core/cgroup.c
index 1e9cb758de..9abcfe2b56 100644
--- a/src/core/cgroup.c
+++ b/src/core/cgroup.c
@@ -4175,9 +4175,23 @@ int unit_cgroup_freezer_action(Unit *u, FreezerAction action) {
if (!cg_freezer_supported())
return 0;
+ /* Ignore all requests to thaw init.scope or -.slice and reject all requests to freeze them */
+ if (unit_has_name(u, SPECIAL_ROOT_SLICE) || unit_has_name(u, SPECIAL_INIT_SCOPE))
+ return action == FREEZER_FREEZE ? -EPERM : 0;
+
if (!u->cgroup_realized)
return -EBUSY;
+ if (action == FREEZER_THAW) {
+ Unit *slice = UNIT_GET_SLICE(u);
+
+ if (slice) {
+ r = unit_cgroup_freezer_action(slice, FREEZER_THAW);
+ if (r < 0)
+ return log_unit_error_errno(u, r, "Failed to thaw slice %s of unit: %m", slice->id);
+ }
+ }
+
target = action == FREEZER_FREEZE ? FREEZER_FROZEN : FREEZER_RUNNING;
r = unit_freezer_state_kernel(u, &kernel);