libvirt/SOURCES/libvirt-vircgroup-extract-virCgroupV1StealPlacement.patch
2021-09-10 11:57:18 +00:00

95 lines
3.1 KiB
Diff

From 6f37c631f12c0e9b7e9fe8ade5b5a98392090cfb Mon Sep 17 00:00:00 2001
Message-Id: <6f37c631f12c0e9b7e9fe8ade5b5a98392090cfb@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 1 Jul 2019 17:06:30 +0200
Subject: [PATCH] vircgroup: extract virCgroupV1StealPlacement
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit 12264c12c819259edeb3e5adb59281906b673ca7)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <5f083ec4400455a10608945377f943a071e36c43.1561993100.git.phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@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 b17a1dcbb7..0e64ad67f4 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1323,8 +1323,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->stealPlacement(init);
virCgroupFree(&init);
if (!path || STREQ(path, "/") || path[0] != '/') {
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
index 086cfb8090..9c0bd89793 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 *
+(*virCgroupStealPlacementCB)(virCgroupPtr group);
+
struct _virCgroupBackend {
virCgroupBackendType type;
@@ -77,6 +80,7 @@ struct _virCgroupBackend {
virCgroupDetectMountsCB detectMounts;
virCgroupDetectPlacementCB detectPlacement;
virCgroupValidatePlacementCB validatePlacement;
+ virCgroupStealPlacementCB stealPlacement;
};
typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr;
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 2c905a832a..446546fd58 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -403,6 +403,17 @@ virCgroupV1ValidatePlacement(virCgroupPtr group,
}
+static char *
+virCgroupV1StealPlacement(virCgroupPtr group)
+{
+ char *ret = NULL;
+
+ VIR_STEAL_PTR(ret, group->controllers[VIR_CGROUP_CONTROLLER_SYSTEMD].placement);
+
+ return ret;
+}
+
+
virCgroupBackend virCgroupV1Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V1,
@@ -413,6 +424,7 @@ virCgroupBackend virCgroupV1Backend = {
.detectMounts = virCgroupV1DetectMounts,
.detectPlacement = virCgroupV1DetectPlacement,
.validatePlacement = virCgroupV1ValidatePlacement,
+ .stealPlacement = virCgroupV1StealPlacement,
};
--
2.22.0