]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgfsng: set errno to ENOENT on get_hierarchy() 2646/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Mon, 24 Sep 2018 20:58:45 +0000 (22:58 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 24 Sep 2018 20:58:45 +0000 (22:58 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c
src/lxc/cgroups/cgroup.h
src/lxc/commands.c

index 3df2793778f875e0dbec542596f38f459bb167a8..5475f7eff0f5502ed52b3d99597296ab94544697 100644 (file)
@@ -179,15 +179,19 @@ static void must_append_controller(char **klist, char **nlist, char ***clist,
 /* Given a handler's cgroup data, return the struct hierarchy for the controller
  * @c, or NULL if there is none.
  */
-struct hierarchy *get_hierarchy(struct cgroup_ops *ops, const char *c)
+struct hierarchy *get_hierarchy(struct cgroup_ops *ops, const char *controller)
 {
        int i;
 
-       if (!ops->hierarchies)
+       errno = ENOENT;
+
+       if (!ops->hierarchies) {
+               TRACE("There are no useable cgroup controllers");
                return NULL;
+       }
 
        for (i = 0; ops->hierarchies[i]; i++) {
-               if (!c) {
+               if (!controller) {
                        /* This is the empty unified hierarchy. */
                        if (ops->hierarchies[i]->controllers &&
                            !ops->hierarchies[i]->controllers[0])
@@ -196,10 +200,15 @@ struct hierarchy *get_hierarchy(struct cgroup_ops *ops, const char *c)
                        continue;
                }
 
-               if (string_in_list(ops->hierarchies[i]->controllers, c))
+               if (string_in_list(ops->hierarchies[i]->controllers, controller))
                        return ops->hierarchies[i];
        }
 
+       if (controller)
+               WARN("There is no useable %s controller", controller);
+       else
+               WARN("There is no empty unified cgroup hierarchy");
+
        return NULL;
 }
 
index 16b88094286b8f3b23c8001c5518227a53764f61..292fa1c922b6fe3e507168ae2e72057e070e4772 100644 (file)
@@ -104,6 +104,7 @@ struct cgroup_ops {
         *   hierarchy wins.
         */
        struct hierarchy **hierarchies;
+       /* Pointer to the unified hierarchy. Do not free! */
        struct hierarchy *unified;
 
        /*
index 09379dec9453f6c166361d42ea01614d81b847ce..4d542eb9480e0f98fbf422976ec1baca809f8d84 100644 (file)
@@ -654,7 +654,7 @@ static int lxc_cmd_stop_callback(int fd, struct lxc_cmd_req *req,
                 * lxc_unfreeze() would do another cmd (GET_CGROUP) which would
                 * deadlock us.
                 */
-               if (cgroup_ops->get_cgroup(cgroup_ops, "freezer") == NULL)
+               if (!cgroup_ops->get_cgroup(cgroup_ops, "freezer"))
                        return 0;
 
                if (cgroup_ops->unfreeze(cgroup_ops))