render / rpms / libvirt

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