]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-execute or lxc-start to fail if cgroup not mounted
authorMichel Normand <normand@fr.ibm.com>
Mon, 13 Jul 2009 21:12:09 +0000 (23:12 +0200)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Mon, 13 Jul 2009 21:12:09 +0000 (23:12 +0200)
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/<pid>/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 <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
src/lxc/cgroup.c
src/lxc/start.c

index a905899a9b7ebc1bac41925659000532dc2214ef..bc90b9aeac5643e15d35b40ab9aa44de02971e92 100644 (file)
@@ -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;
        }
 
index 4e0c3f1d19304e44d9a18280e4148bb245ce6613..037a229f4d8f77764fcdb3110fbb1fb7f095acfa 100644 (file)
@@ -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 &&