]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
Fix failure to detect missing cgroup partitions
authorDaniel P. Berrange <berrange@redhat.com>
Thu, 16 May 2013 17:47:07 +0000 (18:47 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 17 May 2013 09:25:15 +0000 (10:25 +0100)
Change bbe97ae968eba60b71e0066d49f9fc909966d9d6 caused the
QEMU driver to ignore ENOENT errors from cgroups, in order
to cope with missing /proc/cgroups. This is not good though
because many other things can cause ENOENT and should not
be ignored. The callers expect to see ENXIO when cgroups
are not present, so adjust the code to report that errno
when /proc/cgroups is missing

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
src/qemu/qemu_cgroup.c
src/util/vircgroup.c

index aaf94cfd98a00bd3fd8d40c97420bfa76dc1a976..9784f3111a385218537adb183a8a63a646adbace 100644 (file)
@@ -456,8 +456,7 @@ int qemuInitCgroup(virQEMUDriverPtr driver,
         if (rc != 0) {
             if (rc == -ENXIO ||
                 rc == -EPERM ||
-                rc == -EACCES ||
-                rc == -ENOENT) { /* No cgroups mounts == success */
+                rc == -EACCES) { /* No cgroups mounts == success */
                 VIR_DEBUG("No cgroups present/configured/accessible, ignoring error");
                 goto done;
             }
index 5780785c5472f1e47541019e4e44a5c97b5028ac..07ea2c30ef03a4e69e4c528148a97433515dd7d8 100644 (file)
@@ -1110,8 +1110,13 @@ static int virCgroupPartitionNeedsEscaping(const char *path)
         path[0] == '.')
         return 1;
 
-    if (!(fp = fopen("/proc/cgroups", "r")))
+    if (!(fp = fopen("/proc/cgroups", "r"))) {
+        /* The API contract is that we return ENXIO
+         * if cgroups are not available on a host */
+        if (errno == ENOENT)
+            errno = ENXIO;
         return -errno;
+    }
 
     /*
      * Data looks like this: