From: Michel Normand Date: Tue, 3 Nov 2009 10:40:42 +0000 (+0100) Subject: lxc /cgroup/name/ not removed at container end X-Git-Tag: lxc_0_6_4~45 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=422afdd240cbeb7216b480080ec00fe09c46fee8;p=thirdparty%2Flxc.git lxc /cgroup/name/ not removed at container end this is a side effect of my previous patch that removed the LXCPATH/name/nsgroup file. 9f44c57836626d8eb16c7bba4a5f5d88db74df01 Signed-off-by: Michel Normand Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c index 8225ed8df..17abb1654 100644 --- a/src/lxc/cgroup.c +++ b/src/lxc/cgroup.c @@ -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) diff --git a/src/lxc/destroy.c b/src/lxc/destroy.c index d0e7b52d8..9c75ea03c 100644 --- a/src/lxc/destroy.c +++ b/src/lxc/destroy.c @@ -86,9 +86,12 @@ int lxc_destroy(const char *name) goto out_lock; } +#warning keep access to LXCPATH/ 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);