Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
src/util/vircgroup.c | 18 ++----------------
src/util/vircgroupbackend.h | 10 ++++++++++
src/util/vircgroupv1.c | 32 ++++++++++++++++++++++++++++++++
3 files changed, 44 insertions(+), 16 deletions(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index d7d11062e5..beb661df4b 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -2229,19 +2229,7 @@ virCgroupGetCpuShares(virCgroupPtr group, unsigned long long
*shares)
int
virCgroupSetCpuCfsPeriod(virCgroupPtr group, unsigned long long cfs_period)
{
- /* The cfs_period should be greater or equal than 1ms, and less or equal
- * than 1s.
- */
- if (cfs_period < 1000 || cfs_period > 1000000) {
- virReportError(VIR_ERR_INVALID_ARG,
- _("cfs_period '%llu' must be in range (1000,
1000000)"),
- cfs_period);
- return -1;
- }
-
- return virCgroupSetValueU64(group,
- VIR_CGROUP_CONTROLLER_CPU,
- "cpu.cfs_period_us", cfs_period);
+ VIR_CGROUP_BACKEND_CALL(group, setCpuCfsPeriod, -1, cfs_period);
}
@@ -2256,9 +2244,7 @@ virCgroupSetCpuCfsPeriod(virCgroupPtr group, unsigned long long
cfs_period)
int
virCgroupGetCpuCfsPeriod(virCgroupPtr group, unsigned long long *cfs_period)
{
- return virCgroupGetValueU64(group,
- VIR_CGROUP_CONTROLLER_CPU,
- "cpu.cfs_period_us", cfs_period);
+ VIR_CGROUP_BACKEND_CALL(group, getCpuCfsPeriod, -1, cfs_period);
}
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
index 7dbe005319..59f68169ba 100644
--- a/src/util/vircgroupbackend.h
+++ b/src/util/vircgroupbackend.h
@@ -276,6 +276,14 @@ typedef int
(*virCgroupGetCpuSharesCB)(virCgroupPtr group,
unsigned long long *shares);
+typedef int
+(*virCgroupSetCpuCfsPeriodCB)(virCgroupPtr group,
+ unsigned long long cfs_period);
+
+typedef int
+(*virCgroupGetCpuCfsPeriodCB)(virCgroupPtr group,
+ unsigned long long *cfs_period);
+
struct _virCgroupBackend {
virCgroupBackendType type;
@@ -333,6 +341,8 @@ struct _virCgroupBackend {
virCgroupSetCpuSharesCB setCpuShares;
virCgroupGetCpuSharesCB getCpuShares;
+ virCgroupSetCpuCfsPeriodCB setCpuCfsPeriod;
+ virCgroupGetCpuCfsPeriodCB getCpuCfsPeriod;
};
typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr;
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index d2989b0a63..3641371512 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -1780,6 +1780,36 @@ virCgroupV1GetCpuShares(virCgroupPtr group,
}
+static int
+virCgroupV1SetCpuCfsPeriod(virCgroupPtr group,
+ unsigned long long cfs_period)
+{
+ /* The cfs_period should be greater or equal than 1ms, and less or equal
+ * than 1s.
+ */
+ if (cfs_period < 1000 || cfs_period > 1000000) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("cfs_period '%llu' must be in range (1000,
1000000)"),
+ cfs_period);
+ return -1;
+ }
+
+ return virCgroupSetValueU64(group,
+ VIR_CGROUP_CONTROLLER_CPU,
+ "cpu.cfs_period_us", cfs_period);
+}
+
+
+static int
+virCgroupV1GetCpuCfsPeriod(virCgroupPtr group,
+ unsigned long long *cfs_period)
+{
+ return virCgroupGetValueU64(group,
+ VIR_CGROUP_CONTROLLER_CPU,
+ "cpu.cfs_period_us", cfs_period);
+}
+
+
virCgroupBackend virCgroupV1Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V1,
@@ -1835,6 +1865,8 @@ virCgroupBackend virCgroupV1Backend = {
.setCpuShares = virCgroupV1SetCpuShares,
.getCpuShares = virCgroupV1GetCpuShares,
+ .setCpuCfsPeriod = virCgroupV1SetCpuCfsPeriod,
+ .getCpuCfsPeriod = virCgroupV1GetCpuCfsPeriod,
};
--
2.17.1