提交 eb21408f 编写于 作者: V Viktor Mihajlovski 提交者: Michal Privoznik

cgroups: Do not enforce nonexistent controllers

Currently, the controllers argument to virCgroupDetect acts both as
a result filter and a required controller specification, which is
a bit overloaded. If both functionalities are needed, it would be
better to have them seperated into a filter and a requirement mask.
The only situation where it is used today is to ensure that only
CPU related controllers are used for the VCPU directories. But here
we clearly do not want to enforce the existence of cpu, cpuacct and
specifically not cpuset at the same time.
This commit changes the semantics of controllers to "filter only".
Should a required mask ever be needed, more work will have to be done.
Signed-off-by: NViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
上级 2a3a725c
...@@ -368,18 +368,18 @@ static int virCgroupDetect(virCgroupPtr group, ...@@ -368,18 +368,18 @@ static int virCgroupDetect(virCgroupPtr group,
} }
if (controllers >= 0) { if (controllers >= 0) {
VIR_DEBUG("Validating controllers %d", controllers); VIR_DEBUG("Filtering controllers %d", controllers);
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) { for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
VIR_DEBUG("Controller '%s' wanted=%s, mount='%s'", VIR_DEBUG("Controller '%s' wanted=%s, mount='%s'",
virCgroupControllerTypeToString(i), virCgroupControllerTypeToString(i),
(1 << i) & controllers ? "yes" : "no", (1 << i) & controllers ? "yes" : "no",
NULLSTR(group->controllers[i].mountPoint)); NULLSTR(group->controllers[i].mountPoint));
if (((1 << i) & controllers)) { if (((1 << i) & controllers)) {
/* Ensure requested controller is present */ /* Remove non-existent controllers */
if (!group->controllers[i].mountPoint) { if (!group->controllers[i].mountPoint) {
VIR_DEBUG("Requested controlled '%s' not mounted", VIR_DEBUG("Requested controller '%s' not mounted, ignoring",
virCgroupControllerTypeToString(i)); virCgroupControllerTypeToString(i));
return -ENOENT; controllers &= ~(1 << i);
} }
} else { } else {
/* Check whether a request to disable a controller /* Check whether a request to disable a controller
......
...@@ -176,7 +176,7 @@ static int testCgroupNewForDriver(const void *args ATTRIBUTE_UNUSED) ...@@ -176,7 +176,7 @@ static int testCgroupNewForDriver(const void *args ATTRIBUTE_UNUSED)
/* Asking for impossible combination since devices is not mounted */ /* Asking for impossible combination since devices is not mounted */
if ((rv = virCgroupNewDriver("lxc", true, if ((rv = virCgroupNewDriver("lxc", true,
(1 << VIR_CGROUP_CONTROLLER_DEVICES), (1 << VIR_CGROUP_CONTROLLER_DEVICES),
&cgroup)) != -ENOENT) { &cgroup)) != -ENXIO) {
fprintf(stderr, "Should not have created LXC cgroup: %d\n", -rv); fprintf(stderr, "Should not have created LXC cgroup: %d\n", -rv);
goto cleanup; goto cleanup;
} }
...@@ -280,7 +280,7 @@ static int testCgroupNewForPartition(const void *args ATTRIBUTE_UNUSED) ...@@ -280,7 +280,7 @@ static int testCgroupNewForPartition(const void *args ATTRIBUTE_UNUSED)
/* Asking for impossible combination since devices is not mounted */ /* Asking for impossible combination since devices is not mounted */
if ((rv = virCgroupNewPartition("/virtualmachines", true, if ((rv = virCgroupNewPartition("/virtualmachines", true,
(1 << VIR_CGROUP_CONTROLLER_DEVICES), (1 << VIR_CGROUP_CONTROLLER_DEVICES),
&cgroup)) != -ENOENT) { &cgroup)) != -ENXIO) {
fprintf(stderr, "Should not have created /virtualmachines cgroup: %d\n", -rv); fprintf(stderr, "Should not have created /virtualmachines cgroup: %d\n", -rv);
goto cleanup; goto cleanup;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册