]> git.ipfire.org Git - thirdparty/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)
committerJim Fehlig <jfehlig@suse.com>
Thu, 11 Jul 2013 16:39:45 +0000 (10:39 -0600)
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>
(cherry picked from commit c2cf5f1c2abc81d607abe34bf5dc4c615a9b8b4d)

src/qemu/qemu_cgroup.c
src/util/vircgroup.c

index 5745085c767927913c4750022c021befe099502b..400a2b39b874bb48d37f87ec8d349cfacee37050 100644 (file)
@@ -415,8 +415,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 4abe1b17c7c108b28e17add36031b2bca26253a3..ad5da0271bd499d60437099570e5f0ab00355710 100644 (file)
@@ -1122,8 +1122,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: