|
Pablo Greco |
40546a |
From 583928aa5c4d1b28304aa6484ad20cd2036407ae Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
40546a |
Message-Id: <583928aa5c4d1b28304aa6484ad20cd2036407ae@dist-git>
|
|
Pablo Greco |
40546a |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Date: Mon, 1 Jul 2019 17:07:29 +0200
|
|
Pablo Greco |
40546a |
Subject: [PATCH] vircgroup: introduce virCgroupV2BindMount
|
|
Pablo Greco |
40546a |
MIME-Version: 1.0
|
|
Pablo Greco |
40546a |
Content-Type: text/plain; charset=UTF-8
|
|
Pablo Greco |
40546a |
Content-Transfer-Encoding: 8bit
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
(cherry picked from commit cda8ed0646d82f95d4424cfadfb9233037b1d815)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Message-Id: <c99f93d93fe7a944219b860a2a76b18303c27479.1561993100.git.phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
Pablo Greco |
40546a |
---
|
|
Pablo Greco |
40546a |
src/util/vircgroupv2.c | 34 ++++++++++++++++++++++++++++++++++
|
|
Pablo Greco |
40546a |
1 file changed, 34 insertions(+)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
|
|
Pablo Greco |
40546a |
index 074e6ec110..90ce660908 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroupv2.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroupv2.c
|
|
Pablo Greco |
40546a |
@@ -21,6 +21,7 @@
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
#ifdef __linux__
|
|
Pablo Greco |
40546a |
# include <mntent.h>
|
|
Pablo Greco |
40546a |
+# include <sys/mount.h>
|
|
Pablo Greco |
40546a |
#endif /* __linux__ */
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
#include "internal.h"
|
|
Pablo Greco |
40546a |
@@ -462,6 +463,38 @@ virCgroupV2HasEmptyTasks(virCgroupPtr cgroup,
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+static int
|
|
Pablo Greco |
40546a |
+virCgroupV2BindMount(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ const char *oldroot,
|
|
Pablo Greco |
40546a |
+ const char *mountopts)
|
|
Pablo Greco |
40546a |
+{
|
|
Pablo Greco |
40546a |
+ VIR_AUTOFREE(char *) opts = NULL;
|
|
Pablo Greco |
40546a |
+ VIR_AUTOFREE(char *) src = NULL;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ VIR_DEBUG("Mounting cgroups at '%s'", group->unified.mountPoint);
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (virFileMakePath(group->unified.mountPoint) < 0) {
|
|
Pablo Greco |
40546a |
+ virReportSystemError(errno, _("Unable to create directory %s"),
|
|
Pablo Greco |
40546a |
+ group->unified.mountPoint);
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (virAsprintf(&opts, "mode=755,size=65536%s", mountopts) < 0)
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (virAsprintf(&src, "%s%s", oldroot, group->unified.mountPoint) < 0)
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (mount(src, group->unified.mountPoint, "none", MS_BIND, NULL) < 0) {
|
|
Pablo Greco |
40546a |
+ virReportSystemError(errno, _("Failed to bind cgroup '%s' on '%s'"),
|
|
Pablo Greco |
40546a |
+ src, group->unified.mountPoint);
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ return 0;
|
|
Pablo Greco |
40546a |
+}
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
virCgroupBackend virCgroupV2Backend = {
|
|
Pablo Greco |
40546a |
.type = VIR_CGROUP_BACKEND_TYPE_V2,
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
@@ -481,6 +514,7 @@ virCgroupBackend virCgroupV2Backend = {
|
|
Pablo Greco |
40546a |
.remove = virCgroupV2Remove,
|
|
Pablo Greco |
40546a |
.addTask = virCgroupV2AddTask,
|
|
Pablo Greco |
40546a |
.hasEmptyTasks = virCgroupV2HasEmptyTasks,
|
|
Pablo Greco |
40546a |
+ .bindMount = virCgroupV2BindMount,
|
|
Pablo Greco |
40546a |
};
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
--
|
|
Pablo Greco |
40546a |
2.22.0
|
|
Pablo Greco |
40546a |
|