Cgroups are supported only on linux.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
changed in v2:
- define moved to vircgrouppriv.h
- fixed alternative virCgroupV1Register function
src/util/vircgroup.c | 5 -----
src/util/vircgrouppriv.h | 8 ++++++++
src/util/vircgroupv1.c | 13 +++++++++++++
3 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 23957c82c7..aae699db0e 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -66,11 +66,6 @@ VIR_LOG_INIT("util.cgroup");
#define CGROUP_NB_TOTAL_CPU_STAT_PARAM 3
#define CGROUP_NB_PER_CPU_STAT_PARAM 1
-#if defined(__linux__) && defined(HAVE_GETMNTENT_R) && \
- defined(_DIRENT_HAVE_D_TYPE) && defined(_SC_CLK_TCK)
-# define VIR_CGROUP_SUPPORTED
-#endif
-
VIR_ENUM_IMPL(virCgroupController, VIR_CGROUP_CONTROLLER_LAST,
"cpu", "cpuacct", "cpuset",
"memory", "devices",
"freezer", "blkio", "net_cls",
"perf_event",
diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h
index c50a25f195..5a19f965c2 100644
--- a/src/util/vircgrouppriv.h
+++ b/src/util/vircgrouppriv.h
@@ -29,9 +29,17 @@
#ifndef __VIR_CGROUP_PRIV_H__
# define __VIR_CGROUP_PRIV_H__
+# include <dirent.h>
+# include <unistd.h>
+
# include "vircgroup.h"
# include "vircgroupbackend.h"
+# if defined(__linux__) && defined(HAVE_GETMNTENT_R) && \
+ defined(_DIRENT_HAVE_D_TYPE) && defined(_SC_CLK_TCK)
+# define VIR_CGROUP_SUPPORTED
+# endif
+
struct _virCgroupV1Controller {
int type;
char *mountPoint;
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 62a6e5c448..a00dd06148 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,14 @@ virCgroupV1Register(void)
{
virCgroupBackendRegister(&virCgroupV1Backend);
}
+
+#else /* !VIR_CGROUP_SUPPORTED */
+
+void
+virCgroupV1Register(void)
+{
+ virReportSystemError(ENOSYS, "%s",
+ _("Control groups not supported on this platform"));
+}
+
+#endif /* !VIR_CGROUP_SUPPORTED */
--
2.17.1