[libvirt] [PATCH] vircgroupv1: add ifdef around cgroup code

Pavel Hrdina phrdina at redhat.com
Tue Sep 25 13:35:11 UTC 2018


Cgroups are supported only on linux.

Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 src/util/vircgroupv1.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 62a6e5c448..3d05fbd745 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -55,6 +55,8 @@ VIR_ENUM_IMPL(virCgroupV1Controller, VIR_CGROUP_CONTROLLER_LAST,
               "name=systemd");
 
 
+#ifdef VIR_CGROUP_SUPPORTED
+
 /* We're looking for at least one 'cgroup' fs mount,
  * which is *not* a named mount. */
 static bool
@@ -2099,3 +2101,15 @@ virCgroupV1Register(void)
 {
     virCgroupBackendRegister(&virCgroupV1Backend);
 }
+
+#else /* !VIR_CGROUP_SUPPORTED */
+
+void
+virCgroupV1Register(void)
+{
+    virReportSystemError(ENOSYS, "%s",
+                         _("Control groups not supported on this platform"));
+    return -1;
+}
+
+#endif /* !VIR_CGROUP_SUPPORTED */
-- 
2.17.1




More information about the libvir-list mailing list