[PATCH 39/47] vircgroup: extract virCgroupV1SupportsCpuBW

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

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 src/util/vircgroup.c        | 13 +------------
 src/util/vircgroupbackend.h |  4 ++++
 src/util/vircgroupv1.c      | 19 +++++++++++++++++++
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
index 17b8c13cf9..bdbed65be2 100644
--- a/src/util/vircgroup.c
+++ b/src/util/vircgroup.c
@@ -2687,18 +2687,7 @@ int virCgroupSetOwner(virCgroupPtr cgroup,
 bool
 virCgroupSupportsCpuBW(virCgroupPtr cgroup)
 {
-    VIR_AUTOFREE(char *) path = NULL;
-
-    if (!cgroup)
-        return false;
-
-    if (virCgroupPathOfController(cgroup, VIR_CGROUP_CONTROLLER_CPU,
-                                  "cpu.cfs_period_us", &path) < 0) {
-        virResetLastError();
-        return false;
-    }
-
-    return virFileExists(path);
+    VIR_CGROUP_BACKEND_CALL(cgroup, supportsCpuBW, false);
 }
 
 int
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
index b94a89069a..049f9040bd 100644
--- a/src/util/vircgroupbackend.h
+++ b/src/util/vircgroupbackend.h
@@ -292,6 +292,9 @@ typedef int
 (*virCgroupGetCpuCfsQuotaCB)(virCgroupPtr group,
                              long long *cfs_quota);
 
+typedef bool
+(*virCgroupSupportsCpuBWCB)(virCgroupPtr cgroup);
+
 struct _virCgroupBackend {
     virCgroupBackendType type;
 
@@ -353,6 +356,7 @@ struct _virCgroupBackend {
     virCgroupGetCpuCfsPeriodCB getCpuCfsPeriod;
     virCgroupSetCpuCfsQuotaCB setCpuCfsQuota;
     virCgroupGetCpuCfsQuotaCB getCpuCfsQuota;
+    virCgroupSupportsCpuBWCB supportsCpuBW;
 };
 typedef struct _virCgroupBackend virCgroupBackend;
 typedef virCgroupBackend *virCgroupBackendPtr;
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
index 5de6d27f48..88912778b5 100644
--- a/src/util/vircgroupv1.c
+++ b/src/util/vircgroupv1.c
@@ -1840,6 +1840,24 @@ virCgroupV1GetCpuCfsQuota(virCgroupPtr group,
 }
 
 
+static bool
+virCgroupV1SupportsCpuBW(virCgroupPtr cgroup)
+{
+    VIR_AUTOFREE(char *) path = NULL;
+
+    if (!cgroup)
+        return false;
+
+    if (virCgroupV1PathOfController(cgroup, VIR_CGROUP_CONTROLLER_CPU,
+                                    "cpu.cfs_period_us", &path) < 0) {
+        virResetLastError();
+        return false;
+    }
+
+    return virFileExists(path);
+}
+
+
 virCgroupBackend virCgroupV1Backend = {
     .type = VIR_CGROUP_BACKEND_TYPE_V1,
 
@@ -1899,6 +1917,7 @@ virCgroupBackend virCgroupV1Backend = {
     .getCpuCfsPeriod = virCgroupV1GetCpuCfsPeriod,
     .setCpuCfsQuota = virCgroupV1SetCpuCfsQuota,
     .getCpuCfsQuota = virCgroupV1GetCpuCfsQuota,
+    .supportsCpuBW = virCgroupV1SupportsCpuBW,
 };
 
 
-- 
2.17.1

--
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