Blob Blame History Raw
From 59084112841259e4ff74bde8ad7ebf32280fdcca Mon Sep 17 00:00:00 2001
Message-Id: <59084112841259e4ff74bde8ad7ebf32280fdcca@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 1 Jul 2019 17:07:49 +0200
Subject: [PATCH] vircgroup: introduce virCgroupV2SupportsCpuBW
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
(cherry picked from commit 5a4d90ae6af6ea5dd1bb6ae5e3fec7307a5f1257)

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Message-Id: <e0f39a4ebc452685be49eaea66266fef5921c989.1561993100.git.phrdina@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 src/util/vircgroupv2.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index a0a7e55493..55f79af204 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -1441,6 +1441,21 @@ virCgroupV2GetCpuCfsQuota(virCgroupPtr group,
 }
 
 
+static bool
+virCgroupV2SupportsCpuBW(virCgroupPtr cgroup)
+{
+    VIR_AUTOFREE(char *) path = NULL;
+
+    if (virCgroupV2PathOfController(cgroup, VIR_CGROUP_CONTROLLER_CPU,
+                                    "cpu.max", &path) < 0) {
+        virResetLastError();
+        return false;
+    }
+
+    return virFileExists(path);
+}
+
+
 virCgroupBackend virCgroupV2Backend = {
     .type = VIR_CGROUP_BACKEND_TYPE_V2,
 
@@ -1495,6 +1510,7 @@ virCgroupBackend virCgroupV2Backend = {
     .getCpuCfsPeriod = virCgroupV2GetCpuCfsPeriod,
     .setCpuCfsQuota = virCgroupV2SetCpuCfsQuota,
     .getCpuCfsQuota = virCgroupV2GetCpuCfsQuota,
+    .supportsCpuBW = virCgroupV2SupportsCpuBW,
 };
 
 
-- 
2.22.0