|
Pablo Greco |
40546a |
From ac37b7c9693d27c9c20f87b3fd077bf55ac1d34f Mon Sep 17 00:00:00 2001
|
|
Pablo Greco |
40546a |
Message-Id: <ac37b7c9693d27c9c20f87b3fd077bf55ac1d34f@dist-git>
|
|
Pablo Greco |
40546a |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Date: Mon, 1 Jul 2019 17:06:26 +0200
|
|
Pablo Greco |
40546a |
Subject: [PATCH] vircgroup: extract virCgroupV1CopyMounts
|
|
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 |
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
|
|
Pablo Greco |
40546a |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
Pablo Greco |
40546a |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
(cherry picked from commit 47941ea7f52be44f609a6b6acc8895644039e617)
|
|
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: <b833625dd800eee0c3aac96f120ca27dae81ce89.1561993100.git.phrdina@redhat.com>
|
|
Pablo Greco |
40546a |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
Pablo Greco |
40546a |
---
|
|
Pablo Greco |
40546a |
src/util/vircgroup.c | 23 +----------------------
|
|
Pablo Greco |
40546a |
src/util/vircgroupbackend.h | 5 +++++
|
|
Pablo Greco |
40546a |
src/util/vircgroupv1.c | 22 ++++++++++++++++++++++
|
|
Pablo Greco |
40546a |
3 files changed, 28 insertions(+), 22 deletions(-)
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
index 6825623478..9d644d37d1 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroup.c
|
|
Pablo Greco |
40546a |
@@ -235,27 +235,6 @@ virCgroupPartitionEscape(char **path)
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
-static int
|
|
Pablo Greco |
40546a |
-virCgroupCopyMounts(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
- virCgroupPtr parent)
|
|
Pablo Greco |
40546a |
-{
|
|
Pablo Greco |
40546a |
- size_t i;
|
|
Pablo Greco |
40546a |
- for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
Pablo Greco |
40546a |
- if (!parent->controllers[i].mountPoint)
|
|
Pablo Greco |
40546a |
- continue;
|
|
Pablo Greco |
40546a |
-
|
|
Pablo Greco |
40546a |
- if (VIR_STRDUP(group->controllers[i].mountPoint,
|
|
Pablo Greco |
40546a |
- parent->controllers[i].mountPoint) < 0)
|
|
Pablo Greco |
40546a |
- return -1;
|
|
Pablo Greco |
40546a |
-
|
|
Pablo Greco |
40546a |
- if (VIR_STRDUP(group->controllers[i].linkPoint,
|
|
Pablo Greco |
40546a |
- parent->controllers[i].linkPoint) < 0)
|
|
Pablo Greco |
40546a |
- return -1;
|
|
Pablo Greco |
40546a |
- }
|
|
Pablo Greco |
40546a |
- return 0;
|
|
Pablo Greco |
40546a |
-}
|
|
Pablo Greco |
40546a |
-
|
|
Pablo Greco |
40546a |
-
|
|
Pablo Greco |
40546a |
static int
|
|
Pablo Greco |
40546a |
virCgroupResolveMountLink(const char *mntDir,
|
|
Pablo Greco |
40546a |
const char *typeStr,
|
|
Pablo Greco |
40546a |
@@ -653,7 +632,7 @@ virCgroupDetect(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
if (parent) {
|
|
Pablo Greco |
40546a |
- if (virCgroupCopyMounts(group, parent) < 0)
|
|
Pablo Greco |
40546a |
+ if (group->backend->copyMounts(group, parent) < 0)
|
|
Pablo Greco |
40546a |
return -1;
|
|
Pablo Greco |
40546a |
} else {
|
|
Pablo Greco |
40546a |
if (virCgroupDetectMounts(group) < 0)
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
|
|
Pablo Greco |
40546a |
index daf47bac09..81ee597fc8 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroupbackend.h
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroupbackend.h
|
|
Pablo Greco |
40546a |
@@ -41,12 +41,17 @@ typedef bool
|
|
Pablo Greco |
40546a |
const char *drivername,
|
|
Pablo Greco |
40546a |
const char *machinename);
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+typedef int
|
|
Pablo Greco |
40546a |
+(*virCgroupCopyMountsCB)(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ virCgroupPtr parent);
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
struct _virCgroupBackend {
|
|
Pablo Greco |
40546a |
virCgroupBackendType type;
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
/* Mandatory callbacks that need to be implemented for every backend. */
|
|
Pablo Greco |
40546a |
virCgroupAvailableCB available;
|
|
Pablo Greco |
40546a |
virCgroupValidateMachineGroupCB validateMachineGroup;
|
|
Pablo Greco |
40546a |
+ virCgroupCopyMountsCB copyMounts;
|
|
Pablo Greco |
40546a |
};
|
|
Pablo Greco |
40546a |
typedef struct _virCgroupBackend virCgroupBackend;
|
|
Pablo Greco |
40546a |
typedef virCgroupBackend *virCgroupBackendPtr;
|
|
Pablo Greco |
40546a |
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
|
|
Pablo Greco |
40546a |
index b78cdcab53..50b58ab413 100644
|
|
Pablo Greco |
40546a |
--- a/src/util/vircgroupv1.c
|
|
Pablo Greco |
40546a |
+++ b/src/util/vircgroupv1.c
|
|
Pablo Greco |
40546a |
@@ -160,11 +160,33 @@ virCgroupV1ValidateMachineGroup(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
}
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
+static int
|
|
Pablo Greco |
40546a |
+virCgroupV1CopyMounts(virCgroupPtr group,
|
|
Pablo Greco |
40546a |
+ virCgroupPtr parent)
|
|
Pablo Greco |
40546a |
+{
|
|
Pablo Greco |
40546a |
+ size_t i;
|
|
Pablo Greco |
40546a |
+ for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
Pablo Greco |
40546a |
+ if (!parent->controllers[i].mountPoint)
|
|
Pablo Greco |
40546a |
+ continue;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (VIR_STRDUP(group->controllers[i].mountPoint,
|
|
Pablo Greco |
40546a |
+ parent->controllers[i].mountPoint) < 0)
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+ if (VIR_STRDUP(group->controllers[i].linkPoint,
|
|
Pablo Greco |
40546a |
+ parent->controllers[i].linkPoint) < 0)
|
|
Pablo Greco |
40546a |
+ return -1;
|
|
Pablo Greco |
40546a |
+ }
|
|
Pablo Greco |
40546a |
+ return 0;
|
|
Pablo Greco |
40546a |
+}
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
+
|
|
Pablo Greco |
40546a |
virCgroupBackend virCgroupV1Backend = {
|
|
Pablo Greco |
40546a |
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
.available = virCgroupV1Available,
|
|
Pablo Greco |
40546a |
.validateMachineGroup = virCgroupV1ValidateMachineGroup,
|
|
Pablo Greco |
40546a |
+ .copyMounts = virCgroupV1CopyMounts,
|
|
Pablo Greco |
40546a |
};
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
|
|
Pablo Greco |
40546a |
--
|
|
Pablo Greco |
40546a |
2.22.0
|
|
Pablo Greco |
40546a |
|