render / rpms / libvirt

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