[PATCH] util: cgroup: Fix build on non-cgroup platforms

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit 48f44510098cead629ede9a49ea4e840a28ccca introduced a helper
fucntion to convert cgroup device mode to string. The function was only
conditionally compliled 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 | 76 ++++++++++++++++++++++++++--------------------------
 1 file changed, 38 insertions(+), 38 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 2eaf265..1ec12ac 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -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)
@@ -2624,44 +2662,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:
  *
  * @group: The cgroup to allow a device for
-- 
2.0.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]