On Fri, Mar 04, 2011 at 12:06:26PM +0800, Hu Tao wrote:
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;
IMHO, we should only 'continue' if it was the blkio controller.
All the others should treat mkdir failure as a fatal problem.
Also if we 'continue' we should not set 'rc = -errno'....
}
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;
..then this addition is not required.
}
@@ -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;
}
Again, only do this for the 'blkio' controller and set 'rc'
back to 0 if we are ignoring the error.
Daniel
--
|:
http://berrange.com -o-
http://www.flickr.com/photos/dberrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|:
http://entangle-photo.org -o-
http://live.gnome.org/gtk-vnc :|