]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
tools/cgdelete: add support for default systemd delegation slice/scope
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Fri, 10 Feb 2023 21:48:48 +0000 (14:48 -0700)
committerTom Hromatka <tom.hromatka@oracle.com>
Fri, 10 Feb 2023 21:48:55 +0000 (14:48 -0700)
commitd9e8c5c4b7b76e4039b33146b9144fa8563be75f
treebaecc8556eefa62f94ff4543f3732a0b0566c8d9
parent04b44514288156b1fe6351d73fc3047f3b46a18e
tools/cgdelete: add support for default systemd delegation slice/scope

Enhance the cgdelete 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
delete the cgroups 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 cgdelete -g cpu:cgrp-d1

will delete the cgroup cgrp-d1 under the
cgroup_root:systemd_default_cgroup:cgrp-d1

and for deleting the cgroup cgrp1, the user can use:
$ sudo cgdelete -g cpu:/cgrp1

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

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 529f0e77f4e252187298a4e91c891efc1223cd56)
src/tools/cgdelete.c