From: Michel Normand Date: Mon, 13 Jul 2009 21:12:09 +0000 (+0200) Subject: lxc-execute or lxc-start to fail if cgroup not mounted X-Git-Tag: lxc_0_6_3~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2b31f553fab7daa0d62dea9e6e50c7aab2aca0ab;p=thirdparty%2Flxc.git lxc-execute or lxc-start to fail if cgroup not mounted Before this patch a container was able to be started without mounted cgroup. (only a warning was logged) But the lxc-ps is using the /proc//cgroup to identify the lxc container in which pid is running. So to be consistent between all lxc command I force an error if cgroup is not mounted at time of lxc-execute or lxc-start. Signed-off-by: Michel Normand Signed-off-by: Daniel Lezcano --- diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c index a905899a9..bc90b9aea 100644 --- a/src/lxc/cgroup.c +++ b/src/lxc/cgroup.c @@ -75,16 +75,21 @@ int lxc_rename_nsgroup(const char *name, pid_t pid) char oldname[MAXPATHLEN]; char newname[MAXPATHLEN]; char cgroup[MAXPATHLEN]; + int ret; if (get_cgroup_mount(MTAB, cgroup)) { - INFO("cgroup is not mounted"); + ERROR("cgroup is not mounted"); return -1; } snprintf(oldname, MAXPATHLEN, "%s/%d", cgroup, pid); snprintf(newname, MAXPATHLEN, "%s/%s", cgroup, name); - return rename(oldname, newname); + ret = rename(oldname, newname); + if (ret) + SYSERROR("failed to rename cgroup %s->%s", + oldname, newname); + return ret; } int lxc_link_nsgroup(const char *name) @@ -95,7 +100,7 @@ int lxc_link_nsgroup(const char *name) int ret; if (get_cgroup_mount(MTAB, cgroup)) { - INFO("cgroup is not mounted"); + ERROR("cgroup is not mounted"); return -1; } diff --git a/src/lxc/start.c b/src/lxc/start.c index 4e0c3f1d1..037a229f4 100644 --- a/src/lxc/start.c +++ b/src/lxc/start.c @@ -552,7 +552,7 @@ int lxc_spawn(const char *name, struct lxc_handler *handler, char *const argv[]) } if (lxc_rename_nsgroup(name, handler->pid) || lxc_link_nsgroup(name)) - WARN("cgroupfs not found: cgroup disabled"); + goto out_abort; /* Create the network configuration */ if (clone_flags & CLONE_NEWNET &&