}
#define __ISOL_CPUS "/sys/devices/system/cpu/isolated"
-static bool filter_and_set_cpus(char *path, bool am_initialized)
+static bool cg_legacy_filter_and_set_cpus(char *path, bool am_initialized)
{
char *lastslash, *fpath, oldv;
int ret;
* Since the h->base_path is populated by init or ourselves, we know
* it is already initialized.
*/
-static bool handle_cpuset_hierarchy(struct hierarchy *h, char *cgname)
+static bool cg_legacy_handle_cpuset_hierarchy(struct hierarchy *h, char *cgname)
{
char *cgpath, *clonechildrenpath, v, *slash;
}
/* Make sure any isolated cpus are removed from cpuset.cpus. */
- if (!filter_and_set_cpus(cgpath, v == '1')) {
+ if (!cg_legacy_filter_and_set_cpus(cgpath, v == '1')) {
SYSERROR("Failed to remove isolated cpus.");
free(clonechildrenpath);
free(cgpath);
* options. But we simply assume that the mountpoint must be
* /sys/fs/cgroup/controller-list
*/
-static char **get_controllers_on_hybrid_layout(char **klist, char **nlist,
- char *line, int type)
+static char **cg_hybrid_get_controllers(char **klist, char **nlist, char *line,
+ int type)
{
/* the fourth field is /sys/fs/cgroup/comma-delimited-controller-list */
int i;
* Get a copy of the mountpoint from @line, which is a line from
* /proc/self/mountinfo
*/
-static char *get_mountpoint_on_hybrid_layout(char *line)
+static char *cg_hybrid_get_mountpoint(char *line)
{
int i;
char *p2;
* @basecginfo is a copy of /proc/$$/cgroup. Return the current
* cgroup for @controller
*/
-static char *get_current_cgroup(char *basecginfo, char *controller, int type)
+static char *cg_hybrid_get_current_cgroup(char *basecginfo, char *controller, int type)
{
char *p = basecginfo;
}
}
-static void lxc_cgfsng_print_basecg_debuginfo(char *basecginfo, char **klist, char **nlist)
+static void lxc_cgfsng_print_basecg_debuginfo(char *basecginfo, char **klist,
+ char **nlist)
{
int k;
char **it;
* At startup, parse_hierarchies finds all the info we need about
* cgroup mountpoints and current cgroups, and stores it in @d.
*/
-static bool cg_init_hybrid(void)
+static bool cg_hybrid_init(void)
{
int ret;
char *basecginfo;
cgroup_layout = CGROUP_LAYOUT_HYBRID;
}
- controller_list = get_controllers_on_hybrid_layout(klist, nlist, line, type);
+ controller_list = cg_hybrid_get_controllers(klist, nlist, line, type);
if (!controller_list && type == CGROUP_SUPER_MAGIC)
continue;
if (controller_list_is_dup(hierarchies, controller_list))
goto next;
- mountpoint = get_mountpoint_on_hybrid_layout(line);
+ mountpoint = cg_hybrid_get_mountpoint(line);
if (!mountpoint) {
CGFSNG_DEBUG("Failed parsing mountpoint from \"%s\"\n", line);
goto next;
}
if (type == CGROUP_SUPER_MAGIC)
- base_cgroup = get_current_cgroup(basecginfo, controller_list[0], CGROUP_SUPER_MAGIC);
+ base_cgroup = cg_hybrid_get_current_cgroup(basecginfo, controller_list[0], CGROUP_SUPER_MAGIC);
else
- base_cgroup = get_current_cgroup(basecginfo, NULL, CGROUP2_SUPER_MAGIC);
+ base_cgroup = cg_hybrid_get_current_cgroup(basecginfo, NULL, CGROUP2_SUPER_MAGIC);
if (!base_cgroup) {
CGFSNG_DEBUG("Failed to find current cgroup\n");
goto next;
}
/* Get current cgroup from /proc/self/cgroup for the cgroupfs v2 hierarchy. */
-static char *cg_get_current_cgroup_unified(void)
+static char *cg_unified_get_current_cgroup(void)
{
char *basecginfo;
char *base_cgroup;
return copy;
}
-static int cg_init_unified(void)
+static int cg_unified_init(void)
{
int ret;
char *mountpoint, *subtree_path;
if (ret != CGROUP2_SUPER_MAGIC)
return 0;
- base_cgroup = cg_get_current_cgroup_unified();
+ base_cgroup = cg_unified_get_current_cgroup();
if (!base_cgroup)
return -EINVAL;
prune_init_scope(base_cgroup);
}
cgroup_use = must_copy_string(tmp);
- ret = cg_init_unified();
+ ret = cg_unified_init();
if (ret < 0)
return false;
if (ret == CGROUP2_SUPER_MAGIC)
return true;
- return cg_init_hybrid();
+ return cg_hybrid_init();
}
static void *cgfsng_init(struct lxc_handler *handler)
return &cgfsng_ops;
}
-static bool handle_unified_hierarchy(struct hierarchy *h, char *cgname)
+static bool cg_unified_create_cgroup(struct hierarchy *h, char *cgname)
{
char **it;
size_t i, parts_len;
return false;
}
- if (!handle_cpuset_hierarchy(h, cgname)) {
+ if (!cg_legacy_handle_cpuset_hierarchy(h, cgname)) {
ERROR("Failed to handle cgroupfs v1 cpuset controller");
return false;
}
return false;
}
- return handle_unified_hierarchy(h, cgname);
+ return cg_unified_create_cgroup(h, cgname);
}
static void remove_path_for_hierarchy(struct hierarchy *h, char *cgname)
/* mount cgroup-full if requested */
static int mount_cgroup_full(int type, struct hierarchy *h, char *dest,
- char *container_cgroup)
+ char *container_cgroup)
{
if (type < LXC_AUTO_CGROUP_FULL_RO || type > LXC_AUTO_CGROUP_FULL_MIXED)
return 0;
{
if (type >= LXC_AUTO_CGROUP_FULL_RO)
return false;
+
return true;
}
* created, remount controller ro if needed and bindmount the
* cgroupfs onto controll/the/cg/path
*/
-static int
-do_secondstage_mounts_if_needed(int type, struct hierarchy *h,
- char *controllerpath, char *cgpath,
- const char *container_cgroup)
+static int do_secondstage_mounts_if_needed(int type, struct hierarchy *h,
+ char *controllerpath, char *cgpath,
+ const char *container_cgroup)
{
if (type == LXC_AUTO_CGROUP_RO || type == LXC_AUTO_CGROUP_MIXED) {
if (mount(controllerpath, controllerpath, "cgroup", MS_BIND, NULL) < 0) {
if (!d || !d->container_cgroup || !hierarchies)
return -1;
+
path = must_make_path(hierarchies[0]->fullcgpath, NULL);
count = recursive_count_nrtasks(path);
free(path);
return true;
}
-/* TODO: handle the unified cgroup hierarchy */
static int cgfsng_num_hierarchies(void)
{
int i;
return i;
}
-/* TODO: handle the unified cgroup hierarchy */
static bool cgfsng_get_hierarchies(int n, char ***out)
{
int i;
* created when we started the container in the latter case we create our own
* cgroup for the attaching process.
*/
-static int cg_attach_unified(const struct hierarchy *h, const char *name,
- const char *lxcpath, const char *pidstr,
- size_t pidstr_len, const char *controller)
+static int __cg_unified_attach(const struct hierarchy *h, const char *name,
+ const char *lxcpath, const char *pidstr,
+ size_t pidstr_len, const char *controller)
{
int ret;
size_t len;
struct hierarchy *h = hierarchies[i];
if (h->version == CGROUP2_SUPER_MAGIC) {
- ret = cg_attach_unified(h, name, lxcpath, pidstr, len, h->controllers[0]);
+ ret = __cg_unified_attach(h, name, lxcpath, pidstr, len,
+ h->controllers[0]);
if (ret < 0)
return false;
* Called from setup_limits - here we have the container's cgroup_data because
* we created the cgroups
*/
-static int lxc_cgroup_set_data(const char *filename, const char *value, struct cgfsng_handler_data *d)
+static int cg_legacy_set_data(const char *filename, const char *value,
+ struct cgfsng_handler_data *d)
{
char *fullpath, *p;
/* "b|c <2^64-1>:<2^64-1> r|w|m" = 47 chars max */
return ret;
}
-static bool __cgfsng_setup_limits_legacy(void *hdata,
- struct lxc_list *cgroup_settings,
- bool do_devices)
+static bool __cg_legacy_setup_limits(void *hdata,
+ struct lxc_list *cgroup_settings,
+ bool do_devices)
{
struct cgfsng_handler_data *d = hdata;
struct lxc_list *iterator, *sorted_cgroup_settings, *next;
cg = iterator->elem;
if (do_devices == !strncmp("devices", cg->subsystem, 7)) {
- if (lxc_cgroup_set_data(cg->subsystem, cg->value, d)) {
+ if (cg_legacy_set_data(cg->subsystem, cg->value, d)) {
if (do_devices && (errno == EACCES || errno == EPERM)) {
WARN("Error setting %s to %s for %s",
cg->subsystem, cg->value, d->name);
return ret;
}
-static bool __cgfsng_setup_limits_unified(void *hdata,
- struct lxc_list *cgroup_settings)
+static bool __cg_unified_setup_limits(void *hdata,
+ struct lxc_list *cgroup_settings)
{
struct lxc_list *iterator;
struct hierarchy *h = unified;
{
bool bret;
- bret = __cgfsng_setup_limits_legacy(hdata, &conf->cgroup, do_devices);
+ bret = __cg_legacy_setup_limits(hdata, &conf->cgroup, do_devices);
if (!bret)
return false;
- return __cgfsng_setup_limits_unified(hdata, &conf->cgroup2);
+ return __cg_unified_setup_limits(hdata, &conf->cgroup2);
}
static struct cgroup_ops cgfsng_ops = {