return newname;
}
+static bool is_crucial_hierarchy(struct cgroup_hierarchy *h)
+{
+ char **p;
+
+ for (p = h->subsystems; *p; p++) {
+ if (is_crucial_cgroup_subsystem(*p))
+ return true;
+ }
+ return false;
+}
+
/* create a new cgroup */
static struct cgroup_process_info *lxc_cgroupfs_create(const char *name, const char *path_pattern, struct cgroup_meta_data *meta_data, const char *sub_pattern)
{
current_entire_path = NULL;
goto cleanup_name_on_this_level;
} else if (r < 0 && errno != EEXIST) {
- SYSERROR("Could not create cgroup '%s' in '%s'.", current_entire_path, info_ptr->designated_mount_point->mount_point);
- goto cleanup_from_error;
+ if (is_crucial_hierarchy(info_ptr->hierarchy)) {
+ SYSERROR("Could not create cgroup '%s' in '%s'.", current_entire_path, info_ptr->designated_mount_point->mount_point);
+ goto cleanup_from_error;
+ }
+ goto skip;
} else if (r == 0) {
/* successfully created */
r = lxc_grow_array((void ***)&info_ptr->created_paths, &info_ptr->created_paths_capacity, info_ptr->created_paths_count + 1, 8);
goto cleanup_from_error;
}
+skip:
/* already existed but path component of pattern didn't contain '%n',
* so this is not an error; but then we don't need current_entire_path
* anymore...
r = lxc_write_to_file(cgroup_tasks_fn, pid_buf, strlen(pid_buf), false);
free(cgroup_tasks_fn);
- if (r < 0) {
+ if (r < 0 && is_crucial_hierarchy(info_ptr->hierarchy)) {
SYSERROR("Could not add pid %lu to cgroup %s: internal error", (unsigned long)pid, cgroup_path);
return -1;
}
if (!abs_path)
goto out_error;
r = mount(abs_path, abs_path2, "none", MS_BIND, 0);
- if (r < 0) {
+ if (r < 0 && is_crucial_hierarchy(info->hierarchy)) {
SYSERROR("error bind-mounting %s to %s", abs_path, abs_path2);
goto out_error;
}
continue;
}
r = do_cgfs_chown(cgpath, conf);
- if (!r) {
+ if (!r && is_crucial_hierarchy(info_ptr->hierarchy)) {
ERROR("Failed chowning %s\n", cgpath);
free(cgpath);
return false;
return ret;
}
-/*
- * Return true if this is a subsystem which we cannot do
- * without
- */
-static bool is_crucial_subsys(const char *s)
-{
- if (strcmp(s, "systemd") == 0)
- return true;
- if (strcmp(s, "name=systemd") == 0)
- return true;
- if (strcmp(s, "freezer") == 0)
- return true;
- return false;
-}
-
static char *get_last_controller_in_list(char *list)
{
char *p;
char *p = get_last_controller_in_list(subsystems[i]);
if (!subsys_is_writeable(p, probe)) {
- if (is_crucial_subsys(p)) {
+ if (is_crucial_cgroup_subsystem(p)) {
ERROR("Cannot write to crucial subsystem %s\n",
subsystems[i]);
goto out;