nspawn: drop cgv1 handling; core: drop cgroup agent (#36764)
This commit is contained in:
@@ -868,91 +868,6 @@ int cg_trim_v1_controllers(CGroupMask supported, CGroupMask mask, const char *pa
|
||||
return r;
|
||||
}
|
||||
|
||||
int cg_install_release_agent(const char *controller, const char *agent) {
|
||||
_cleanup_free_ char *fs = NULL, *contents = NULL;
|
||||
const char *sc;
|
||||
int r;
|
||||
|
||||
assert(agent);
|
||||
|
||||
r = cg_unified_controller(controller);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r > 0) /* doesn't apply to unified hierarchy */
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
r = cg_get_path(controller, NULL, "release_agent", &fs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = read_one_line_file(fs, &contents);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
sc = strstrip(contents);
|
||||
if (isempty(sc)) {
|
||||
r = write_string_file(fs, agent, WRITE_STRING_FILE_DISABLE_BUFFER);
|
||||
if (r < 0)
|
||||
return r;
|
||||
} else if (!path_equal(sc, agent))
|
||||
return -EEXIST;
|
||||
|
||||
fs = mfree(fs);
|
||||
r = cg_get_path(controller, NULL, "notify_on_release", &fs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
contents = mfree(contents);
|
||||
r = read_one_line_file(fs, &contents);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
sc = strstrip(contents);
|
||||
if (streq(sc, "0")) {
|
||||
r = write_string_file(fs, "1", WRITE_STRING_FILE_DISABLE_BUFFER);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!streq(sc, "1"))
|
||||
return -EIO;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cg_uninstall_release_agent(const char *controller) {
|
||||
_cleanup_free_ char *fs = NULL;
|
||||
int r;
|
||||
|
||||
r = cg_unified_controller(controller);
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r > 0) /* Doesn't apply to unified hierarchy */
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
r = cg_get_path(controller, NULL, "notify_on_release", &fs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = write_string_file(fs, "0", WRITE_STRING_FILE_DISABLE_BUFFER);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
fs = mfree(fs);
|
||||
|
||||
r = cg_get_path(controller, NULL, "release_agent", &fs);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = write_string_file(fs, "", WRITE_STRING_FILE_DISABLE_BUFFER);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cg_has_legacy(void) {
|
||||
struct statfs fs;
|
||||
|
||||
|
||||
@@ -38,7 +38,4 @@ int cg_migrate_recursive_fallback(const char *cfrom, const char *pfrom, const ch
|
||||
int cg_migrate_v1_controllers(CGroupMask supported, CGroupMask mask, const char *from, cg_migrate_callback_t to_callback, void *userdata);
|
||||
int cg_trim_v1_controllers(CGroupMask supported, CGroupMask mask, const char *path, bool delete_root);
|
||||
|
||||
int cg_install_release_agent(const char *controller, const char *agent);
|
||||
int cg_uninstall_release_agent(const char *controller);
|
||||
|
||||
int cg_has_legacy(void);
|
||||
|
||||
@@ -66,6 +66,21 @@ static bool cgroupfs_recursiveprot_supported(void) {
|
||||
return r > 0;
|
||||
}
|
||||
|
||||
int mount_cgroupfs(const char *path) {
|
||||
assert(path);
|
||||
|
||||
/* Mount a separate cgroupfs instance, taking all options we initial set into account. This is
|
||||
* especially useful when cgroup namespace is *not* employed, since the kernel overrides all
|
||||
* previous options if a new mount is established in initial cgns (c.f.
|
||||
* https://github.com/torvalds/linux/blob/b69bb476dee99d564d65d418e9a20acca6f32c3f/kernel/cgroup/cgroup.c#L1984)
|
||||
*
|
||||
* The options shall be kept in sync with those in mount_table below. */
|
||||
|
||||
return mount_nofollow_verbose(LOG_ERR, "cgroup2", path, "cgroup2",
|
||||
MS_NOSUID|MS_NOEXEC|MS_NODEV,
|
||||
cgroupfs_recursiveprot_supported() ? "nsdelegate,memory_recursiveprot" : "nsdelegate");
|
||||
}
|
||||
|
||||
static const MountPoint mount_table[] = {
|
||||
{ "proc", "/proc", "proc", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV,
|
||||
NULL, MNT_FATAL|MNT_IN_CONTAINER|MNT_FOLLOW_SYMLINK },
|
||||
|
||||
@@ -8,3 +8,5 @@ bool mount_point_ignore(const char *path);
|
||||
|
||||
int mount_setup_early(void);
|
||||
int mount_setup(bool loaded_policy, bool leave_propagation);
|
||||
|
||||
int mount_cgroupfs(const char *path);
|
||||
|
||||
Reference in New Issue
Block a user