]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
config: Support systemd's slice/scope creation/delegation using configuration
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 8 Feb 2023 09:22:29 +0000 (14:52 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Fri, 10 Feb 2023 21:44:14 +0000 (14:44 -0700)
commit4fd38393d3934e62351a680bdad0c9f4deb4d3d2
tree1fc482ad0da3825cc0d4e919605bccad8231be5e
parente751b3236c7ed2544e49f377bb6356872b313c31
config: Support systemd's slice/scope creation/delegation using configuration

Add support for the creation of systemd slices and scopes (transient).
Users can create a systemd slice and scope using the new setting
'systemd' in the cgconfig.conf.

$ cat /etc/cgconfig.conf
...
systemd {
        slice = database.slice;
        scope = db.scope;
        setdefault = yes;
}

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

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

systemd configuration requires two mandatory settings, slice and scope,
those represent the systemd slice and scope name and other optional
settings are 'setdefault', that allows the users to append one of the
systemd slice/scope name to as default cgroup root, making the delegated
subtree as the new cgroup root, i.e., the default cgroup path is
changed to '/sys/fs/cgroup/database.slice/db.scope/' from
'/sys/fs/cgroup/', this is useful to the libcgroup tools, where users
can work on new subtree hierarchy, they created and other optional
setting is pid, which can be used as the default task for transient
scope, created by us, by default a task that spins an idle loop is
created and set as default task.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Fix minor typos in a couple comments where delegate was written
     instead of setdefault
TJH: Explicitly initialize the list head and tail to NULL.  May not be
     needed but better safe than sorry
include/libcgroup/systemd.h
src/Makefile.am
src/api.c
src/config.c
src/lex.l
src/libcgroup-internal.h
src/parse.y