]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
cgconfig: auto convert cgroup controller versions
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 12 Apr 2023 09:15:01 +0000 (14:45 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 12 Apr 2023 13:44:35 +0000 (07:44 -0600)
commit0c421124756a80617612ea1daf55a3c8b16e6b41
treee6c6017033bd41661bf9edec5d797e37c85cb3a7
parent0c65a402990d8657637b10bb4ae02f99ae575082
cgconfig: auto convert cgroup controller versions

The user might be using cgroup v1 controller settings in the
cgconfig.conf and when migrating to the cgroup v2 setup, they are
required to manually edit the cgconfig.conf file to map v1 controllers
settings to that of v2 settings, this might be cumbersome activity.
This patch tries to address the mapping issue, by silently mapping
the possible controller settings to the current cgroup setup.

Consider the scenario:
$ cgget -m
Unified Mode (Cgroup v2 only).

$ cat cgconfig.conf
group foo {
        cpu {
                cpu.shares = 512;
                cpu.cfs_quota_us = 5000;
        }
        cpuset {
                cpuset.cpus = 0-1;
        }
}

the cpu controller settings are of cgroup v1 but the system is booted
into cgroup v2 setup. Running cgconfigparser without the patch, the user
will be warned about invalid settings and the parser will exit.

$ sudo cgconfigparser -l ./cgconfig.conf
cgconfigparser; error loading cgconfig.conf: Cgroup, requested group parameter does not exist

with this patch, cgconfigparser will attempt to convert the settings.
$ sudo cgconfigparser -l ./cgconfig.conf
$ cat /sys/fs/cgroup/foo/cpu.weight
50
$ cat /sys/fs/cgroup/foo/cpu.max
5000 100000

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/config.c