Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/util/vircgroup.c | 3 +--
src/util/vircgroupbackend.h | 4 ++++
src/util/vircgroupv1.c | 12 ++++++++++++
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 864dd876b0..ff102e2cb0 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1317,8 +1317,7 @@ virCgroupNewMachineSystemd(const char *name,
&init) < 0)
return -1;
- path = init->controllers[VIR_CGROUP_CONTROLLER_SYSTEMD].placement;
- init->controllers[VIR_CGROUP_CONTROLLER_SYSTEMD].placement = NULL;
+ path = init->backend->getPlacement(init);
virCgroupFree(&init);
if (!path || STREQ(path, "/") || path[0] != '/') {
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
index 086cfb8090..1856164c6b 100644
--- a/src/util/vircgroupbackend.h
+++ b/src/util/vircgroupbackend.h
@@ -66,6 +66,9 @@ typedef int
(*virCgroupValidatePlacementCB)(virCgroupPtr group,
pid_t pid);
+typedef char *
+(*virCgroupGetPlacementCB)(virCgroupPtr group);
+
struct _virCgroupBackend {
virCgroupBackendType type;
@@ -77,6 +80,7 @@ struct _virCgroupBackend {
virCgroupDetectMountsCB detectMounts;
virCgroupDetectPlacementCB detectPlacement;
virCgroupValidatePlacementCB validatePlacement;
+ virCgroupGetPlacementCB getPlacement;
};
typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr;
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 68df323d72..ab8988cd59 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -402,6 +402,17 @@ virCgroupV1ValidatePlacement(virCgroupPtr group,
}
+static char *
+virCgroupV1GetPlacement(virCgroupPtr group)
+{
+ char *ret = NULL;
+
+ ignore_value(VIR_STRDUP(ret,
group->controllers[VIR_CGROUP_CONTROLLER_SYSTEMD].placement));
+
+ return ret;
+}
+
+
virCgroupBackend virCgroupV1Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V1,
@@ -412,6 +423,7 @@ virCgroupBackend virCgroupV1Backend = {
.detectMounts = virCgroupV1DetectMounts,
.detectPlacement = virCgroupV1DetectPlacement,
.validatePlacement = virCgroupV1ValidatePlacement,
+ .getPlacement = virCgroupV1GetPlacement,
};
--
2.17.1