Re: [PATCH 36/47] vircgroup: extract virCgroupV1(Set|Get)CpuShares

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On Tue, Sep 18, 2018 at 5:45 PM, Pavel Hrdina <phrdina@xxxxxxxxxx> wrote:
Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>

Reviewed-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
 
---
 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 ca36984472..d7d11062e5 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -2207,18 +2207,14 @@ virCgroupGetDomainTotalCpuStats(virCgroupPtr group,
 int
 virCgroupSetCpuShares(virCgroupPtr group, unsigned long long shares)
 {
-    return virCgroupSetValueU64(group,
-                                VIR_CGROUP_CONTROLLER_CPU,
-                                "cpu.shares", shares);
+    VIR_CGROUP_BACKEND_CALL(group, setCpuShares, -1, shares);
 }


 int
 virCgroupGetCpuShares(virCgroupPtr group, unsigned long long *shares)
 {
-    return virCgroupGetValueU64(group,
-                                VIR_CGROUP_CONTROLLER_CPU,
-                                "cpu.shares", shares);
+    VIR_CGROUP_BACKEND_CALL(group, getCpuShares, -1, shares);
 }


diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
index ce165fead4..7dbe005319 100644
--- a/src/util/vircgroupbackend.h
+++ b/src/util/vircgroupbackend.h
@@ -268,6 +268,14 @@ typedef int
 typedef int
 (*virCgroupDenyAllDevicesCB)(virCgroupPtr group);

+typedef int
+(*virCgroupSetCpuSharesCB)(virCgroupPtr group,
+                           unsigned long long shares);
+
+typedef int
+(*virCgroupGetCpuSharesCB)(virCgroupPtr group,
+                           unsigned long long *shares);
+
 struct _virCgroupBackend {
     virCgroupBackendType type;

@@ -322,6 +330,9 @@ struct _virCgroupBackend {
     virCgroupDenyDeviceCB denyDevice;
     virCgroupAllowAllDevicesCB allowAllDevices;
     virCgroupDenyAllDevicesCB denyAllDevices;
+
+    virCgroupSetCpuSharesCB setCpuShares;
+    virCgroupGetCpuSharesCB getCpuShares;
 };
 typedef struct _virCgroupBackend virCgroupBackend;
 typedef virCgroupBackend *virCgroupBackendPtr;
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index bd6914f878..d2989b0a63 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -1760,6 +1760,26 @@ virCgroupV1DenyAllDevices(virCgroupPtr group)
 }


+static int
+virCgroupV1SetCpuShares(virCgroupPtr group,
+                        unsigned long long shares)
+{
+    return virCgroupSetValueU64(group,
+                                VIR_CGROUP_CONTROLLER_CPU,
+                                "cpu.shares", shares);
+}
+
+
+static int
+virCgroupV1GetCpuShares(virCgroupPtr group,
+                        unsigned long long *shares)
+{
+    return virCgroupGetValueU64(group,
+                                VIR_CGROUP_CONTROLLER_CPU,
+                                "cpu.shares", shares);
+}
+
+
 virCgroupBackend virCgroupV1Backend = {
     .type = VIR_CGROUP_BACKEND_TYPE_V1,

@@ -1812,6 +1832,9 @@ virCgroupBackend virCgroupV1Backend = {
     .denyDevice = virCgroupV1DenyDevice,
     .allowAllDevices = virCgroupV1AllowAllDevices,
     .denyAllDevices = virCgroupV1DenyAllDevices,
+
+    .setCpuShares = virCgroupV1SetCpuShares,
+    .getCpuShares = virCgroupV1GetCpuShares,
 };
 

--
2.17.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux