]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/cgroup: thaw slice of unit when thawing unit
authormsizanoen1 <msizanoen@qtmlabs.xyz>
Wed, 7 Dec 2022 09:32:05 +0000 (16:32 +0700)
committermsizanoen1 <msizanoen@qtmlabs.xyz>
Wed, 7 Dec 2022 23:54:53 +0000 (00:54 +0100)
This ensures starting a new unit under a frozen slice work as expected.

src/core/cgroup.c

index 1e9cb758de93a12340336419f5672ba26fb9efa7..9abcfe2b56bd34d84a5c2bc728b175049dd99848 100644 (file)
@@ -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);