]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Ignore trailing /init.scope in init cgroups
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Thu, 15 Oct 2015 18:56:17 +0000 (18:56 +0000)
committerStéphane Graber <stgraber@ubuntu.com>
Thu, 29 Oct 2015 21:56:27 +0000 (17:56 -0400)
The lxc monitor does not store the container's cgroups, rather it
recalculates them whenever needed.

Systemd moves itself into a /init.scope cgroup for the systemd
controller.

It might be worth changing that (by storing all cgroup info in the
lxc_handler), but for now go the hacky route and chop off any
trailing /init.scope.

I definately thinkg we want to switch to storing as that will be
more bullet-proof, but for now we need a quick backportable fix
for systemd 226 guests.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/cgfs.c
src/lxc/cgmanager.c
src/lxc/cgroup.c
src/lxc/cgroup.h

index df2e6b2333bc81f94bf7583087475fd8d62605a1..d65f2d709e0d934f47908cf628647b90aa2b8e64 100644 (file)
@@ -1220,6 +1220,7 @@ static char *lxc_cgroup_get_hierarchy_path_data(const char *subsystem, struct cg
        info = find_info_for_subsystem(info, subsystem);
        if (!info)
                return NULL;
+       prune_init_scope(info->cgroup_path);
        return info->cgroup_path;
 }
 
index a677c22c768eccccaa3af386c662c43dad8412cf..f8689033bb20c4c06c0d445bded6983c4dafb311 100644 (file)
@@ -776,6 +776,7 @@ static char *try_get_abs_cgroup(const char *name, const char *lxcpath,
                        nerr = nih_error_get();
                        nih_free(nerr);
                }
+               prune_init_scope(cgroup);
                return cgroup;
        }
 
index 2362ad8b393cc6a25f872f35857cf32c02418072..b1c764f2b7083ed4c542b22e56721e93f7ab4f1e 100644 (file)
@@ -194,3 +194,17 @@ cgroup_driver_t cgroup_driver(void)
 {
        return ops->driver;
 }
+
+#define INIT_SCOPE "/init.scope"
+void prune_init_scope(char *cg)
+{
+       char *point = cg + strlen(cg) - strlen(INIT_SCOPE);
+       if (point < cg)
+               return;
+       if (strcmp(point, INIT_SCOPE) == 0) {
+               if (point == cg)
+                       *(point+1) = '\0';
+               else
+                       *point = '\0';
+       }
+}
index 670693991755cc18af0ae0dfb7f602b966a793f9..7704c04d391b8a208bfaa278c19decdd15c05ef8 100644 (file)
@@ -80,4 +80,6 @@ extern bool cgroup_unfreeze(struct lxc_handler *handler);
 extern void cgroup_disconnect(void);
 extern cgroup_driver_t cgroup_driver(void);
 
+extern void prune_init_scope(char *cg);
+
 #endif