c313de
From 1f5aa6a591ba44492813f5a1a92d0fd2480ae3e7 Mon Sep 17 00:00:00 2001
c313de
Message-Id: <1f5aa6a591ba44492813f5a1a92d0fd2480ae3e7@dist-git>
c313de
From: Pavel Hrdina <phrdina@redhat.com>
c313de
Date: Mon, 1 Jul 2019 17:07:03 +0200
c313de
Subject: [PATCH] vircgroup: extract virCgroupV1(Set|Get)CpusetMems
c313de
MIME-Version: 1.0
c313de
Content-Type: text/plain; charset=UTF-8
c313de
Content-Transfer-Encoding: 8bit
c313de
c313de
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
c313de
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c313de
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c313de
(cherry picked from commit 41510b1b74b9d15a64aaefa83826ddf00c999fe0)
c313de
c313de
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
c313de
c313de
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c313de
Message-Id: <163d30216cc48d77abac54b014faa779c64aa629.1561993100.git.phrdina@redhat.com>
c313de
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c313de
---
c313de
 src/util/vircgroup.c        | 10 ++--------
c313de
 src/util/vircgroupbackend.h | 11 +++++++++++
c313de
 src/util/vircgroupv1.c      | 25 +++++++++++++++++++++++++
c313de
 3 files changed, 38 insertions(+), 8 deletions(-)
c313de
c313de
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
c313de
index 8b14c053e9..700e597157 100644
c313de
--- a/src/util/vircgroup.c
c313de
+++ b/src/util/vircgroup.c
c313de
@@ -1712,10 +1712,7 @@ virCgroupGetMemSwapUsage(virCgroupPtr group, unsigned long long *kb)
c313de
 int
c313de
 virCgroupSetCpusetMems(virCgroupPtr group, const char *mems)
c313de
 {
c313de
-    return virCgroupSetValueStr(group,
c313de
-                                VIR_CGROUP_CONTROLLER_CPUSET,
c313de
-                                "cpuset.mems",
c313de
-                                mems);
c313de
+    VIR_CGROUP_BACKEND_CALL(group, setCpusetMems, -1, mems);
c313de
 }
c313de
 
c313de
 
c313de
@@ -1730,10 +1727,7 @@ virCgroupSetCpusetMems(virCgroupPtr group, const char *mems)
c313de
 int
c313de
 virCgroupGetCpusetMems(virCgroupPtr group, char **mems)
c313de
 {
c313de
-    return virCgroupGetValueStr(group,
c313de
-                                VIR_CGROUP_CONTROLLER_CPUSET,
c313de
-                                "cpuset.mems",
c313de
-                                mems);
c313de
+    VIR_CGROUP_BACKEND_CALL(group, getCpusetMems, -1, mems);
c313de
 }
c313de
 
c313de
 
c313de
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
c313de
index 2c16706c96..35221e90df 100644
c313de
--- a/src/util/vircgroupbackend.h
c313de
+++ b/src/util/vircgroupbackend.h
c313de
@@ -324,6 +324,14 @@ typedef int
c313de
 (*virCgroupGetFreezerStateCB)(virCgroupPtr group,
c313de
                               char **state);
c313de
 
c313de
+typedef int
c313de
+(*virCgroupSetCpusetMemsCB)(virCgroupPtr group,
c313de
+                            const char *mems);
c313de
+
c313de
+typedef int
c313de
+(*virCgroupGetCpusetMemsCB)(virCgroupPtr group,
c313de
+                            char **mems);
c313de
+
c313de
 struct _virCgroupBackend {
c313de
     virCgroupBackendType type;
c313de
 
c313de
@@ -393,6 +401,9 @@ struct _virCgroupBackend {
c313de
 
c313de
     virCgroupSetFreezerStateCB setFreezerState;
c313de
     virCgroupGetFreezerStateCB getFreezerState;
c313de
+
c313de
+    virCgroupSetCpusetMemsCB setCpusetMems;
c313de
+    virCgroupGetCpusetMemsCB getCpusetMems;
c313de
 };
c313de
 typedef struct _virCgroupBackend virCgroupBackend;
c313de
 typedef virCgroupBackend *virCgroupBackendPtr;
c313de
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
c313de
index 7580f8b756..be9a6b82b4 100644
c313de
--- a/src/util/vircgroupv1.c
c313de
+++ b/src/util/vircgroupv1.c
c313de
@@ -1949,6 +1949,28 @@ virCgroupV1GetFreezerState(virCgroupPtr group,
c313de
 }
c313de
 
c313de
 
c313de
+static int
c313de
+virCgroupV1SetCpusetMems(virCgroupPtr group,
c313de
+                         const char *mems)
c313de
+{
c313de
+    return virCgroupSetValueStr(group,
c313de
+                                VIR_CGROUP_CONTROLLER_CPUSET,
c313de
+                                "cpuset.mems",
c313de
+                                mems);
c313de
+}
c313de
+
c313de
+
c313de
+static int
c313de
+virCgroupV1GetCpusetMems(virCgroupPtr group,
c313de
+                         char **mems)
c313de
+{
c313de
+    return virCgroupGetValueStr(group,
c313de
+                                VIR_CGROUP_CONTROLLER_CPUSET,
c313de
+                                "cpuset.mems",
c313de
+                                mems);
c313de
+}
c313de
+
c313de
+
c313de
 virCgroupBackend virCgroupV1Backend = {
c313de
     .type = VIR_CGROUP_BACKEND_TYPE_V1,
c313de
 
c313de
@@ -2016,6 +2038,9 @@ virCgroupBackend virCgroupV1Backend = {
c313de
 
c313de
     .setFreezerState = virCgroupV1SetFreezerState,
c313de
     .getFreezerState = virCgroupV1GetFreezerState,
c313de
+
c313de
+    .setCpusetMems = virCgroupV1SetCpusetMems,
c313de
+    .getCpusetMems = virCgroupV1GetCpusetMems,
c313de
 };
c313de
 
c313de
 
c313de
-- 
c313de
2.22.0
c313de