render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From 2a826bcdbe8e34af71634250ae814d5ff81d6ffc Mon Sep 17 00:00:00 2001
Message-Id: <2a826bcdbe8e34af71634250ae814d5ff81d6ffc@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Mon, 1 Jul 2019 17:07:24 +0200
Subject: [PATCH] vircgroup: introduce virCgroupV2PathOfController
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 0542640a9c480993c7e8be6917b0f513277b4cea)

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

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

diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
index 65cbad533b..6695901766 100644
--- a/src/util/vircgroupv2.c
+++ b/src/util/vircgroupv2.c
@@ -315,6 +315,29 @@ virCgroupV2GetAnyController(virCgroupPtr group)
 }
 
 
+static int
+virCgroupV2PathOfController(virCgroupPtr group,
+                            int controller,
+                            const char *key,
+                            char **path)
+{
+    if (!virCgroupV2HasController(group, controller)) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("v2 controller '%s' is not available"),
+                       virCgroupV2ControllerTypeToString(controller));
+        return -1;
+    }
+
+    if (virAsprintf(path, "%s%s/%s",
+                    group->unified.mountPoint,
+                    group->unified.placement,
+                    key ? key : "") < 0)
+        return -1;
+
+    return 0;
+}
+
+
 virCgroupBackend virCgroupV2Backend = {
     .type = VIR_CGROUP_BACKEND_TYPE_V2,
 
@@ -329,6 +352,7 @@ virCgroupBackend virCgroupV2Backend = {
     .detectControllers = virCgroupV2DetectControllers,
     .hasController = virCgroupV2HasController,
     .getAnyController = virCgroupV2GetAnyController,
+    .pathOfController = virCgroupV2PathOfController,
 };
 
 
-- 
2.22.0