|
|
c480ed |
From 66611194a3195560a9aea899b9da724154a03609 Mon Sep 17 00:00:00 2001
|
|
|
c480ed |
Message-Id: <66611194a3195560a9aea899b9da724154a03609@dist-git>
|
|
|
c480ed |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
Date: Mon, 1 Jul 2019 17:06:34 +0200
|
|
|
c480ed |
Subject: [PATCH] vircgroup: extract virCgroupV1PathOfController
|
|
|
c480ed |
MIME-Version: 1.0
|
|
|
c480ed |
Content-Type: text/plain; charset=UTF-8
|
|
|
c480ed |
Content-Transfer-Encoding: 8bit
|
|
|
c480ed |
|
|
|
c480ed |
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c480ed |
(cherry picked from commit 57890b2ab49b27ca9dc8a3922fe61e586aca8f77)
|
|
|
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: <0867ff8a5f46a8909e621bfb730942cfac3b2cdb.1561993100.git.phrdina@redhat.com>
|
|
|
c480ed |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c480ed |
---
|
|
|
c480ed |
src/util/vircgroup.c | 22 +---------------------
|
|
|
c480ed |
src/util/vircgroupbackend.h | 7 +++++++
|
|
|
c480ed |
src/util/vircgroupv1.c | 31 +++++++++++++++++++++++++++++++
|
|
|
c480ed |
3 files changed, 39 insertions(+), 21 deletions(-)
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
|
c480ed |
index a6f529accd..438d9b4e70 100644
|
|
|
c480ed |
--- a/src/util/vircgroup.c
|
|
|
c480ed |
+++ b/src/util/vircgroup.c
|
|
|
c480ed |
@@ -1460,27 +1460,7 @@ virCgroupPathOfController(virCgroupPtr group,
|
|
|
c480ed |
return -1;
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
- if (group->controllers[controller].mountPoint == NULL) {
|
|
|
c480ed |
- virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c480ed |
- _("Controller '%s' is not mounted"),
|
|
|
c480ed |
- virCgroupControllerTypeToString(controller));
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
- }
|
|
|
c480ed |
-
|
|
|
c480ed |
- if (group->controllers[controller].placement == NULL) {
|
|
|
c480ed |
- virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c480ed |
- _("Controller '%s' is not enabled for group"),
|
|
|
c480ed |
- virCgroupControllerTypeToString(controller));
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
- }
|
|
|
c480ed |
-
|
|
|
c480ed |
- if (virAsprintf(path, "%s%s/%s",
|
|
|
c480ed |
- group->controllers[controller].mountPoint,
|
|
|
c480ed |
- group->controllers[controller].placement,
|
|
|
c480ed |
- key ? key : "") < 0)
|
|
|
c480ed |
- return -1;
|
|
|
c480ed |
-
|
|
|
c480ed |
- return 0;
|
|
|
c480ed |
+ return group->backend->pathOfController(group, controller, key, path);
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
diff --git a/src/util/vircgroupbackend.h b/src/util/vircgroupbackend.h
|
|
|
c480ed |
index b4eaa89021..916227ba6a 100644
|
|
|
c480ed |
--- a/src/util/vircgroupbackend.h
|
|
|
c480ed |
+++ b/src/util/vircgroupbackend.h
|
|
|
c480ed |
@@ -80,6 +80,12 @@ typedef bool
|
|
|
c480ed |
typedef int
|
|
|
c480ed |
(*virCgroupGetAnyControllerCB)(virCgroupPtr group);
|
|
|
c480ed |
|
|
|
c480ed |
+typedef int
|
|
|
c480ed |
+(*virCgroupPathOfControllerCB)(virCgroupPtr group,
|
|
|
c480ed |
+ int controller,
|
|
|
c480ed |
+ const char *key,
|
|
|
c480ed |
+ char **path);
|
|
|
c480ed |
+
|
|
|
c480ed |
struct _virCgroupBackend {
|
|
|
c480ed |
virCgroupBackendType type;
|
|
|
c480ed |
|
|
|
c480ed |
@@ -95,6 +101,7 @@ struct _virCgroupBackend {
|
|
|
c480ed |
virCgroupDetectControllersCB detectControllers;
|
|
|
c480ed |
virCgroupHasControllerCB hasController;
|
|
|
c480ed |
virCgroupGetAnyControllerCB getAnyController;
|
|
|
c480ed |
+ virCgroupPathOfControllerCB pathOfController;
|
|
|
c480ed |
};
|
|
|
c480ed |
typedef struct _virCgroupBackend virCgroupBackend;
|
|
|
c480ed |
typedef virCgroupBackend *virCgroupBackendPtr;
|
|
|
c480ed |
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
|
|
|
c480ed |
index bae16b8294..a6302d71b1 100644
|
|
|
c480ed |
--- a/src/util/vircgroupv1.c
|
|
|
c480ed |
+++ b/src/util/vircgroupv1.c
|
|
|
c480ed |
@@ -507,6 +507,36 @@ virCgroupV1GetAnyController(virCgroupPtr group)
|
|
|
c480ed |
}
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
+static int
|
|
|
c480ed |
+virCgroupV1PathOfController(virCgroupPtr group,
|
|
|
c480ed |
+ int controller,
|
|
|
c480ed |
+ const char *key,
|
|
|
c480ed |
+ char **path)
|
|
|
c480ed |
+{
|
|
|
c480ed |
+ if (group->controllers[controller].mountPoint == NULL) {
|
|
|
c480ed |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c480ed |
+ _("v1 controller '%s' is not mounted"),
|
|
|
c480ed |
+ virCgroupV1ControllerTypeToString(controller));
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (group->controllers[controller].placement == NULL) {
|
|
|
c480ed |
+ virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c480ed |
+ _("v1 controller '%s' is not enabled for group"),
|
|
|
c480ed |
+ virCgroupV1ControllerTypeToString(controller));
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+ }
|
|
|
c480ed |
+
|
|
|
c480ed |
+ if (virAsprintf(path, "%s%s/%s",
|
|
|
c480ed |
+ group->controllers[controller].mountPoint,
|
|
|
c480ed |
+ group->controllers[controller].placement,
|
|
|
c480ed |
+ key ? key : "") < 0)
|
|
|
c480ed |
+ return -1;
|
|
|
c480ed |
+
|
|
|
c480ed |
+ return 0;
|
|
|
c480ed |
+}
|
|
|
c480ed |
+
|
|
|
c480ed |
+
|
|
|
c480ed |
virCgroupBackend virCgroupV1Backend = {
|
|
|
c480ed |
.type = VIR_CGROUP_BACKEND_TYPE_V1,
|
|
|
c480ed |
|
|
|
c480ed |
@@ -521,6 +551,7 @@ virCgroupBackend virCgroupV1Backend = {
|
|
|
c480ed |
.detectControllers = virCgroupV1DetectControllers,
|
|
|
c480ed |
.hasController = virCgroupV1HasController,
|
|
|
c480ed |
.getAnyController = virCgroupV1GetAnyController,
|
|
|
c480ed |
+ .pathOfController = virCgroupV1PathOfController,
|
|
|
c480ed |
};
|
|
|
c480ed |
|
|
|
c480ed |
|
|
|
c480ed |
--
|
|
|
c480ed |
2.22.0
|
|
|
c480ed |
|