]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
tools/cgexec: add support for default systemd delegation slice/scope
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Tue, 31 Jan 2023 06:24:37 +0000 (06:24 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Fri, 10 Feb 2023 21:44:25 +0000 (14:44 -0700)
commitbad8137c6d7741ecd5ff48cfd7ede2ceabde93ea
tree573c94e2fa795f0b5d93c9220d248f030ece5ed3
parent08ee9e36dee97bd32b0e648090b2e7570a1935fb
tools/cgexec: add support for default systemd delegation slice/scope

Enhance the cgexec tool to support default systemd delegation
slice/scope, if set in the cgconfig.conf's systemd setting.  Parse  the
configuration file and read the systemd::delegate setting, if any, and
set it as the default systemd slice/scope in
systemd_default_cgroup. Setting it appends the slice/scope
name to the constructed default cgroup mount path.

When the user passes the relative cgroup name, its appends to the
sub-tree (delegated slice/scope) by default and if the user wishes to
create a cgroup in another subtree or cgroup root hierarchy, they need
to use the absolute path. For example:

                          cgroup_root
                         /          \
                        /            \
                 systemd.slice*      cgrp1
                        |
                 systemd.scope
                        |
                    cgrp-d1

* default system delegation slice/scope - read from cgconfig.conf
$ sudo cgexec -g cpu:cgrp-d1 sleep 10

will create the cgroup under the cpu controller hirearchy
cgroup_root:systemd_default_cgroup:cgrp-d1

and for creating a cgroup cgrp1, the user can use:
$ sudo cgexec -g cpu:/cgrp1 sleep 10

or use the newly introduced -b switch to ignore the systemd slice/scope:
$ sudo cgexec -b -g cpu:cgrp1 sleep 10

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