The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxcfs/pull/183

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Christian Brauner <[email protected]>
From 51c7ca35d2646d452da3e3db7c6292bec5492e27 Mon Sep 17 00:00:00 2001
From: Christian Brauner <[email protected]>
Date: Wed, 17 May 2017 12:11:20 +0200
Subject: [PATCH] bindings: add mountpoint for unified hierarchy

Signed-off-by: Christian Brauner <[email protected]>
---
 bindings.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/bindings.c b/bindings.c
index 6387012..5b5860e 100644
--- a/bindings.c
+++ b/bindings.c
@@ -4383,11 +4383,13 @@ static bool cgfs_mount_hierarchies(void)
 
        for (i = 0; i < num_hierarchies; i++) {
                char *controller = hierarchies[i];
+
                clen = strlen(controller);
                len = strlen(BASEDIR) + clen + 2;
                target = malloc(len);
                if (!target)
                        return false;
+
                ret = snprintf(target, len, "%s/%s", BASEDIR, controller);
                if (ret < 0 || ret >= len) {
                        free(target);
@@ -4397,8 +4399,12 @@ static bool cgfs_mount_hierarchies(void)
                        free(target);
                        return false;
                }
-               if (mount(controller, target, "cgroup", 0, controller) < 0) {
-                       lxcfs_error("Failed mounting cgroup %s\n", controller);
+               if (!strcmp(controller, "unified"))
+                       ret = mount("none", target, "cgroup2", 0, NULL);
+               else
+                       ret = mount(controller, target, "cgroup", 0, 
controller);
+               if (ret < 0) {
+                       lxcfs_error("Failed mounting cgroup %s: %s\n", 
controller, strerror(errno));
                        free(target);
                        return false;
                }
@@ -4449,6 +4455,7 @@ static void __attribute__((constructor)) 
collect_and_mount_subsystems(void)
        char cwd[MAXPATHLEN];
        size_t len = 0;
        int i, init_ns = -1;
+       bool found_unified = false;
 
        if ((f = fopen("/proc/self/cgroup", "r")) == NULL) {
                lxcfs_error("Error opening /proc/self/cgroup: %s\n", 
strerror(errno));
@@ -4456,11 +4463,12 @@ static void __attribute__((constructor)) 
collect_and_mount_subsystems(void)
        }
 
        while (getline(&line, &len, f) != -1) {
-               char *p, *p2;
+               char *idx, *p, *p2;
 
                p = strchr(line, ':');
                if (!p)
                        goto out;
+               idx = line;
                *(p++) = '\0';
 
                p2 = strrchr(p, ':');
@@ -4473,8 +4481,10 @@ static void __attribute__((constructor)) 
collect_and_mount_subsystems(void)
                 * because it parses out the empty string "" and later on passes
                 * it to mount(). Let's skip such entries.
                 */
-               if (!strcmp(p, ""))
-                       continue;
+               if (!strcmp(p, "") && !strcmp(idx, "0") && !found_unified) {
+                       found_unified = true;
+                       p = "unified";
+               }
 
                if (!store_hierarchy(line, p))
                        goto out;
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to