]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc /cgroup/name/ not removed at container end
authorMichel Normand <normand@fr.ibm.com>
Tue, 3 Nov 2009 10:40:42 +0000 (11:40 +0100)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Tue, 3 Nov 2009 10:40:42 +0000 (11:40 +0100)
this is a side effect of my previous patch
that removed the LXCPATH/name/nsgroup file.
9f44c57836626d8eb16c7bba4a5f5d88db74df01

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/cgroup.c
src/lxc/destroy.c

index 8225ed8df7ad34a039a633959cbb43c0b0fa8801..17abb1654990621d33accc0ae8606ec203e270be 100644 (file)
@@ -120,24 +120,25 @@ int lxc_rename_nsgroup(const char *name, struct lxc_handler *handler)
        return ret;
 }
 
-#warning keep lxc_unlink_nsgroup fct to be able to destroy old created container.
 int lxc_unlink_nsgroup(const char *name)
 {
        char nsgroup[MAXPATHLEN];
-       char path[MAXPATHLEN];
-       ssize_t len;
+       char cgroup[MAXPATHLEN];
+       int ret;
 
-       snprintf(nsgroup, MAXPATHLEN, LXCPATH "/%s/nsgroup", name);
-       
-       len = readlink(nsgroup, path, MAXPATHLEN-1);
-       if (len >  0) {
-               path[len] = '\0';
-               rmdir(path);
+       if (get_cgroup_mount(MTAB, cgroup)) {
+               ERROR("cgroup is not mounted");
+               return -1;
        }
 
-       DEBUG("unlinking '%s'", nsgroup);
+       snprintf(nsgroup, MAXPATHLEN, "%s/%s", cgroup, name);
+       ret = rmdir(nsgroup);
+       if (ret)
+               SYSERROR("failed to remove cgroup '%s'", nsgroup);
+       else
+               DEBUG("'%s' unlinked", nsgroup);
 
-       return unlink(nsgroup);
+       return ret;
 }
 
 int lxc_cgroup_path_get(char **path, const char *name)
index d0e7b52d8f17731dd130e1896509499246ee9cb7..9c75ea03cb8d1b7a6f16a038c21ccdeb5a573f56 100644 (file)
@@ -86,9 +86,12 @@ int lxc_destroy(const char *name)
                goto out_lock;
        }
        
+#warning keep access to LXCPATH/<name> to destroy old created container
        snprintf(path, MAXPATHLEN, LXCPATH "/%s/init", name);
        unlink(path);
-       lxc_unlink_nsgroup(name);
+
+       snprintf(path, MAXPATHLEN, LXCPATH "/%s/nsgroup", name);
+       unlink(path);
 
        if (lxc_unconfigure(name)) {
                ERROR("failed to cleanup %s", name);