]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vircgroupv2: Freezer controller is implicit
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 23 Apr 2026 10:05:44 +0000 (12:05 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 4 May 2026 07:05:34 +0000 (09:05 +0200)
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>
Reviewed-by: Pavel Hrdina <pavel@hrdina.info>
src/util/vircgroupv2.c
tests/vircgroupdata/hybrid.parsed
tests/vircgrouptest.c

index eaf5ae98f6f0e0872e569ea6f19be92ae3bbbdd6..3fbd67fbda7ac417a4c1ecce2b88a2bd85b1e5b6 100644 (file)
@@ -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;
                 }
index f755eed46598b2185995fcc67c1d84d698045177..e92abacc7a6b697cc1bc90ba7ecedc73c73fa3de 100644 (file)
@@ -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
index 0e7645af7a79b79b17b5de8a10084bfdbec1ba8f..eb85b6d01217d8fa7ed0eb5728be1546b5a3a4a3 100644 (file)
@@ -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) {