|
|
c480ed |
From 2b27d54de68a4581a9b46fe5c399b45c0014fcbd Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <2b27d54de68a4581a9b46fe5c399b45c0014fcbd@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:07:10 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroupv1: fix build on non-linux OSes
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
Cgroups are linux specific and we need to make sure that the code is
|
|
|
c480ed |
compiled only on linux. On different OSes it fails the compilation:
|
|
|
c480ed |
|
|
|
c480ed |
../../src/util/vircgroupv1.c:65:19: error: variable has incomplete type 'struct mntent'
|
|
|
c480ed |
struct mntent entry;
|
|
|
c480ed |
^
|
|
|
c480ed |
../../src/util/vircgroupv1.c:65:12: note: forward declaration of 'struct mntent'
|
|
|
c480ed |
struct mntent entry;
|
|
|
c480ed |
^
|
|
|
c480ed |
../../src/util/vircgroupv1.c:74:12: error: implicit declaration of function 'getmntent_r' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
|
|
|
c480ed |
while (getmntent_r(mounts, &entry, buf, sizeof(buf)) != NULL) {
|
|
|
c480ed |
^
|
|
|
c480ed |
../../src/util/vircgroupv1.c:814:39: error: use of undeclared identifier 'MS_NOSUID'
|
|
|
c480ed |
if (mount("tmpfs", root, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC, opts) < 0) {
|
|
|
c480ed |
^
|
|
|
c480ed |
../../src/util/vircgroupv1.c:814:49: error: use of undeclared identifier 'MS_NODEV'
|
|
|
c480ed |
if (mount("tmpfs", root, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC, opts) < 0) {
|
|
|
c480ed |
^
|
|
|
c480ed |
../../src/util/vircgroupv1.c:814:58: error: use of undeclared identifier 'MS_NOEXEC'
|
|
|
c480ed |
if (mount("tmpfs", root, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC, opts) < 0) {
|
|
|
c480ed |
^
|
|
|
c480ed |
../../src/util/vircgroupv1.c:841:65: error: use of undeclared identifier 'MS_BIND'
|
|
|
c480ed |
if (mount(src, group->legacy[i].mountPoint, "none", MS_BIND,
|
|
|
c480ed |
^
|
|
|
c480ed |
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
(cherry picked from commit 0615c8436ac868889454bee2781b6c9993518597)
|
|
|
c480ed |
|
|
|
c480ed |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
|
c480ed |
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Message-Id: <a1b4d0cfa90a65f5c431a388e6f51be2ab9a7cdd.1561993100.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroupv1.c | 20 +++++++++++++++-----
|
|
|
c480ed |
1 file changed, 15 insertions(+), 5 deletions(-)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
|
|
|
c480ed |
index 482615f3c8..97d108d3ac 100644
|
|
|
c480ed |
--- a/src/util/vircgroupv1.c
|
|
|
c480ed |
+++ b/src/util/vircgroupv1.c
|
|
|
c480ed |
@@ -20,13 +20,11 @@
|
|
|
c480ed |
*/
|
|
|
c480ed |
#include <config.h>
|
|
|
c480ed |
|
|
|
c480ed |
-#if defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R
|
|
|
c480ed |
+#ifdef __linux__
|
|
|
c480ed |
# include <mntent.h>
|
|
|
c480ed |
-#endif
|
|
|
c480ed |
-#include <sys/stat.h>
|
|
|
c480ed |
-#if defined HAVE_SYS_MOUNT_H
|
|
|
c480ed |
+# include <sys/stat.h>
|
|
|
c480ed |
# include <sys/mount.h>
|
|
|
c480ed |
-#endif
|
|
|
c480ed |
+#endif /* __linux__ */
|
|
|
c480ed |
|
|
|
c480ed |
#include "internal.h"
|
|
|
c480ed |
|
|
|
c480ed |
@@ -56,6 +54,8 @@ VIR_ENUM_IMPL(virCgroupV1Controller, VIR_CGROUP_CONTROLLER_LAST,
|
|
|
c480ed |
"name=systemd");
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+#ifdef __linux__
|
|
|
c480ed |
+
|
|
|
c480ed |
/* We're looking for at least one 'cgroup' fs mount,
|
|
|
c480ed |
* which is *not* a named mount. */
|
|
|
c480ed |
static bool
|
|
|
c480ed |
@@ -2100,3 +2100,13 @@ virCgroupV1Register(void)
|
|
|
c480ed |
{
|
|
|
c480ed |
virCgroupBackendRegister(&virCgroupV1Backend);
|
|
|
c480ed |
}
|
|
|
c480ed |
+
|
|
|
c480ed |
+#else /* !__linux__ */
|
|
|
c480ed |
+
|
|
|
c480ed |
+void
|
|
|
c480ed |
+virCgroupV1Register(void)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ VIR_INFO("Control groups not supported on this platform");
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+#endif /* !__linux__ */
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|