render / rpms / libvirt

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