render / rpms / libvirt

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