On Wed, Sep 26, 2018 at 02:42:51PM +0200, Pavel Hrdina wrote:
Cgroups are supported only on linux.
The commit message is sparse, doesn't mention neither the build fix
motivation, nor the other conditions for building the cgroup code.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
changed in v2:
- define moved to vircgrouppriv.h
- fixed alternative virCgroupV1Register function
As pointed out in my review of v1:
https://www.redhat.com/archives/libvir-list/2018-September/msg01313.html
the tests are only guarded by #ifdef __linux__
I just tried removing the VIR_CGROUP_SUPPORTED constant on v4.7.0
and the cgrouptest fails. So any unreasonable linux platform already has
the tests failing.
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
So this is just an overly verbose way of saying
#if defined(__linux__) with the other conditions being leftovers from
when we tried to build parts of the file on non-Linux.
-
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
This can be just #ifdef __linux__
and we don't need to bother with the rest.
Jano
+
/* 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
--
libvir-list mailing list
libvir-list(a)redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list