c480ed
From 59084112841259e4ff74bde8ad7ebf32280fdcca Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <59084112841259e4ff74bde8ad7ebf32280fdcca@dist-git>
c480ed
From: Pavel Hrdina <phrdina@redhat.com>
c480ed
Date: Mon, 1 Jul 2019 17:07:49 +0200
c480ed
Subject: [PATCH] vircgroup: introduce virCgroupV2SupportsCpuBW
c480ed
MIME-Version: 1.0
c480ed
Content-Type: text/plain; charset=UTF-8
c480ed
Content-Transfer-Encoding: 8bit
c480ed
c480ed
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
c480ed
(cherry picked from commit 5a4d90ae6af6ea5dd1bb6ae5e3fec7307a5f1257)
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: <e0f39a4ebc452685be49eaea66266fef5921c989.1561993100.git.phrdina@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 src/util/vircgroupv2.c | 16 ++++++++++++++++
c480ed
 1 file changed, 16 insertions(+)
c480ed
c480ed
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
c480ed
index a0a7e55493..55f79af204 100644
c480ed
--- a/src/util/vircgroupv2.c
c480ed
+++ b/src/util/vircgroupv2.c
c480ed
@@ -1441,6 +1441,21 @@ virCgroupV2GetCpuCfsQuota(virCgroupPtr group,
c480ed
 }
c480ed
 
c480ed
 
c480ed
+static bool
c480ed
+virCgroupV2SupportsCpuBW(virCgroupPtr cgroup)
c480ed
+{
c480ed
+    VIR_AUTOFREE(char *) path = NULL;
c480ed
+
c480ed
+    if (virCgroupV2PathOfController(cgroup, VIR_CGROUP_CONTROLLER_CPU,
c480ed
+                                    "cpu.max", &path) < 0) {
c480ed
+        virResetLastError();
c480ed
+        return false;
c480ed
+    }
c480ed
+
c480ed
+    return virFileExists(path);
c480ed
+}
c480ed
+
c480ed
+
c480ed
 virCgroupBackend virCgroupV2Backend = {
c480ed
     .type = VIR_CGROUP_BACKEND_TYPE_V2,
c480ed
 
c480ed
@@ -1495,6 +1510,7 @@ virCgroupBackend virCgroupV2Backend = {
c480ed
     .getCpuCfsPeriod = virCgroupV2GetCpuCfsPeriod,
c480ed
     .setCpuCfsQuota = virCgroupV2SetCpuCfsQuota,
c480ed
     .getCpuCfsQuota = virCgroupV2GetCpuCfsQuota,
c480ed
+    .supportsCpuBW = virCgroupV2SupportsCpuBW,
c480ed
 };
c480ed
 
c480ed
 
c480ed
-- 
c480ed
2.22.0
c480ed