]> 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>
Fri, 6 Nov 2015 22:34:51 +0000 (17:34 -0500)
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 23e889c31f21aa870f5476d15d3c2049e7d93237..1c7cb98219d5adb2452c37cec1e6848059ac0f0b 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 0f79ffb8fbbb32675f430fb6cb5afeaff1887113..922f1e2c3d134ebdc716accf2168c8be19e2354d 100644 (file)
@@ -767,6 +767,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 63a2ad4defb289927c8d127cfc32098cacff4b06..c11346d4934550fde20e3685628e1b1487e1b41e 100644 (file)
@@ -173,3 +173,17 @@ void cgroup_disconnect(void)
        if (ops && ops->disconnect)
                ops->disconnect();
 }
+
+#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 7e033702f9c3c1cf89afe5068a767c91cd7bf9e6..fe9c805ebf0c8232f7c8f60880e6aa61d97fa4ba 100644 (file)
@@ -67,4 +67,6 @@ extern const char *cgroup_get_cgroup(struct lxc_handler *handler, const char *su
 extern bool cgroup_unfreeze(struct lxc_handler *handler);
 extern void cgroup_disconnect(void);
 
+extern void prune_init_scope(char *cg);
+
 #endif