If any cgroup controller is not avaiable, libvirt disables other
controllers as well although they are avaiable. This patch enables
cgroup controllers as much as possible.
the kernel shipped with RHEL6 doesn't support mutli-level directory
for blkio controller, this causes all other controllers disabled by
libvirt and virsh memtune, schedinfo doesn't work.
Signed-off-by: Hu Tao <hutao(a)cn.fujitsu.com>
---
src/util/cgroup.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/util/cgroup.c b/src/util/cgroup.c
index c5b8cdd..30b6dd8 100644
--- a/src/util/cgroup.c
+++ b/src/util/cgroup.c
@@ -507,6 +507,7 @@ static int virCgroupMakeGroup(virCgroupPtr parent, virCgroupPtr
group,
{
int i;
int rc = 0;
+ int n = 0;
VIR_DEBUG("Make group %s", group->path);
for (i = 0 ; i < VIR_CGROUP_CONTROLLER_LAST ; i++) {
@@ -529,7 +530,7 @@ static int virCgroupMakeGroup(virCgroupPtr parent, virCgroupPtr
group,
mkdir(path, 0755) < 0) {
rc = -errno;
VIR_FREE(path);
- break;
+ continue;
}
if (group->controllers[VIR_CGROUP_CONTROLLER_CPUSET].mountPoint != NULL
&&
(i == VIR_CGROUP_CONTROLLER_CPUSET ||
@@ -556,9 +557,12 @@ static int virCgroupMakeGroup(virCgroupPtr parent, virCgroupPtr
group,
}
}
+ n++;
VIR_FREE(path);
}
+ if (n > 0)
+ return 0;
return rc;
}
@@ -743,6 +747,7 @@ int virCgroupRemove(virCgroupPtr group)
int virCgroupAddTask(virCgroupPtr group, pid_t pid)
{
int rc = 0;
+ int n = 0;
int i;
for (i = 0 ; i < VIR_CGROUP_CONTROLLER_LAST ; i++) {
@@ -752,9 +757,12 @@ int virCgroupAddTask(virCgroupPtr group, pid_t pid)
rc = virCgroupSetValueU64(group, i, "tasks", (unsigned long long)pid);
if (rc != 0)
- break;
+ continue;
+ n++;
}
+ if (n > 0)
+ return 0;
return rc;
}
--
1.7.3.1