From: Michal Privoznik <mprivozn@redhat.com> The freezer controller in CGroupsV2 is always present (under cgroup.freeze file). Make our vircgroupv2 backend aware of it. NB, because of the way our backends are ordered (v2 is prefered) the v1 freezer is never going to be used when CGroupsV2 are detected. Hence the change to tests. NB2, this also fixes output of virt-host-validate which complains that the 'freezer' controller is not present for LXC driver. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/vircgroupv2.c | 5 +++++ tests/vircgroupdata/hybrid.parsed | 2 +- tests/vircgrouptest.c | 5 +++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/util/vircgroupv2.c b/src/util/vircgroupv2.c index eaf5ae98f6..3fbd67fbda 100644 --- a/src/util/vircgroupv2.c +++ b/src/util/vircgroupv2.c @@ -319,6 +319,10 @@ virCgroupV2DetectControllers(virCgroup *group, * exists with usage stats. */ group->unified.controllers |= 1 << VIR_CGROUP_CONTROLLER_CPUACCT; + /* Similarly, the freezer controller is always available via cgroup.freeze + * file. */ + group->unified.controllers |= 1 << VIR_CGROUP_CONTROLLER_FREEZER; + if (virCgroupV2DevicesAvailable(group)) group->unified.controllers |= 1 << VIR_CGROUP_CONTROLLER_DEVICES; @@ -480,6 +484,7 @@ virCgroupV2MakeGroup(virCgroup *parent, /* Controllers that are implicitly enabled if available. */ if (i == VIR_CGROUP_CONTROLLER_CPUACCT || + i == VIR_CGROUP_CONTROLLER_FREEZER || i == VIR_CGROUP_CONTROLLER_DEVICES) { continue; } diff --git a/tests/vircgroupdata/hybrid.parsed b/tests/vircgroupdata/hybrid.parsed index f755eed465..e92abacc7a 100644 --- a/tests/vircgroupdata/hybrid.parsed +++ b/tests/vircgroupdata/hybrid.parsed @@ -3,7 +3,7 @@ cpuacct <null> cpuset /not/really/sys/fs/cgroup/cpuset memory <null> devices <null> -freezer /not/really/sys/fs/cgroup/freezer +freezer <null> blkio <null> net_cls /not/really/sys/fs/cgroup/net_cls perf_event /not/really/sys/fs/cgroup/perf_event diff --git a/tests/vircgrouptest.c b/tests/vircgrouptest.c index 0e7645af7a..eb85b6d012 100644 --- a/tests/vircgrouptest.c +++ b/tests/vircgrouptest.c @@ -529,6 +529,7 @@ static int testCgroupNewForSelfUnified(const void *args G_GNUC_UNUSED) (1 << VIR_CGROUP_CONTROLLER_CPUACCT) | (1 << VIR_CGROUP_CONTROLLER_MEMORY) | (1 << VIR_CGROUP_CONTROLLER_DEVICES) | + (1 << VIR_CGROUP_CONTROLLER_FREEZER) | (1 << VIR_CGROUP_CONTROLLER_BLKIO); if (virCgroupNewSelf(&cgroup) < 0) { @@ -547,13 +548,11 @@ static int testCgroupNewForSelfHybrid(const void *args G_GNUC_UNUSED) const char *empty[VIR_CGROUP_CONTROLLER_LAST] = { 0 }; const char *mounts[VIR_CGROUP_CONTROLLER_LAST] = { [VIR_CGROUP_CONTROLLER_CPUSET] = "/not/really/sys/fs/cgroup/cpuset", - [VIR_CGROUP_CONTROLLER_FREEZER] = "/not/really/sys/fs/cgroup/freezer", [VIR_CGROUP_CONTROLLER_NET_CLS] = "/not/really/sys/fs/cgroup/net_cls", [VIR_CGROUP_CONTROLLER_PERF_EVENT] = "/not/really/sys/fs/cgroup/perf_event", }; const char *placement[VIR_CGROUP_CONTROLLER_LAST] = { [VIR_CGROUP_CONTROLLER_CPUSET] = "/", - [VIR_CGROUP_CONTROLLER_FREEZER] = "/", [VIR_CGROUP_CONTROLLER_NET_CLS] = "/", [VIR_CGROUP_CONTROLLER_PERF_EVENT] = "/", }; @@ -562,6 +561,7 @@ static int testCgroupNewForSelfHybrid(const void *args G_GNUC_UNUSED) (1 << VIR_CGROUP_CONTROLLER_CPUACCT) | (1 << VIR_CGROUP_CONTROLLER_MEMORY) | (1 << VIR_CGROUP_CONTROLLER_DEVICES) | + (1 << VIR_CGROUP_CONTROLLER_FREEZER) | (1 << VIR_CGROUP_CONTROLLER_BLKIO); if (virCgroupNewSelf(&cgroup) < 0) { @@ -619,6 +619,7 @@ static int testCgroupNewForSelfSystemdUnified(const void *args G_GNUC_UNUSED) (1 << VIR_CGROUP_CONTROLLER_CPUACCT) | (1 << VIR_CGROUP_CONTROLLER_MEMORY) | (1 << VIR_CGROUP_CONTROLLER_DEVICES) | + (1 << VIR_CGROUP_CONTROLLER_FREEZER) | (1 << VIR_CGROUP_CONTROLLER_BLKIO); if (virCgroupNewSelf(&cgroup) < 0) { -- 2.53.0