|
|
c313de |
From da3574e1bcbc4779b516e8bf14f56abf2a19885d Mon Sep 17 00:00:00 2001
|
|
|
c313de |
Message-Id: <da3574e1bcbc4779b516e8bf14f56abf2a19885d@dist-git>
|
|
|
c313de |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c313de |
Date: Mon, 1 Jul 2019 17:07:07 +0200
|
|
|
c313de |
Subject: [PATCH] vircgroup: rename controllers to legacy
|
|
|
c313de |
MIME-Version: 1.0
|
|
|
c313de |
Content-Type: text/plain; charset=UTF-8
|
|
|
c313de |
Content-Transfer-Encoding: 8bit
|
|
|
c313de |
|
|
|
c313de |
With the introduction of cgroup v2 there are new names used with
|
|
|
c313de |
cgroups based on which version is used:
|
|
|
c313de |
|
|
|
c313de |
- legacy: cgroup v1
|
|
|
c313de |
- unified: cgroup v2
|
|
|
c313de |
- hybrid: cgroup v1 and cgroup v2
|
|
|
c313de |
|
|
|
c313de |
Let's use 'legacy' instead of 'cgroupv1' or 'controllers' in our code.
|
|
|
c313de |
|
|
|
c313de |
Reviewed-by: Fabiano Fidêncio <fidencio@redhat.com>
|
|
|
c313de |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c313de |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c313de |
(cherry picked from commit 65ba48d26745450e5079f171052caa7309c99fdf)
|
|
|
c313de |
|
|
|
c313de |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1689297
|
|
|
c313de |
|
|
|
c313de |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
c313de |
Message-Id: <b9853bf7cd21097e0248448362f6178e31ab6279.1561993100.git.phrdina@redhat.com>
|
|
|
c313de |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
c313de |
---
|
|
|
c313de |
src/util/vircgroup.c | 6 +-
|
|
|
c313de |
src/util/vircgrouppriv.h | 2 +-
|
|
|
c313de |
src/util/vircgroupv1.c | 140 +++++++++++++++++++--------------------
|
|
|
c313de |
tests/vircgrouptest.c | 14 ++--
|
|
|
c313de |
4 files changed, 81 insertions(+), 81 deletions(-)
|
|
|
c313de |
|
|
|
c313de |
diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c
|
|
|
c313de |
index b159bda1bb..349c388e0a 100644
|
|
|
c313de |
--- a/src/util/vircgroup.c
|
|
|
c313de |
+++ b/src/util/vircgroup.c
|
|
|
c313de |
@@ -1246,9 +1246,9 @@ virCgroupFree(virCgroupPtr *group)
|
|
|
c313de |
return;
|
|
|
c313de |
|
|
|
c313de |
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
|
c313de |
- VIR_FREE((*group)->controllers[i].mountPoint);
|
|
|
c313de |
- VIR_FREE((*group)->controllers[i].linkPoint);
|
|
|
c313de |
- VIR_FREE((*group)->controllers[i].placement);
|
|
|
c313de |
+ VIR_FREE((*group)->legacy[i].mountPoint);
|
|
|
c313de |
+ VIR_FREE((*group)->legacy[i].linkPoint);
|
|
|
c313de |
+ VIR_FREE((*group)->legacy[i].placement);
|
|
|
c313de |
}
|
|
|
c313de |
|
|
|
c313de |
VIR_FREE((*group)->path);
|
|
|
c313de |
diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h
|
|
|
c313de |
index ee6aeedbb5..c50a25f195 100644
|
|
|
c313de |
--- a/src/util/vircgrouppriv.h
|
|
|
c313de |
+++ b/src/util/vircgrouppriv.h
|
|
|
c313de |
@@ -50,7 +50,7 @@ struct _virCgroup {
|
|
|
c313de |
|
|
|
c313de |
virCgroupBackendPtr backend;
|
|
|
c313de |
|
|
|
c313de |
- virCgroupV1Controller controllers[VIR_CGROUP_CONTROLLER_LAST];
|
|
|
c313de |
+ virCgroupV1Controller legacy[VIR_CGROUP_CONTROLLER_LAST];
|
|
|
c313de |
};
|
|
|
c313de |
|
|
|
c313de |
int virCgroupSetValueStr(virCgroupPtr group,
|
|
|
c313de |
diff --git a/src/util/vircgroupv1.c b/src/util/vircgroupv1.c
|
|
|
c313de |
index 0ba8757348..482615f3c8 100644
|
|
|
c313de |
--- a/src/util/vircgroupv1.c
|
|
|
c313de |
+++ b/src/util/vircgroupv1.c
|
|
|
c313de |
@@ -127,10 +127,10 @@ virCgroupV1ValidateMachineGroup(virCgroupPtr group,
|
|
|
c313de |
if (i == VIR_CGROUP_CONTROLLER_SYSTEMD)
|
|
|
c313de |
continue;
|
|
|
c313de |
|
|
|
c313de |
- if (!group->controllers[i].placement)
|
|
|
c313de |
+ if (!group->legacy[i].placement)
|
|
|
c313de |
continue;
|
|
|
c313de |
|
|
|
c313de |
- tmp = strrchr(group->controllers[i].placement, '/');
|
|
|
c313de |
+ tmp = strrchr(group->legacy[i].placement, '/');
|
|
|
c313de |
if (!tmp)
|
|
|
c313de |
return false;
|
|
|
c313de |
|
|
|
c313de |
@@ -139,7 +139,7 @@ virCgroupV1ValidateMachineGroup(virCgroupPtr group,
|
|
|
c313de |
i == VIR_CGROUP_CONTROLLER_CPUSET) {
|
|
|
c313de |
if (STREQ(tmp, "/emulator"))
|
|
|
c313de |
*tmp = '\0';
|
|
|
c313de |
- tmp = strrchr(group->controllers[i].placement, '/');
|
|
|
c313de |
+ tmp = strrchr(group->legacy[i].placement, '/');
|
|
|
c313de |
if (!tmp)
|
|
|
c313de |
return false;
|
|
|
c313de |
}
|
|
|
c313de |
@@ -171,15 +171,15 @@ virCgroupV1CopyMounts(virCgroupPtr group,
|
|
|
c313de |
{
|
|
|
c313de |
size_t i;
|
|
|
c313de |
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
|
c313de |
- if (!parent->controllers[i].mountPoint)
|
|
|
c313de |
+ if (!parent->legacy[i].mountPoint)
|
|
|
c313de |
continue;
|
|
|
c313de |
|
|
|
c313de |
- if (VIR_STRDUP(group->controllers[i].mountPoint,
|
|
|
c313de |
- parent->controllers[i].mountPoint) < 0)
|
|
|
c313de |
+ if (VIR_STRDUP(group->legacy[i].mountPoint,
|
|
|
c313de |
+ parent->legacy[i].mountPoint) < 0)
|
|
|
c313de |
return -1;
|
|
|
c313de |
|
|
|
c313de |
- if (VIR_STRDUP(group->controllers[i].linkPoint,
|
|
|
c313de |
- parent->controllers[i].linkPoint) < 0)
|
|
|
c313de |
+ if (VIR_STRDUP(group->legacy[i].linkPoint,
|
|
|
c313de |
+ parent->legacy[i].linkPoint) < 0)
|
|
|
c313de |
return -1;
|
|
|
c313de |
}
|
|
|
c313de |
return 0;
|
|
|
c313de |
@@ -193,14 +193,14 @@ virCgroupV1CopyPlacement(virCgroupPtr group,
|
|
|
c313de |
{
|
|
|
c313de |
size_t i;
|
|
|
c313de |
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
|
c313de |
- if (!group->controllers[i].mountPoint)
|
|
|
c313de |
+ if (!group->legacy[i].mountPoint)
|
|
|
c313de |
continue;
|
|
|
c313de |
|
|
|
c313de |
if (i == VIR_CGROUP_CONTROLLER_SYSTEMD)
|
|
|
c313de |
continue;
|
|
|
c313de |
|
|
|
c313de |
if (path[0] == '/') {
|
|
|
c313de |
- if (VIR_STRDUP(group->controllers[i].placement, path) < 0)
|
|
|
c313de |
+ if (VIR_STRDUP(group->legacy[i].placement, path) < 0)
|
|
|
c313de |
return -1;
|
|
|
c313de |
} else {
|
|
|
c313de |
/*
|
|
|
c313de |
@@ -208,10 +208,10 @@ virCgroupV1CopyPlacement(virCgroupPtr group,
|
|
|
c313de |
* parent == "/libvirt.service" + path == "" => "/libvirt.service"
|
|
|
c313de |
* parent == "/libvirt.service" + path == "foo" => "/libvirt.service/foo"
|
|
|
c313de |
*/
|
|
|
c313de |
- if (virAsprintf(&group->controllers[i].placement,
|
|
|
c313de |
+ if (virAsprintf(&group->legacy[i].placement,
|
|
|
c313de |
"%s%s%s",
|
|
|
c313de |
- parent->controllers[i].placement,
|
|
|
c313de |
- (STREQ(parent->controllers[i].placement, "/") ||
|
|
|
c313de |
+ parent->legacy[i].placement,
|
|
|
c313de |
+ (STREQ(parent->legacy[i].placement, "/") ||
|
|
|
c313de |
STREQ(path, "") ? "" : "/"),
|
|
|
c313de |
path) < 0)
|
|
|
c313de |
return -1;
|
|
|
c313de |
@@ -320,7 +320,7 @@ virCgroupV1DetectMounts(virCgroupPtr group,
|
|
|
c313de |
* once. We need to save the results of the last one,
|
|
|
c313de |
* and we need to be careful to release the memory used
|
|
|
c313de |
* by previous processing. */
|
|
|
c313de |
- virCgroupV1ControllerPtr controller = &group->controllers[i];
|
|
|
c313de |
+ virCgroupV1ControllerPtr controller = &group->legacy[i];
|
|
|
c313de |
|
|
|
c313de |
VIR_FREE(controller->mountPoint);
|
|
|
c313de |
VIR_FREE(controller->linkPoint);
|
|
|
c313de |
@@ -350,19 +350,19 @@ virCgroupV1DetectPlacement(virCgroupPtr group,
|
|
|
c313de |
const char *typestr = virCgroupV1ControllerTypeToString(i);
|
|
|
c313de |
|
|
|
c313de |
if (virCgroupV1MountOptsMatchController(controllers, typestr) &&
|
|
|
c313de |
- group->controllers[i].mountPoint != NULL &&
|
|
|
c313de |
- group->controllers[i].placement == NULL) {
|
|
|
c313de |
+ group->legacy[i].mountPoint != NULL &&
|
|
|
c313de |
+ group->legacy[i].placement == NULL) {
|
|
|
c313de |
/*
|
|
|
c313de |
* selfpath == "/" + path="" -> "/"
|
|
|
c313de |
* selfpath == "/libvirt.service" + path == "" -> "/libvirt.service"
|
|
|
c313de |
* selfpath == "/libvirt.service" + path == "foo" -> "/libvirt.service/foo"
|
|
|
c313de |
*/
|
|
|
c313de |
if (i == VIR_CGROUP_CONTROLLER_SYSTEMD) {
|
|
|
c313de |
- if (VIR_STRDUP(group->controllers[i].placement,
|
|
|
c313de |
+ if (VIR_STRDUP(group->legacy[i].placement,
|
|
|
c313de |
selfpath) < 0)
|
|
|
c313de |
return -1;
|
|
|
c313de |
} else {
|
|
|
c313de |
- if (virAsprintf(&group->controllers[i].placement,
|
|
|
c313de |
+ if (virAsprintf(&group->legacy[i].placement,
|
|
|
c313de |
"%s%s%s", selfpath,
|
|
|
c313de |
(STREQ(selfpath, "/") ||
|
|
|
c313de |
STREQ(path, "") ? "" : "/"),
|
|
|
c313de |
@@ -383,22 +383,22 @@ virCgroupV1ValidatePlacement(virCgroupPtr group,
|
|
|
c313de |
size_t i;
|
|
|
c313de |
|
|
|
c313de |
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
|
c313de |
- if (!group->controllers[i].mountPoint)
|
|
|
c313de |
+ if (!group->legacy[i].mountPoint)
|
|
|
c313de |
continue;
|
|
|
c313de |
|
|
|
c313de |
- if (!group->controllers[i].placement) {
|
|
|
c313de |
+ if (!group->legacy[i].placement) {
|
|
|
c313de |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c313de |
_("Could not find placement for v1 controller %s at %s"),
|
|
|
c313de |
virCgroupV1ControllerTypeToString(i),
|
|
|
c313de |
- group->controllers[i].placement);
|
|
|
c313de |
+ group->legacy[i].placement);
|
|
|
c313de |
return -1;
|
|
|
c313de |
}
|
|
|
c313de |
|
|
|
c313de |
VIR_DEBUG("Detected mount/mapping %zu:%s at %s in %s for pid %lld",
|
|
|
c313de |
i,
|
|
|
c313de |
virCgroupV1ControllerTypeToString(i),
|
|
|
c313de |
- group->controllers[i].mountPoint,
|
|
|
c313de |
- group->controllers[i].placement,
|
|
|
c313de |
+ group->legacy[i].mountPoint,
|
|
|
c313de |
+ group->legacy[i].placement,
|
|
|
c313de |
(long long) pid);
|
|
|
c313de |
}
|
|
|
c313de |
|
|
|
c313de |
@@ -411,7 +411,7 @@ virCgroupV1StealPlacement(virCgroupPtr group)
|
|
|
c313de |
{
|
|
|
c313de |
char *ret = NULL;
|
|
|
c313de |
|
|
|
c313de |
- VIR_STEAL_PTR(ret, group->controllers[VIR_CGROUP_CONTROLLER_SYSTEMD].placement);
|
|
|
c313de |
+ VIR_STEAL_PTR(ret, group->legacy[VIR_CGROUP_CONTROLLER_SYSTEMD].placement);
|
|
|
c313de |
|
|
|
c313de |
return ret;
|
|
|
c313de |
}
|
|
|
c313de |
@@ -430,7 +430,7 @@ virCgroupV1DetectControllers(virCgroupPtr group,
|
|
|
c313de |
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
|
c313de |
if (((1 << i) & controllers)) {
|
|
|
c313de |
/* Remove non-existent controllers */
|
|
|
c313de |
- if (!group->controllers[i].mountPoint) {
|
|
|
c313de |
+ if (!group->legacy[i].mountPoint) {
|
|
|
c313de |
VIR_DEBUG("Requested controller '%s' not mounted, ignoring",
|
|
|
c313de |
virCgroupV1ControllerTypeToString(i));
|
|
|
c313de |
controllers &= ~(1 << i);
|
|
|
c313de |
@@ -441,9 +441,9 @@ virCgroupV1DetectControllers(virCgroupPtr group,
|
|
|
c313de |
VIR_DEBUG("Controller '%s' wanted=%s, mount='%s'",
|
|
|
c313de |
virCgroupV1ControllerTypeToString(i),
|
|
|
c313de |
(1 << i) & controllers ? "yes" : "no",
|
|
|
c313de |
- NULLSTR(group->controllers[i].mountPoint));
|
|
|
c313de |
+ NULLSTR(group->legacy[i].mountPoint));
|
|
|
c313de |
if (!((1 << i) & controllers) &&
|
|
|
c313de |
- group->controllers[i].mountPoint) {
|
|
|
c313de |
+ group->legacy[i].mountPoint) {
|
|
|
c313de |
/* Check whether a request to disable a controller
|
|
|
c313de |
* clashes with co-mounting of controllers */
|
|
|
c313de |
for (j = 0; j < VIR_CGROUP_CONTROLLER_LAST; j++) {
|
|
|
c313de |
@@ -452,8 +452,8 @@ virCgroupV1DetectControllers(virCgroupPtr group,
|
|
|
c313de |
if (!((1 << j) & controllers))
|
|
|
c313de |
continue;
|
|
|
c313de |
|
|
|
c313de |
- if (STREQ_NULLABLE(group->controllers[i].mountPoint,
|
|
|
c313de |
- group->controllers[j].mountPoint)) {
|
|
|
c313de |
+ if (STREQ_NULLABLE(group->legacy[i].mountPoint,
|
|
|
c313de |
+ group->legacy[j].mountPoint)) {
|
|
|
c313de |
virReportSystemError(EINVAL,
|
|
|
c313de |
_("V1 controller '%s' is not wanted, but '%s' is co-mounted"),
|
|
|
c313de |
virCgroupV1ControllerTypeToString(i),
|
|
|
c313de |
@@ -461,7 +461,7 @@ virCgroupV1DetectControllers(virCgroupPtr group,
|
|
|
c313de |
return -1;
|
|
|
c313de |
}
|
|
|
c313de |
}
|
|
|
c313de |
- VIR_FREE(group->controllers[i].mountPoint);
|
|
|
c313de |
+ VIR_FREE(group->legacy[i].mountPoint);
|
|
|
c313de |
}
|
|
|
c313de |
}
|
|
|
c313de |
} else {
|
|
|
c313de |
@@ -470,8 +470,8 @@ virCgroupV1DetectControllers(virCgroupPtr group,
|
|
|
c313de |
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
|
c313de |
VIR_DEBUG("Controller '%s' present=%s",
|
|
|
c313de |
virCgroupV1ControllerTypeToString(i),
|
|
|
c313de |
- group->controllers[i].mountPoint ? "yes" : "no");
|
|
|
c313de |
- if (group->controllers[i].mountPoint == NULL)
|
|
|
c313de |
+ group->legacy[i].mountPoint ? "yes" : "no");
|
|
|
c313de |
+ if (group->legacy[i].mountPoint == NULL)
|
|
|
c313de |
continue;
|
|
|
c313de |
controllers |= (1 << i);
|
|
|
c313de |
}
|
|
|
c313de |
@@ -485,7 +485,7 @@ static bool
|
|
|
c313de |
virCgroupV1HasController(virCgroupPtr group,
|
|
|
c313de |
int controller)
|
|
|
c313de |
{
|
|
|
c313de |
- return group->controllers[controller].mountPoint != NULL;
|
|
|
c313de |
+ return group->legacy[controller].mountPoint != NULL;
|
|
|
c313de |
}
|
|
|
c313de |
|
|
|
c313de |
|
|
|
c313de |
@@ -499,9 +499,9 @@ virCgroupV1GetAnyController(virCgroupPtr group)
|
|
|
c313de |
* of '/' to avoid doing bad stuff to the root
|
|
|
c313de |
* cgroup
|
|
|
c313de |
*/
|
|
|
c313de |
- if (group->controllers[i].mountPoint &&
|
|
|
c313de |
- group->controllers[i].placement &&
|
|
|
c313de |
- STRNEQ(group->controllers[i].placement, "/")) {
|
|
|
c313de |
+ if (group->legacy[i].mountPoint &&
|
|
|
c313de |
+ group->legacy[i].placement &&
|
|
|
c313de |
+ STRNEQ(group->legacy[i].placement, "/")) {
|
|
|
c313de |
return i;
|
|
|
c313de |
}
|
|
|
c313de |
}
|
|
|
c313de |
@@ -516,14 +516,14 @@ virCgroupV1PathOfController(virCgroupPtr group,
|
|
|
c313de |
const char *key,
|
|
|
c313de |
char **path)
|
|
|
c313de |
{
|
|
|
c313de |
- if (group->controllers[controller].mountPoint == NULL) {
|
|
|
c313de |
+ if (group->legacy[controller].mountPoint == NULL) {
|
|
|
c313de |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c313de |
_("v1 controller '%s' is not mounted"),
|
|
|
c313de |
virCgroupV1ControllerTypeToString(controller));
|
|
|
c313de |
return -1;
|
|
|
c313de |
}
|
|
|
c313de |
|
|
|
c313de |
- if (group->controllers[controller].placement == NULL) {
|
|
|
c313de |
+ if (group->legacy[controller].placement == NULL) {
|
|
|
c313de |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c313de |
_("v1 controller '%s' is not enabled for group"),
|
|
|
c313de |
virCgroupV1ControllerTypeToString(controller));
|
|
|
c313de |
@@ -531,8 +531,8 @@ virCgroupV1PathOfController(virCgroupPtr group,
|
|
|
c313de |
}
|
|
|
c313de |
|
|
|
c313de |
if (virAsprintf(path, "%s%s/%s",
|
|
|
c313de |
- group->controllers[controller].mountPoint,
|
|
|
c313de |
- group->controllers[controller].placement,
|
|
|
c313de |
+ group->legacy[controller].mountPoint,
|
|
|
c313de |
+ group->legacy[controller].placement,
|
|
|
c313de |
key ? key : "") < 0)
|
|
|
c313de |
return -1;
|
|
|
c313de |
|
|
|
c313de |
@@ -618,7 +618,7 @@ virCgroupV1MakeGroup(virCgroupPtr parent,
|
|
|
c313de |
}
|
|
|
c313de |
|
|
|
c313de |
/* Skip over controllers that aren't mounted */
|
|
|
c313de |
- if (!group->controllers[i].mountPoint) {
|
|
|
c313de |
+ if (!group->legacy[i].mountPoint) {
|
|
|
c313de |
VIR_DEBUG("Skipping unmounted controller %s",
|
|
|
c313de |
virCgroupV1ControllerTypeToString(i));
|
|
|
c313de |
continue;
|
|
|
c313de |
@@ -639,7 +639,7 @@ virCgroupV1MakeGroup(virCgroupPtr parent,
|
|
|
c313de |
* treat blkio as unmounted if mkdir fails. */
|
|
|
c313de |
if (i == VIR_CGROUP_CONTROLLER_BLKIO) {
|
|
|
c313de |
VIR_DEBUG("Ignoring mkdir failure with blkio controller. Kernel probably too old");
|
|
|
c313de |
- VIR_FREE(group->controllers[i].mountPoint);
|
|
|
c313de |
+ VIR_FREE(group->legacy[i].mountPoint);
|
|
|
c313de |
continue;
|
|
|
c313de |
} else {
|
|
|
c313de |
virReportSystemError(errno,
|
|
|
c313de |
@@ -649,7 +649,7 @@ virCgroupV1MakeGroup(virCgroupPtr parent,
|
|
|
c313de |
}
|
|
|
c313de |
}
|
|
|
c313de |
if (i == VIR_CGROUP_CONTROLLER_CPUSET &&
|
|
|
c313de |
- group->controllers[i].mountPoint != NULL &&
|
|
|
c313de |
+ group->legacy[i].mountPoint != NULL &&
|
|
|
c313de |
virCgroupV1CpuSetInherit(parent, group) < 0) {
|
|
|
c313de |
return -1;
|
|
|
c313de |
}
|
|
|
c313de |
@@ -659,7 +659,7 @@ virCgroupV1MakeGroup(virCgroupPtr parent,
|
|
|
c313de |
*/
|
|
|
c313de |
if ((flags & VIR_CGROUP_MEM_HIERACHY) &&
|
|
|
c313de |
i == VIR_CGROUP_CONTROLLER_MEMORY &&
|
|
|
c313de |
- group->controllers[i].mountPoint != NULL &&
|
|
|
c313de |
+ group->legacy[i].mountPoint != NULL &&
|
|
|
c313de |
virCgroupV1SetMemoryUseHierarchy(group) < 0) {
|
|
|
c313de |
return -1;
|
|
|
c313de |
}
|
|
|
c313de |
@@ -682,7 +682,7 @@ virCgroupV1Remove(virCgroupPtr group)
|
|
|
c313de |
VIR_AUTOFREE(char *) grppath = NULL;
|
|
|
c313de |
|
|
|
c313de |
/* Skip over controllers not mounted */
|
|
|
c313de |
- if (!group->controllers[i].mountPoint)
|
|
|
c313de |
+ if (!group->legacy[i].mountPoint)
|
|
|
c313de |
continue;
|
|
|
c313de |
|
|
|
c313de |
/* We must never rmdir() in systemd's hierarchy */
|
|
|
c313de |
@@ -691,7 +691,7 @@ virCgroupV1Remove(virCgroupPtr group)
|
|
|
c313de |
|
|
|
c313de |
/* Don't delete the root group, if we accidentally
|
|
|
c313de |
ended up in it for some reason */
|
|
|
c313de |
- if (STREQ(group->controllers[i].placement, "/"))
|
|
|
c313de |
+ if (STREQ(group->legacy[i].placement, "/"))
|
|
|
c313de |
continue;
|
|
|
c313de |
|
|
|
c313de |
if (virCgroupV1PathOfController(group,
|
|
|
c313de |
@@ -719,7 +719,7 @@ virCgroupV1AddTask(virCgroupPtr group,
|
|
|
c313de |
|
|
|
c313de |
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
|
c313de |
/* Skip over controllers not mounted */
|
|
|
c313de |
- if (!group->controllers[i].mountPoint)
|
|
|
c313de |
+ if (!group->legacy[i].mountPoint)
|
|
|
c313de |
continue;
|
|
|
c313de |
|
|
|
c313de |
/* We must never add tasks in systemd's hierarchy
|
|
|
c313de |
@@ -766,17 +766,17 @@ virCgroupV1IdentifyRoot(virCgroupPtr group)
|
|
|
c313de |
|
|
|
c313de |
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
|
c313de |
char *tmp;
|
|
|
c313de |
- if (!group->controllers[i].mountPoint)
|
|
|
c313de |
+ if (!group->legacy[i].mountPoint)
|
|
|
c313de |
continue;
|
|
|
c313de |
- if (!(tmp = strrchr(group->controllers[i].mountPoint, '/'))) {
|
|
|
c313de |
+ if (!(tmp = strrchr(group->legacy[i].mountPoint, '/'))) {
|
|
|
c313de |
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
|
c313de |
_("Could not find directory separator in %s"),
|
|
|
c313de |
- group->controllers[i].mountPoint);
|
|
|
c313de |
+ group->legacy[i].mountPoint);
|
|
|
c313de |
return NULL;
|
|
|
c313de |
}
|
|
|
c313de |
|
|
|
c313de |
- if (VIR_STRNDUP(ret, group->controllers[i].mountPoint,
|
|
|
c313de |
- tmp - group->controllers[i].mountPoint) < 0)
|
|
|
c313de |
+ if (VIR_STRNDUP(ret, group->legacy[i].mountPoint,
|
|
|
c313de |
+ tmp - group->legacy[i].mountPoint) < 0)
|
|
|
c313de |
return NULL;
|
|
|
c313de |
return ret;
|
|
|
c313de |
}
|
|
|
c313de |
@@ -820,44 +820,44 @@ virCgroupV1BindMount(virCgroupPtr group,
|
|
|
c313de |
}
|
|
|
c313de |
|
|
|
c313de |
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
|
c313de |
- if (!group->controllers[i].mountPoint)
|
|
|
c313de |
+ if (!group->legacy[i].mountPoint)
|
|
|
c313de |
continue;
|
|
|
c313de |
|
|
|
c313de |
- if (!virFileExists(group->controllers[i].mountPoint)) {
|
|
|
c313de |
+ if (!virFileExists(group->legacy[i].mountPoint)) {
|
|
|
c313de |
VIR_AUTOFREE(char *) src = NULL;
|
|
|
c313de |
if (virAsprintf(&src, "%s%s",
|
|
|
c313de |
oldroot,
|
|
|
c313de |
- group->controllers[i].mountPoint) < 0)
|
|
|
c313de |
+ group->legacy[i].mountPoint) < 0)
|
|
|
c313de |
return -1;
|
|
|
c313de |
|
|
|
c313de |
VIR_DEBUG("Create mount point '%s'",
|
|
|
c313de |
- group->controllers[i].mountPoint);
|
|
|
c313de |
- if (virFileMakePath(group->controllers[i].mountPoint) < 0) {
|
|
|
c313de |
+ group->legacy[i].mountPoint);
|
|
|
c313de |
+ if (virFileMakePath(group->legacy[i].mountPoint) < 0) {
|
|
|
c313de |
virReportSystemError(errno,
|
|
|
c313de |
_("Unable to create directory %s"),
|
|
|
c313de |
- group->controllers[i].mountPoint);
|
|
|
c313de |
+ group->legacy[i].mountPoint);
|
|
|
c313de |
return -1;
|
|
|
c313de |
}
|
|
|
c313de |
|
|
|
c313de |
- if (mount(src, group->controllers[i].mountPoint, "none", MS_BIND,
|
|
|
c313de |
+ if (mount(src, group->legacy[i].mountPoint, "none", MS_BIND,
|
|
|
c313de |
NULL) < 0) {
|
|
|
c313de |
virReportSystemError(errno,
|
|
|
c313de |
_("Failed to bind cgroup '%s' on '%s'"),
|
|
|
c313de |
- src, group->controllers[i].mountPoint);
|
|
|
c313de |
+ src, group->legacy[i].mountPoint);
|
|
|
c313de |
return -1;
|
|
|
c313de |
}
|
|
|
c313de |
}
|
|
|
c313de |
|
|
|
c313de |
- if (group->controllers[i].linkPoint) {
|
|
|
c313de |
+ if (group->legacy[i].linkPoint) {
|
|
|
c313de |
VIR_DEBUG("Link mount point '%s' to '%s'",
|
|
|
c313de |
- group->controllers[i].mountPoint,
|
|
|
c313de |
- group->controllers[i].linkPoint);
|
|
|
c313de |
- if (symlink(group->controllers[i].mountPoint,
|
|
|
c313de |
- group->controllers[i].linkPoint) < 0) {
|
|
|
c313de |
+ group->legacy[i].mountPoint,
|
|
|
c313de |
+ group->legacy[i].linkPoint);
|
|
|
c313de |
+ if (symlink(group->legacy[i].mountPoint,
|
|
|
c313de |
+ group->legacy[i].linkPoint) < 0) {
|
|
|
c313de |
virReportSystemError(errno,
|
|
|
c313de |
_("Unable to symlink directory %s to %s"),
|
|
|
c313de |
- group->controllers[i].mountPoint,
|
|
|
c313de |
- group->controllers[i].linkPoint);
|
|
|
c313de |
+ group->legacy[i].mountPoint,
|
|
|
c313de |
+ group->legacy[i].linkPoint);
|
|
|
c313de |
return -1;
|
|
|
c313de |
}
|
|
|
c313de |
}
|
|
|
c313de |
@@ -885,11 +885,11 @@ virCgroupV1SetOwner(virCgroupPtr cgroup,
|
|
|
c313de |
if (!((1 << i) & controllers))
|
|
|
c313de |
continue;
|
|
|
c313de |
|
|
|
c313de |
- if (!cgroup->controllers[i].mountPoint)
|
|
|
c313de |
+ if (!cgroup->legacy[i].mountPoint)
|
|
|
c313de |
continue;
|
|
|
c313de |
|
|
|
c313de |
- if (virAsprintf(&base, "%s%s", cgroup->controllers[i].mountPoint,
|
|
|
c313de |
- cgroup->controllers[i].placement) < 0)
|
|
|
c313de |
+ if (virAsprintf(&base, "%s%s", cgroup->legacy[i].mountPoint,
|
|
|
c313de |
+ cgroup->legacy[i].placement) < 0)
|
|
|
c313de |
goto cleanup;
|
|
|
c313de |
|
|
|
c313de |
if (virDirOpen(&dh, base) < 0)
|
|
|
c313de |
diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c
|
|
|
c313de |
index 588a6e824d..c4bf987ca1 100644
|
|
|
c313de |
--- a/tests/vircgrouptest.c
|
|
|
c313de |
+++ b/tests/vircgrouptest.c
|
|
|
c313de |
@@ -56,25 +56,25 @@ static int validateCgroup(virCgroupPtr cgroup,
|
|
|
c313de |
|
|
|
c313de |
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
|
c313de |
if (STRNEQ_NULLABLE(expectMountPoint[i],
|
|
|
c313de |
- cgroup->controllers[i].mountPoint)) {
|
|
|
c313de |
+ cgroup->legacy[i].mountPoint)) {
|
|
|
c313de |
fprintf(stderr, "Wrong mount '%s', expected '%s' for '%s'\n",
|
|
|
c313de |
- cgroup->controllers[i].mountPoint,
|
|
|
c313de |
+ cgroup->legacy[i].mountPoint,
|
|
|
c313de |
expectMountPoint[i],
|
|
|
c313de |
virCgroupControllerTypeToString(i));
|
|
|
c313de |
return -1;
|
|
|
c313de |
}
|
|
|
c313de |
if (STRNEQ_NULLABLE(expectLinkPoint[i],
|
|
|
c313de |
- cgroup->controllers[i].linkPoint)) {
|
|
|
c313de |
+ cgroup->legacy[i].linkPoint)) {
|
|
|
c313de |
fprintf(stderr, "Wrong link '%s', expected '%s' for '%s'\n",
|
|
|
c313de |
- cgroup->controllers[i].linkPoint,
|
|
|
c313de |
+ cgroup->legacy[i].linkPoint,
|
|
|
c313de |
expectLinkPoint[i],
|
|
|
c313de |
virCgroupControllerTypeToString(i));
|
|
|
c313de |
return -1;
|
|
|
c313de |
}
|
|
|
c313de |
if (STRNEQ_NULLABLE(expectPlacement[i],
|
|
|
c313de |
- cgroup->controllers[i].placement)) {
|
|
|
c313de |
+ cgroup->legacy[i].placement)) {
|
|
|
c313de |
fprintf(stderr, "Wrong placement '%s', expected '%s' for '%s'\n",
|
|
|
c313de |
- cgroup->controllers[i].placement,
|
|
|
c313de |
+ cgroup->legacy[i].placement,
|
|
|
c313de |
expectPlacement[i],
|
|
|
c313de |
virCgroupControllerTypeToString(i));
|
|
|
c313de |
return -1;
|
|
|
c313de |
@@ -174,7 +174,7 @@ testCgroupDetectMounts(const void *args)
|
|
|
c313de |
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
|
|
c313de |
virBufferAsprintf(&buf, "%-12s %s\n",
|
|
|
c313de |
virCgroupControllerTypeToString(i),
|
|
|
c313de |
- NULLSTR(group->controllers[i].mountPoint));
|
|
|
c313de |
+ NULLSTR(group->legacy[i].mountPoint));
|
|
|
c313de |
}
|
|
|
c313de |
if (virBufferCheckError(&buf) < 0)
|
|
|
c313de |
goto cleanup;
|
|
|
c313de |
--
|
|
|
c313de |
2.22.0
|
|
|
c313de |
|