mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
util: vircgroup: improve controller detection
This affects only cgroups v2 where enabled controllers are not based on available mount points but on the list provided in cgroup.controllers file. However, moving it will fill in placement as well, so it needs to be freed together with mount point if we don't need that controller. Before this patch we were assuming that all controllers available in root cgroup where available in all other sub-cgroups which was wrong. In order to fix it we need to move the cgroup controllers detection after cgroup placement was prepared in order to build correct path for cgroup.controllers file. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
7bca1c9bdc
commit
d3007c844d
@ -381,22 +381,6 @@ virCgroupDetect(virCgroupPtr group,
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
||||
if (group->backends[i]) {
|
||||
int rc = group->backends[i]->detectControllers(group, controllers, parent);
|
||||
if (rc < 0)
|
||||
return -1;
|
||||
controllersAvailable |= rc;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check that at least 1 controller is available */
|
||||
if (controllersAvailable == 0) {
|
||||
virReportSystemError(ENXIO, "%s",
|
||||
_("At least one cgroup controller is required"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* In some cases we can copy part of the placement info
|
||||
* based on the parent cgroup...
|
||||
*/
|
||||
@ -421,6 +405,22 @@ virCgroupDetect(virCgroupPtr group,
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < VIR_CGROUP_BACKEND_TYPE_LAST; i++) {
|
||||
if (group->backends[i]) {
|
||||
int rc = group->backends[i]->detectControllers(group, controllers, parent);
|
||||
if (rc < 0)
|
||||
return -1;
|
||||
controllersAvailable |= rc;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check that at least 1 controller is available */
|
||||
if (controllersAvailable == 0) {
|
||||
virReportSystemError(ENXIO, "%s",
|
||||
_("At least one cgroup controller is required"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -464,6 +464,7 @@ virCgroupV1DetectControllers(virCgroupPtr group,
|
||||
}
|
||||
}
|
||||
VIR_FREE(group->legacy[i].mountPoint);
|
||||
VIR_FREE(group->legacy[i].placement);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -250,8 +250,9 @@ virCgroupV2ParseControllersFile(virCgroupPtr group)
|
||||
char **contList = NULL;
|
||||
char **tmp;
|
||||
|
||||
if (virAsprintf(&contFile, "%s/cgroup.controllers",
|
||||
group->unified.mountPoint) < 0)
|
||||
if (virAsprintf(&contFile, "%s%s/cgroup.controllers",
|
||||
group->unified.mountPoint,
|
||||
NULLSTR_EMPTY(group->unified.placement)) < 0)
|
||||
return -1;
|
||||
|
||||
rc = virFileReadAll(contFile, 1024 * 1024, &contStr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user