render / rpms / libvirt

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