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