if (!UNIT_HAS_CGROUP_CONTEXT(u))
return 0;
+ if (u->freezer_state != FREEZER_RUNNING)
+ return log_unit_error_errno(u, SYNTHETIC_ERRNO(EBUSY), "Cannot realize cgroup for frozen unit.");
+
/* Figure out our cgroup path */
r = unit_pick_cgroup_path(u);
if (r < 0)
if (!cg_freezer_supported())
return 0;
- CGroupRuntime *crt = unit_get_cgroup_runtime(u);
- if (!crt || !crt->cgroup_realized)
- return 0; /* No cgroup = nothing running to freeze */
-
unit_next_freezer_state(u, action, &next, &target);
+ CGroupRuntime *crt = unit_get_cgroup_runtime(u);
+ if (!crt || !crt->cgroup_realized) {
+ /* No realized cgroup = nothing to freeze */
+ u->freezer_state = freezer_state_finish(next);
+ return 0;
+ }
+
r = unit_cgroup_freezer_kernel_state(u, ¤t);
if (r < 0)
return r;