libvirt/SOURCES/libvirt-vircgroup-extract-virCgroupV1-Set-Get-FreezerState.patch
2021-10-08 13:11:16 +00:00

124 lines
4.0 KiB
Diff

From c68fdfdc5432ec922ca9ead1e3a0880a6112fea6 Mon Sep 17 00:00:00 2001
Message-Id: <c68fdfdc5432ec922ca9ead1e3a0880a6112fea6@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 1 Jul 2019 17:07:02 +0200
Subject: [PATCH] vircgroup: extract virCgroupV1(Set|Get)FreezerState
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 269a8e2718f96d5c015ad5d792fdf6759b7faee5)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <a3223b27d03cc952fcf5d7aedbc7fbfd95052b1a.1561993100.git.phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
src/util/vircgroup.c | 8 ++------
src/util/vircgroupbackend.h | 11 +++++++++++
src/util/vircgroupv1.c | 23 +++++++++++++++++++++++
3 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 090fe140bb..8b14c053e9 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -2603,18 +2603,14 @@ virCgroupGetCpuacctStat(virCgroupPtr group, unsigned long long *user,
int
virCgroupSetFreezerState(virCgroupPtr group, const char *state)
{
- return virCgroupSetValueStr(group,
- VIR_CGROUP_CONTROLLER_FREEZER,
- "freezer.state", state);
+ VIR_CGROUP_BACKEND_CALL(group, setFreezerState, -1, state);
}
int
virCgroupGetFreezerState(virCgroupPtr group, char **state)
{
- return virCgroupGetValueStr(group,
- VIR_CGROUP_CONTROLLER_FREEZER,
- "freezer.state", state);
+ VIR_CGROUP_BACKEND_CALL(group, getFreezerState, -1, state);
}
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
index 3e3a73777d..2c16706c96 100644
--- a/src/util/vircgroupbackend.h
+++ b/src/util/vircgroupbackend.h
@@ -316,6 +316,14 @@ typedef int
unsigned long long *user,
unsigned long long *sys);
+typedef int
+(*virCgroupSetFreezerStateCB)(virCgroupPtr group,
+ const char *state);
+
+typedef int
+(*virCgroupGetFreezerStateCB)(virCgroupPtr group,
+ char **state);
+
struct _virCgroupBackend {
virCgroupBackendType type;
@@ -382,6 +390,9 @@ struct _virCgroupBackend {
virCgroupGetCpuacctUsageCB getCpuacctUsage;
virCgroupGetCpuacctPercpuUsageCB getCpuacctPercpuUsage;
virCgroupGetCpuacctStatCB getCpuacctStat;
+
+ virCgroupSetFreezerStateCB setFreezerState;
+ virCgroupGetFreezerStateCB getFreezerState;
};
typedef struct _virCgroupBackend virCgroupBackend;
typedef virCgroupBackend *virCgroupBackendPtr;
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 23a91adf60..7580f8b756 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -1929,6 +1929,26 @@ virCgroupV1GetCpuacctStat(virCgroupPtr group,
}
+static int
+virCgroupV1SetFreezerState(virCgroupPtr group,
+ const char *state)
+{
+ return virCgroupSetValueStr(group,
+ VIR_CGROUP_CONTROLLER_FREEZER,
+ "freezer.state", state);
+}
+
+
+static int
+virCgroupV1GetFreezerState(virCgroupPtr group,
+ char **state)
+{
+ return virCgroupGetValueStr(group,
+ VIR_CGROUP_CONTROLLER_FREEZER,
+ "freezer.state", state);
+}
+
+
virCgroupBackend virCgroupV1Backend = {
.type = VIR_CGROUP_BACKEND_TYPE_V1,
@@ -1993,6 +2013,9 @@ virCgroupBackend virCgroupV1Backend = {
.getCpuacctUsage = virCgroupV1GetCpuacctUsage,
.getCpuacctPercpuUsage = virCgroupV1GetCpuacctPercpuUsage,
.getCpuacctStat = virCgroupV1GetCpuacctStat,
+
+ .setFreezerState = virCgroupV1SetFreezerState,
+ .getFreezerState = virCgroupV1GetFreezerState,
};
--
2.22.0