]> xenbits.xensource.com Git - libvirt.git/commitdiff
Don't return an error on failure to create blkio controller
authorHu Tao <hutao@cn.fujitsu.com>
Mon, 7 Mar 2011 03:49:12 +0000 (11:49 +0800)
committerEric Blake <eblake@redhat.com>
Fri, 18 Mar 2011 22:59:03 +0000 (16:59 -0600)
This patch enables cgroup controllers as much as possible by skipping
the creation of blkio controller when running with old kernels that
doesn't support multi-level directory for blkio controller.

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
src/util/cgroup.c

index 9a41a62dc35082d2cd834b6f2c2e58b27592877e..afe873118a3a79ef2259f214afc07e75bf2382cb 100644 (file)
@@ -527,9 +527,20 @@ static int virCgroupMakeGroup(virCgroupPtr parent, virCgroupPtr group,
         if (access(path, F_OK) != 0) {
             if (!create ||
                 mkdir(path, 0755) < 0) {
-                rc = -errno;
-                VIR_FREE(path);
-                break;
+                /* With a kernel that doesn't support multi-level directory
+                 * for blkio controller, libvirt will fail and disable all
+                 * other controllers even though they are available. So
+                 * treat blkio as unmounted if mkdir fails. */
+                if (i == VIR_CGROUP_CONTROLLER_BLKIO) {
+                    rc = 0;
+                    VIR_FREE(group->controllers[i].mountPoint);
+                    VIR_FREE(path);
+                    continue;
+                } else {
+                    rc = -errno;
+                    VIR_FREE(path);
+                    break;
+                }
             }
             if (group->controllers[VIR_CGROUP_CONTROLLER_CPUSET].mountPoint != NULL &&
                 (i == VIR_CGROUP_CONTROLLER_CPUSET ||