render / rpms / libvirt

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