render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c480ed
From e8af2c7b172894ae3cfacd6de98b01af63947b05 Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <e8af2c7b172894ae3cfacd6de98b01af63947b05@dist-git>
c480ed
From: Pavel Hrdina <phrdina@redhat.com>
c480ed
Date: Mon, 1 Jul 2019 17:07:04 +0200
c480ed
Subject: [PATCH] vircgroup: extract virCgroupV1(Set|Get)CpusetMemoryMigrate
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 7f3aedacac33fd4775d7def3734422108d6cd93e)
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: <0067ed0a20d90451ab63112dc273ddb8344569ca.1561993100.git.phrdina@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 src/util/vircgroup.c        | 13 ++-----------
c480ed
 src/util/vircgroupbackend.h | 10 ++++++++++
c480ed
 src/util/vircgroupv1.c      | 27 +++++++++++++++++++++++++++
c480ed
 3 files changed, 39 insertions(+), 11 deletions(-)
c480ed
c480ed
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
c480ed
index 700e597157..1a5ed472df 100644
c480ed
--- a/src/util/vircgroup.c
c480ed
+++ b/src/util/vircgroup.c
c480ed
@@ -1742,10 +1742,7 @@ virCgroupGetCpusetMems(virCgroupPtr group, char **mems)
c480ed
 int
c480ed
 virCgroupSetCpusetMemoryMigrate(virCgroupPtr group, bool migrate)
c480ed
 {
c480ed
-    return virCgroupSetValueStr(group,
c480ed
-                                VIR_CGROUP_CONTROLLER_CPUSET,
c480ed
-                                "cpuset.memory_migrate",
c480ed
-                                migrate ? "1" : "0");
c480ed
+    VIR_CGROUP_BACKEND_CALL(group, setCpusetMemoryMigrate, -1, migrate);
c480ed
 }
c480ed
 
c480ed
 
c480ed
@@ -1760,13 +1757,7 @@ virCgroupSetCpusetMemoryMigrate(virCgroupPtr group, bool migrate)
c480ed
 int
c480ed
 virCgroupGetCpusetMemoryMigrate(virCgroupPtr group, bool *migrate)
c480ed
 {
c480ed
-    unsigned long long value = 0;
c480ed
-    int ret = virCgroupGetValueU64(group,
c480ed
-                                   VIR_CGROUP_CONTROLLER_CPUSET,
c480ed
-                                   "cpuset.memory_migrate",
c480ed
-                                   &value);
c480ed
-    *migrate = !!value;
c480ed
-    return ret;
c480ed
+    VIR_CGROUP_BACKEND_CALL(group, getCpusetMemoryMigrate, -1, migrate);
c480ed
 }
c480ed
 
c480ed
 
c480ed
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
c480ed
index 35221e90df..d4e4c4a6cc 100644
c480ed
--- a/src/util/vircgroupbackend.h
c480ed
+++ b/src/util/vircgroupbackend.h
c480ed
@@ -332,6 +332,14 @@ typedef int
c480ed
 (*virCgroupGetCpusetMemsCB)(virCgroupPtr group,
c480ed
                             char **mems);
c480ed
 
c480ed
+typedef int
c480ed
+(*virCgroupSetCpusetMemoryMigrateCB)(virCgroupPtr group,
c480ed
+                                     bool migrate);
c480ed
+
c480ed
+typedef int
c480ed
+(*virCgroupGetCpusetMemoryMigrateCB)(virCgroupPtr group,
c480ed
+                                     bool *migrate);
c480ed
+
c480ed
 struct _virCgroupBackend {
c480ed
     virCgroupBackendType type;
c480ed
 
c480ed
@@ -404,6 +412,8 @@ struct _virCgroupBackend {
c480ed
 
c480ed
     virCgroupSetCpusetMemsCB setCpusetMems;
c480ed
     virCgroupGetCpusetMemsCB getCpusetMems;
c480ed
+    virCgroupSetCpusetMemoryMigrateCB setCpusetMemoryMigrate;
c480ed
+    virCgroupGetCpusetMemoryMigrateCB getCpusetMemoryMigrate;
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 be9a6b82b4..3a41899dd8 100644
c480ed
--- a/src/util/vircgroupv1.c
c480ed
+++ b/src/util/vircgroupv1.c
c480ed
@@ -1971,6 +1971,31 @@ virCgroupV1GetCpusetMems(virCgroupPtr group,
c480ed
 }
c480ed
 
c480ed
 
c480ed
+static int
c480ed
+virCgroupV1SetCpusetMemoryMigrate(virCgroupPtr group,
c480ed
+                                  bool migrate)
c480ed
+{
c480ed
+    return virCgroupSetValueStr(group,
c480ed
+                                VIR_CGROUP_CONTROLLER_CPUSET,
c480ed
+                                "cpuset.memory_migrate",
c480ed
+                                migrate ? "1" : "0");
c480ed
+}
c480ed
+
c480ed
+
c480ed
+static int
c480ed
+virCgroupV1GetCpusetMemoryMigrate(virCgroupPtr group,
c480ed
+                                  bool *migrate)
c480ed
+{
c480ed
+    unsigned long long value = 0;
c480ed
+    int ret = virCgroupGetValueU64(group,
c480ed
+                                   VIR_CGROUP_CONTROLLER_CPUSET,
c480ed
+                                   "cpuset.memory_migrate",
c480ed
+                                   &value);
c480ed
+    *migrate = !!value;
c480ed
+    return ret;
c480ed
+}
c480ed
+
c480ed
+
c480ed
 virCgroupBackend virCgroupV1Backend = {
c480ed
     .type = VIR_CGROUP_BACKEND_TYPE_V1,
c480ed
 
c480ed
@@ -2041,6 +2066,8 @@ virCgroupBackend virCgroupV1Backend = {
c480ed
 
c480ed
     .setCpusetMems = virCgroupV1SetCpusetMems,
c480ed
     .getCpusetMems = virCgroupV1GetCpusetMems,
c480ed
+    .setCpusetMemoryMigrate = virCgroupV1SetCpusetMemoryMigrate,
c480ed
+    .getCpusetMemoryMigrate = virCgroupV1GetCpusetMemoryMigrate,
c480ed
 };
c480ed
 
c480ed
 
c480ed
-- 
c480ed
2.22.0
c480ed