Skip to content

Commit

Permalink
cgroup: add support for unified cgroup v2
Browse files Browse the repository at this point in the history
add support for: opencontainers/runtime-spec#1040

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Aug 17, 2020
1 parent 545fa78 commit 02b876a
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/libcrun/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -2828,6 +2828,26 @@ update_cgroup_v2_resources (runtime_spec_schema_config_linux_resources *resource
return ret;
}

/* Write unified resources if any. They have higher precedence and override any previous setting. */
if (resources->unified)
{
size_t i;

for (i = 0; i < resources->unified->len; i++)
{
size_t len;

if (strchr (resources->unified->keys[i], '/'))
return crun_make_error (err, 0, "key `%s` must be a file name without any slash", resources->unified->keys[i]);

len = strlen (resources->unified->values[i]);
ret = write_file_at (cgroup_dirfd, resources->unified->keys[i], resources->unified->values[i], len, err);
if (UNLIKELY (ret < 0))
return ret;
}

}

return 0;
}

Expand Down

0 comments on commit 02b876a

Please sign in to comment.