render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c480ed
From d45a116567b6ad1cc87060651a4d1c8d83384ba8 Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <d45a116567b6ad1cc87060651a4d1c8d83384ba8@dist-git>
c480ed
From: Pavel Hrdina <phrdina@redhat.com>
c480ed
Date: Mon, 1 Jul 2019 17:07:05 +0200
c480ed
Subject: [PATCH] vircgroup: extract virCgroupV1(Set|Get)CpusetCpus
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 2b09065e0fb4b40e05a46f0592d978d3cb72278f)
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: <e68c2c6509b0e9e76c923c980f2d73f0a756cfd1.1561993100.git.phrdina@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 src/util/vircgroup.c        | 10 ++--------
c480ed
 src/util/vircgroupbackend.h | 10 ++++++++++
c480ed
 src/util/vircgroupv1.c      | 24 ++++++++++++++++++++++++
c480ed
 3 files changed, 36 insertions(+), 8 deletions(-)
c480ed
c480ed
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
c480ed
index 1a5ed472df..b159bda1bb 100644
c480ed
--- a/src/util/vircgroup.c
c480ed
+++ b/src/util/vircgroup.c
c480ed
@@ -1772,10 +1772,7 @@ virCgroupGetCpusetMemoryMigrate(virCgroupPtr group, bool *migrate)
c480ed
 int
c480ed
 virCgroupSetCpusetCpus(virCgroupPtr group, const char *cpus)
c480ed
 {
c480ed
-    return virCgroupSetValueStr(group,
c480ed
-                                VIR_CGROUP_CONTROLLER_CPUSET,
c480ed
-                                "cpuset.cpus",
c480ed
-                                cpus);
c480ed
+    VIR_CGROUP_BACKEND_CALL(group, setCpusetCpus, -1, cpus);
c480ed
 }
c480ed
 
c480ed
 
c480ed
@@ -1790,10 +1787,7 @@ virCgroupSetCpusetCpus(virCgroupPtr group, const char *cpus)
c480ed
 int
c480ed
 virCgroupGetCpusetCpus(virCgroupPtr group, char **cpus)
c480ed
 {
c480ed
-    return virCgroupGetValueStr(group,
c480ed
-                                VIR_CGROUP_CONTROLLER_CPUSET,
c480ed
-                                "cpuset.cpus",
c480ed
-                                cpus);
c480ed
+    VIR_CGROUP_BACKEND_CALL(group, getCpusetCpus, -1, cpus);
c480ed
 }
c480ed
 
c480ed
 
c480ed
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
c480ed
index d4e4c4a6cc..1c5744ef76 100644
c480ed
--- a/src/util/vircgroupbackend.h
c480ed
+++ b/src/util/vircgroupbackend.h
c480ed
@@ -340,6 +340,14 @@ typedef int
c480ed
 (*virCgroupGetCpusetMemoryMigrateCB)(virCgroupPtr group,
c480ed
                                      bool *migrate);
c480ed
 
c480ed
+typedef int
c480ed
+(*virCgroupSetCpusetCpusCB)(virCgroupPtr group,
c480ed
+                            const char *cpus);
c480ed
+
c480ed
+typedef int
c480ed
+(*virCgroupGetCpusetCpusCB)(virCgroupPtr group,
c480ed
+                            char **cpus);
c480ed
+
c480ed
 struct _virCgroupBackend {
c480ed
     virCgroupBackendType type;
c480ed
 
c480ed
@@ -414,6 +422,8 @@ struct _virCgroupBackend {
c480ed
     virCgroupGetCpusetMemsCB getCpusetMems;
c480ed
     virCgroupSetCpusetMemoryMigrateCB setCpusetMemoryMigrate;
c480ed
     virCgroupGetCpusetMemoryMigrateCB getCpusetMemoryMigrate;
c480ed
+    virCgroupSetCpusetCpusCB setCpusetCpus;
c480ed
+    virCgroupGetCpusetCpusCB getCpusetCpus;
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 3a41899dd8..54e7d6ea9a 100644
c480ed
--- a/src/util/vircgroupv1.c
c480ed
+++ b/src/util/vircgroupv1.c
c480ed
@@ -1996,6 +1996,28 @@ virCgroupV1GetCpusetMemoryMigrate(virCgroupPtr group,
c480ed
 }
c480ed
 
c480ed
 
c480ed
+static int
c480ed
+virCgroupV1SetCpusetCpus(virCgroupPtr group,
c480ed
+                         const char *cpus)
c480ed
+{
c480ed
+    return virCgroupSetValueStr(group,
c480ed
+                                VIR_CGROUP_CONTROLLER_CPUSET,
c480ed
+                                "cpuset.cpus",
c480ed
+                                cpus);
c480ed
+}
c480ed
+
c480ed
+
c480ed
+static int
c480ed
+virCgroupV1GetCpusetCpus(virCgroupPtr group,
c480ed
+                         char **cpus)
c480ed
+{
c480ed
+    return virCgroupGetValueStr(group,
c480ed
+                                VIR_CGROUP_CONTROLLER_CPUSET,
c480ed
+                                "cpuset.cpus",
c480ed
+                                cpus);
c480ed
+}
c480ed
+
c480ed
+
c480ed
 virCgroupBackend virCgroupV1Backend = {
c480ed
     .type = VIR_CGROUP_BACKEND_TYPE_V1,
c480ed
 
c480ed
@@ -2068,6 +2090,8 @@ virCgroupBackend virCgroupV1Backend = {
c480ed
     .getCpusetMems = virCgroupV1GetCpusetMems,
c480ed
     .setCpusetMemoryMigrate = virCgroupV1SetCpusetMemoryMigrate,
c480ed
     .getCpusetMemoryMigrate = virCgroupV1GetCpusetMemoryMigrate,
c480ed
+    .setCpusetCpus = virCgroupV1SetCpusetCpus,
c480ed
+    .getCpusetCpus = virCgroupV1GetCpusetCpus,
c480ed
 };
c480ed
 
c480ed
 
c480ed
-- 
c480ed
2.22.0
c480ed