]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
api: cg_build_path_locked() - support default systemd delegate scope
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 8 Feb 2023 09:40:23 +0000 (15:10 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Fri, 10 Feb 2023 21:44:25 +0000 (14:44 -0700)
commite4ec9a941ec0d1a92934a97a4226bb1fe14a34aa
tree6eb4463b53d72e72c2b8b0b25d56449ccb9e4a61
parent4fd38393d3934e62351a680bdad0c9f4deb4d3d2
api: cg_build_path_locked() - support default systemd delegate scope

Add support to build cgroup path to the default systemd slice/scope
cgroup, if setdefault is set in the systemd configuration of the
cgconfig.conf.

$ cat /etc/cgconfig.conf
...
systemd {
    slice = database.slice;
    scope = db.scope;
    setdefault = yes; <--  set cgroup root path to '/sys/fs/cgroup/database.slice/db.scope/'
}

systemd {
    slice = database.slice;
    scope = house_keeping.scope;
    pid = 3241;
}

systemd {
    slice = others.slice;
    scope = server.scope;
}

cg_build_path() constructs the cgroup path to the mount point of the
given cgroup controller. With the support for the default systemd scope,
the default cgroup path for the controller, appends the slice/scope
name, making it the default cgroup root.

Allowing the users to set their default cgroup path from
'/sys/fs/cgroup/' to
'/sys/fs/cgroup/<systemd slice name>/<systemd scope name>/', while
using the libcgroup tools, allowing them to work on the delegated
cgroup hierarchy.

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