]> xenbits.xensource.com Git - libvirt.git/commitdiff
cgroups: Do not enforce nonexistent controllers
authorViktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Thu, 23 May 2013 13:26:31 +0000 (15:26 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 24 May 2013 10:11:24 +0000 (12:11 +0200)
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: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
src/util/vircgroup.c
tests/vircgrouptest.c

index 51f25f01008d6f135e17321db6c8a910f66ab820..fc0e43062a05c0e753167a987a6a7bf1b39a0dd4 100644 (file)
@@ -368,18 +368,18 @@ static int virCgroupDetect(virCgroupPtr group,
     }
 
     if (controllers >= 0) {
-        VIR_DEBUG("Validating controllers %d", controllers);
+        VIR_DEBUG("Filtering controllers %d", controllers);
         for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
             VIR_DEBUG("Controller '%s' wanted=%s, mount='%s'",
                       virCgroupControllerTypeToString(i),
                       (1 << i) & controllers ? "yes" : "no",
                       NULLSTR(group->controllers[i].mountPoint));
             if (((1 << i) & controllers)) {
-                /* Ensure requested controller is present */
+                /* Remove non-existent controllers  */
                 if (!group->controllers[i].mountPoint) {
-                    VIR_DEBUG("Requested controlled '%s' not mounted",
+                    VIR_DEBUG("Requested controller '%s' not mounted, ignoring",
                               virCgroupControllerTypeToString(i));
-                    return -ENOENT;
+                    controllers &= ~(1 << i);
                 }
             } else {
                 /* Check whether a request to disable a controller
index b00a1871ecc7ff65c21e6cfd0fa1e2b85bb3e5d6..262eb8ba6b1d04c23a0421f92d0cde6ad23bf0bc 100644 (file)
@@ -176,7 +176,7 @@ static int testCgroupNewForDriver(const void *args ATTRIBUTE_UNUSED)
     /* Asking for impossible combination since devices is not mounted */
     if ((rv = virCgroupNewDriver("lxc", true,
                                  (1 << VIR_CGROUP_CONTROLLER_DEVICES),
-                                 &cgroup)) != -ENOENT) {
+                                 &cgroup)) != -ENXIO) {
         fprintf(stderr, "Should not have created LXC cgroup: %d\n", -rv);
         goto cleanup;
     }
@@ -280,7 +280,7 @@ static int testCgroupNewForPartition(const void *args ATTRIBUTE_UNUSED)
     /* Asking for impossible combination since devices is not mounted */
     if ((rv = virCgroupNewPartition("/virtualmachines", true,
                                     (1 << VIR_CGROUP_CONTROLLER_DEVICES),
-                                    &cgroup)) != -ENOENT) {
+                                    &cgroup)) != -ENXIO) {
         fprintf(stderr, "Should not have created /virtualmachines cgroup: %d\n", -rv);
         goto cleanup;
     }