]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
util: cgroup: Fix build on non-cgroup platforms
authorPeter Krempa <pkrempa@redhat.com>
Tue, 8 Jul 2014 15:34:56 +0000 (17:34 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 9 Jul 2014 07:45:36 +0000 (09:45 +0200)
Commit a48f44510098cead629ede9a49ea4e840a28ccca introduced a helper
function to convert cgroup device mode to string. The function was only
conditionally compiled on platforms that support cgroup. This broke the
build when attempting to export the symbol:

  CCLD     libvirt.la
  Cannot export virCgroupGetDevicePermsString: symbol not defined

Move the function out of the ifdef, as it doesn't really depend on the
cgroup code being present.

src/util/vircgroup.c

index 2eaf26592c449829be8fe22db4dbcbc1df59aa8a..1ec12ac56eedeb4e0834ee574f9bca01fd9b0349 100644 (file)
@@ -83,6 +83,44 @@ typedef enum {
 } virCgroupFlags;
 
 
+/**
+ * virCgroupGetDevicePermsString:
+ *
+ * @perms: Bitwise or of VIR_CGROUP_DEVICE permission bits
+ *
+ * Returns string corresponding to the appropriate bits set.
+ */
+const char *
+virCgroupGetDevicePermsString(int perms)
+{
+    if (perms & VIR_CGROUP_DEVICE_READ) {
+        if (perms & VIR_CGROUP_DEVICE_WRITE) {
+            if (perms & VIR_CGROUP_DEVICE_MKNOD)
+                return "rwm";
+            else
+                return "rw";
+        } else {
+            if (perms & VIR_CGROUP_DEVICE_MKNOD)
+                return "rm";
+            else
+                return "r";
+        }
+    } else {
+        if (perms & VIR_CGROUP_DEVICE_WRITE) {
+            if (perms & VIR_CGROUP_DEVICE_MKNOD)
+                return "wm";
+            else
+                return "w";
+        } else {
+            if (perms & VIR_CGROUP_DEVICE_MKNOD)
+                return "m";
+            else
+                return "";
+        }
+    }
+}
+
+
 #ifdef VIR_CGROUP_SUPPORTED
 bool
 virCgroupAvailable(void)
@@ -2623,44 +2661,6 @@ virCgroupDenyAllDevices(virCgroupPtr group)
 }
 
 
-/**
- * virCgroupGetDevicePermsString:
- *
- * @perms: Bitwise or of VIR_CGROUP_DEVICE permission bits
- *
- * Returns string corresponding to the appropriate bits set.
- */
-const char *
-virCgroupGetDevicePermsString(int perms)
-{
-    if (perms & VIR_CGROUP_DEVICE_READ) {
-        if (perms & VIR_CGROUP_DEVICE_WRITE) {
-            if (perms & VIR_CGROUP_DEVICE_MKNOD)
-                return "rwm";
-            else
-                return "rw";
-        } else {
-            if (perms & VIR_CGROUP_DEVICE_MKNOD)
-                return "rm";
-            else
-                return "r";
-        }
-    } else {
-        if (perms & VIR_CGROUP_DEVICE_WRITE) {
-            if (perms & VIR_CGROUP_DEVICE_MKNOD)
-                return "wm";
-            else
-                return "w";
-        } else {
-            if (perms & VIR_CGROUP_DEVICE_MKNOD)
-                return "m";
-            else
-                return "";
-        }
-    }
-}
-
-
 /**
  * virCgroupAllowDevice:
  *