]> git.proxmox.com Git - mirror_lxc.git/commitdiff
cgroups: add DEFAULT_MOUNTPOINT #define
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 3 Dec 2019 00:24:55 +0000 (01:24 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 3 Dec 2019 14:37:53 +0000 (15:37 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c
src/lxc/cgroups/cgroup.h

index 306530097f9d2badf6078ae1bb13e3b6a63778bd..e3f435d1f229b919c634ad9ad6c309af5605cd7c 100644 (file)
@@ -742,8 +742,8 @@ static char **cg_hybrid_get_controllers(char **klist, char **nlist, char *line,
        /* Note, if we change how mountinfo works, then our caller will need to
         * verify /sys/fs/cgroup/ in this field.
         */
-       if (strncmp(p, "/sys/fs/cgroup/", 15) != 0) {
-               ERROR("Found hierarchy not under /sys/fs/cgroup: \"%s\"", p);
+       if (strncmp(p, DEFAULT_CGROUP_MOUNTPOINT "/", 15) != 0) {
+               ERROR("Found hierarchy not under " DEFAULT_CGROUP_MOUNTPOINT ": \"%s\"", p);
                return NULL;
        }
 
@@ -844,7 +844,7 @@ static char *cg_hybrid_get_mountpoint(char *line)
                p++;
        }
 
-       if (strncmp(p, "/sys/fs/cgroup/", 15) != 0)
+       if (strncmp(p, DEFAULT_CGROUP_MOUNTPOINT "/", 15) != 0)
                return NULL;
 
        p2 = strchr(p + 15, ' ');
@@ -1811,7 +1811,7 @@ __cgfsng_ops static bool cgfsng_mount(struct cgroup_ops *ops,
        else if (type == LXC_AUTO_CGROUP_FULL_NOSPEC)
                type = LXC_AUTO_CGROUP_FULL_MIXED;
 
-       cgroup_root = must_make_path(root, "/sys/fs/cgroup", NULL);
+       cgroup_root = must_make_path(root, DEFAULT_CGROUP_MOUNTPOINT, NULL);
        if (ops->cgroup_layout == CGROUP_LAYOUT_UNIFIED) {
                if (has_cgns && wants_force_mount) {
                        /* If cgroup namespaces are supported but the container
@@ -2953,7 +2953,7 @@ static int cg_is_pure_unified(void)
        int ret;
        struct statfs fs;
 
-       ret = statfs("/sys/fs/cgroup", &fs);
+       ret = statfs(DEFAULT_CGROUP_MOUNTPOINT, &fs);
        if (ret < 0)
                return -ENOMEDIUM;
 
@@ -3019,7 +3019,7 @@ static int cg_unified_init(struct cgroup_ops *ops, bool relative,
         * further down the hierarchy. If not it is up to the user to delegate
         * them to us.
         */
-       mountpoint = must_copy_string("/sys/fs/cgroup");
+       mountpoint = must_copy_string(DEFAULT_CGROUP_MOUNTPOINT);
        subtree_path = must_make_path(mountpoint, base_cgroup,
                                      "cgroup.subtree_control", NULL);
        delegatable = cg_unified_get_controllers(subtree_path);
index a3eb46b9d6937fe2576b0c132a796e30aeaef9a0..6c875b2a6e402b9e7621f9f897b866bde99c73ac 100644 (file)
@@ -28,6 +28,7 @@
 #include <stddef.h>
 #include <sys/types.h>
 
+#define DEFAULT_CGROUP_MOUNTPOINT "/sys/fs/cgroup"
 #define PAYLOAD_CGROUP "lxc.payload"
 #define MONITOR_CGROUP "lxc.monitor"
 #define PIVOT_CGROUP "lxc.pivot"
@@ -92,6 +93,8 @@ struct hierarchy {
        char *container_full_path;
        char *monitor_full_path;
        int version;
+
+       /* cgroup2 only */
        int bpf_device_controller:1;
 };