Blob Blame History Raw
From 1f5aa6a591ba44492813f5a1a92d0fd2480ae3e7 Mon Sep 17 00:00:00 2001
Message-Id: <1f5aa6a591ba44492813f5a1a92d0fd2480ae3e7@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 1 Jul 2019 17:07:03 +0200
Subject: [PATCH] vircgroup: extract virCgroupV1(Set|Get)CpusetMems
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 41510b1b74b9d15a64aaefa83826ddf00c999fe0)

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <163d30216cc48d77abac54b014faa779c64aa629.1561993100.git.phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 src/util/vircgroup.c        | 10 ++--------
 src/util/vircgroupbackend.h | 11 +++++++++++
 src/util/vircgroupv1.c      | 25 +++++++++++++++++++++++++
 3 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 8b14c053e9..700e597157 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -1712,10 +1712,7 @@ virCgroupGetMemSwapUsage(virCgroupPtr group, unsigned long long *kb)
 int
 virCgroupSetCpusetMems(virCgroupPtr group, const char *mems)
 {
-    return virCgroupSetValueStr(group,
-                                VIR_CGROUP_CONTROLLER_CPUSET,
-                                "cpuset.mems",
-                                mems);
+    VIR_CGROUP_BACKEND_CALL(group, setCpusetMems, -1, mems);
 }
 
 
@@ -1730,10 +1727,7 @@ virCgroupSetCpusetMems(virCgroupPtr group, const char *mems)
 int
 virCgroupGetCpusetMems(virCgroupPtr group, char **mems)
 {
-    return virCgroupGetValueStr(group,
-                                VIR_CGROUP_CONTROLLER_CPUSET,
-                                "cpuset.mems",
-                                mems);
+    VIR_CGROUP_BACKEND_CALL(group, getCpusetMems, -1, mems);
 }
 
 
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
index 2c16706c96..35221e90df 100644
--- a/src/util/vircgroupbackend.h
+++ b/src/util/vircgroupbackend.h
@@ -324,6 +324,14 @@ typedef int
 (*virCgroupGetFreezerStateCB)(virCgroupPtr group,
                               char **state);
 
+typedef int
+(*virCgroupSetCpusetMemsCB)(virCgroupPtr group,
+                            const char *mems);
+
+typedef int
+(*virCgroupGetCpusetMemsCB)(virCgroupPtr group,
+                            char **mems);
+
 struct _virCgroupBackend {
     virCgroupBackendType type;
 
@@ -393,6 +401,9 @@ struct _virCgroupBackend {
 
     virCgroupSetFreezerStateCB setFreezerState;
     virCgroupGetFreezerStateCB getFreezerState;
+
+    virCgroupSetCpusetMemsCB setCpusetMems;
+    virCgroupGetCpusetMemsCB getCpusetMems;
 };
 typedef struct _virCgroupBackend virCgroupBackend;
 typedef virCgroupBackend *virCgroupBackendPtr;
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 7580f8b756..be9a6b82b4 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -1949,6 +1949,28 @@ virCgroupV1GetFreezerState(virCgroupPtr group,
 }
 
 
+static int
+virCgroupV1SetCpusetMems(virCgroupPtr group,
+                         const char *mems)
+{
+    return virCgroupSetValueStr(group,
+                                VIR_CGROUP_CONTROLLER_CPUSET,
+                                "cpuset.mems",
+                                mems);
+}
+
+
+static int
+virCgroupV1GetCpusetMems(virCgroupPtr group,
+                         char **mems)
+{
+    return virCgroupGetValueStr(group,
+                                VIR_CGROUP_CONTROLLER_CPUSET,
+                                "cpuset.mems",
+                                mems);
+}
+
+
 virCgroupBackend virCgroupV1Backend = {
     .type = VIR_CGROUP_BACKEND_TYPE_V1,
 
@@ -2016,6 +2038,9 @@ virCgroupBackend virCgroupV1Backend = {
 
     .setFreezerState = virCgroupV1SetFreezerState,
     .getFreezerState = virCgroupV1GetFreezerState,
+
+    .setCpusetMems = virCgroupV1SetCpusetMems,
+    .getCpusetMems = virCgroupV1GetCpusetMems,
 };
 
 
-- 
2.22.0