render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Pablo Greco 40546a
From 2a826bcdbe8e34af71634250ae814d5ff81d6ffc Mon Sep 17 00:00:00 2001
Pablo Greco 40546a
Message-Id: <2a826bcdbe8e34af71634250ae814d5ff81d6ffc@dist-git>
Pablo Greco 40546a
From: Pavel Hrdina <phrdina@redhat.com>
Pablo Greco 40546a
Date: Mon, 1 Jul 2019 17:07:24 +0200
Pablo Greco 40546a
Subject: [PATCH] vircgroup: introduce virCgroupV2PathOfController
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 0542640a9c480993c7e8be6917b0f513277b4cea)
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: <91b63d07af48bdb0fdc9648f4e5e4808cc90ad0e.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 | 24 ++++++++++++++++++++++++
Pablo Greco 40546a
 1 file changed, 24 insertions(+)
Pablo Greco 40546a
Pablo Greco 40546a
diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c
Pablo Greco 40546a
index 65cbad533b..6695901766 100644
Pablo Greco 40546a
--- a/src/util/vircgroupv2.c
Pablo Greco 40546a
+++ b/src/util/vircgroupv2.c
Pablo Greco 40546a
@@ -315,6 +315,29 @@ virCgroupV2GetAnyController(virCgroupPtr group)
Pablo Greco 40546a
 }
Pablo Greco 40546a
 
Pablo Greco 40546a
 
Pablo Greco 40546a
+static int
Pablo Greco 40546a
+virCgroupV2PathOfController(virCgroupPtr group,
Pablo Greco 40546a
+                            int controller,
Pablo Greco 40546a
+                            const char *key,
Pablo Greco 40546a
+                            char **path)
Pablo Greco 40546a
+{
Pablo Greco 40546a
+    if (!virCgroupV2HasController(group, controller)) {
Pablo Greco 40546a
+        virReportError(VIR_ERR_INTERNAL_ERROR,
Pablo Greco 40546a
+                       _("v2 controller '%s' is not available"),
Pablo Greco 40546a
+                       virCgroupV2ControllerTypeToString(controller));
Pablo Greco 40546a
+        return -1;
Pablo Greco 40546a
+    }
Pablo Greco 40546a
+
Pablo Greco 40546a
+    if (virAsprintf(path, "%s%s/%s",
Pablo Greco 40546a
+                    group->unified.mountPoint,
Pablo Greco 40546a
+                    group->unified.placement,
Pablo Greco 40546a
+                    key ? key : "") < 0)
Pablo Greco 40546a
+        return -1;
Pablo Greco 40546a
+
Pablo Greco 40546a
+    return 0;
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
@@ -329,6 +352,7 @@ virCgroupBackend virCgroupV2Backend = {
Pablo Greco 40546a
     .detectControllers = virCgroupV2DetectControllers,
Pablo Greco 40546a
     .hasController = virCgroupV2HasController,
Pablo Greco 40546a
     .getAnyController = virCgroupV2GetAnyController,
Pablo Greco 40546a
+    .pathOfController = virCgroupV2PathOfController,
Pablo Greco 40546a
 };
Pablo Greco 40546a
 
Pablo Greco 40546a
 
Pablo Greco 40546a
-- 
Pablo Greco 40546a
2.22.0
Pablo Greco 40546a