提交 7bca1c9b 编写于 作者: P Pavel Hrdina

util: vircgroup: pass parent cgroup into virCgroupDetectControllersCB

In cgroups v2 we don't have to detect available controllers every single
time if we are creating a new cgroup based on parent cgroup.
Signed-off-by: NPavel Hrdina <phrdina@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 7d5b2830
......@@ -383,7 +383,7 @@ 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);
int rc = group->backends[i]->detectControllers(group, controllers, parent);
if (rc < 0)
return -1;
controllersAvailable |= rc;
......
......@@ -95,7 +95,8 @@ typedef char *
typedef int
(*virCgroupDetectControllersCB)(virCgroupPtr group,
int controllers);
int controllers,
virCgroupPtr parent);
typedef bool
(*virCgroupHasControllerCB)(virCgroupPtr cgroup,
......
......@@ -420,7 +420,8 @@ virCgroupV1StealPlacement(virCgroupPtr group)
static int
virCgroupV1DetectControllers(virCgroupPtr group,
int controllers)
int controllers,
virCgroupPtr parent ATTRIBUTE_UNUSED)
{
size_t i;
size_t j;
......
......@@ -285,16 +285,21 @@ virCgroupV2ParseControllersFile(virCgroupPtr group)
static int
virCgroupV2DetectControllers(virCgroupPtr group,
int controllers)
int controllers,
virCgroupPtr parent)
{
size_t i;
if (virCgroupV2ParseControllersFile(group) < 0)
return -1;
if (parent) {
group->unified.controllers = parent->unified.controllers;
} else {
if (virCgroupV2ParseControllersFile(group) < 0)
return -1;
/* In cgroup v2 there is no cpuacct controller, the cpu.stat file always
* exists with usage stats. */
group->unified.controllers |= 1 << VIR_CGROUP_CONTROLLER_CPUACCT;
/* In cgroup v2 there is no cpuacct controller, the cpu.stat file always
* exists with usage stats. */
group->unified.controllers |= 1 << VIR_CGROUP_CONTROLLER_CPUACCT;
}
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++)
VIR_DEBUG("Controller '%s' present=%s",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册