]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
api: Support specifying controllers in cgroup_get_cgroup()
authorTom Hromatka <tom.hromatka@oracle.com>
Tue, 14 Feb 2023 19:53:03 +0000 (12:53 -0700)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 22 Feb 2023 16:17:28 +0000 (09:17 -0700)
commit6bb000d2dc90eb0e9966bba0aaf70c0daa655e09
treebe37c27e2a43a70f61040efb3c9f467a6fe7aeaf
parent94ba8b65f8b3424232cf3fea5a06fbbfb921789a
api: Support specifying controllers in cgroup_get_cgroup()

Add support for the user to explicitly specify controllers of interest
when calling cgroup_get_cgroup().  Controllers not specified will not
be added to the struct cgroup.  Also, this allows users to view cgroup
v2 controllers that aren't enabled.  This may be useful for seeing
settings like cpuset.cpus.effective even when the cpuset controller
isn't enabled.

If no controllers are specified, then the previous behavior should be
utilized.  All controllers that are enabled for that cgroup will be
added to the struct cgroup.

Here is a simple example python program that exercises these changes:
#!/usr/bin/env python3
from libcgroup import Cgroup, Version

cg = Cgroup('user.slice', Version.CGROUP_V2)
cg.add_controller('cpuset')
cg.get()

print(cg)

Reported-by: Justin Israel <justinisrael@gmail.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/api.c