]> git.ipfire.org Git - thirdparty/libcgroup.git/log
thirdparty/libcgroup.git
3 years agotest-013: make it PEP8 compliant
Kamalesh Babulal [Tue, 15 Feb 2022 07:03:06 +0000 (12:33 +0530)] 
test-013: make it PEP8 compliant

Make test 013-cgget-multiple_g_flags.py PEP-8 compliant.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agotest-012: make it PEP8 compliant
Kamalesh Babulal [Tue, 15 Feb 2022 07:02:43 +0000 (12:32 +0530)] 
test-012: make it PEP8 compliant

Make test 012-cgget-multiple_r_flags2.py PEP-8 compliant.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agotest-011: make it PEP8 compliant
Kamalesh Babulal [Tue, 15 Feb 2022 07:02:25 +0000 (12:32 +0530)] 
test-011: make it PEP8 compliant

Make test 011-cgget-r_flag_two_cgroups.py PEP-8 compliant.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agotest-010: make it PEP8 compliant
Kamalesh Babulal [Tue, 15 Feb 2022 07:02:02 +0000 (12:32 +0530)] 
test-010: make it PEP8 compliant

Make test 010-cgget-g_flag_controller_and_cgroup.py PEP-8 compliant.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agotest-009: make it PEP8 compliant
Kamalesh Babulal [Tue, 15 Feb 2022 07:01:23 +0000 (12:31 +0530)] 
test-009: make it PEP8 compliant

Make test 009-cgget-g_flag_controller_only.py PEP-8 compliant.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agotest-008: make it PEP8 compliant
Kamalesh Babulal [Tue, 15 Feb 2022 07:00:59 +0000 (12:30 +0530)] 
test-008: make it PEP8 compliant

Make test 008-cgget-multiple_r_flags.py PEP-8 compliant.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agotest-007: make it PEP8 compliant
Kamalesh Babulal [Tue, 15 Feb 2022 07:00:32 +0000 (12:30 +0530)] 
test-007: make it PEP8 compliant

Make test 007-cgrules-basic_cgrules_v2.py PEP-8 compliant.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agotest-006: make it PEP8 compliant
Kamalesh Babulal [Tue, 15 Feb 2022 06:59:47 +0000 (12:29 +0530)] 
test-006: make it PEP8 compliant

Make test 006-cgrules-basic_cgrules_v1.py PEP-8 compliant.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agotest-005: make it PEP8 compliant
Kamalesh Babulal [Tue, 15 Feb 2022 06:58:11 +0000 (12:28 +0530)] 
test-005: make it PEP8 compliant

Make test 005-cgsnapshot-basic_snapshot_v2.py PEP-8 compliant.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agotest-004: make it PEP8 complaint
Kamalesh Babulal [Wed, 16 Feb 2022 06:19:43 +0000 (11:49 +0530)] 
test-004: make it PEP8 complaint

Make test 004-cgsnapshot-basic_snapshot_v1.py PEP-8 complaint.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agotest-003: make it PEP8 compliant
Kamalesh Babulal [Tue, 15 Feb 2022 06:52:53 +0000 (12:22 +0530)] 
test-003: make it PEP8 compliant

Make test 003-cgget-basic_cgget_v2.py PEP-8 compliant.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agotest-002: make it PEP8 compliant
Kamalesh Babulal [Tue, 15 Feb 2022 06:52:26 +0000 (12:22 +0530)] 
test-002: make it PEP8 compliant

Make test 002-cgdelete-recursive_delete.py PEP-8 compliant.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agotest-001: make it PEP8 compliant
Kamalesh Babulal [Tue, 15 Feb 2022 06:46:03 +0000 (12:16 +0530)] 
test-001: make it PEP8 compliant

Make test 001-cgget-basic_cgget_v1.py PEP-8 compliant.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoREADME.md: Update the LGTM link
Tom Hromatka [Mon, 14 Feb 2022 15:25:15 +0000 (08:25 -0700)] 
README.md: Update the LGTM link

The LGTM badge linked to a comparison of libcgroup with
other open source projects.  Change the link to go directly
to libcgroup's alerts.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoapi.c: Fix TOCTOU race cgroup_get_cg_type()
Kamalesh Babulal [Mon, 14 Feb 2022 15:11:56 +0000 (08:11 -0700)] 
api.c: Fix TOCTOU race cgroup_get_cg_type()

Fix a TOCTOU race condition, that checks for file existence versus file
open in cgroup_get_cg_type() by opening the file and check for errno for
file existence.

Reported-by: LGTM
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoapi.c: fix a comparison error in cgroup_delete_cgroup_ext()
Kamalesh Babulal [Mon, 14 Feb 2022 15:11:39 +0000 (08:11 -0700)] 
api.c: fix a comparison error in cgroup_delete_cgroup_ext()

Fix a comparison logic in the first_errno assignment, that would
never get executed in the case of first_errno == ECGNONEMPTY in
cgroup_delete_cgroup_ext().

Reported-by: LGTM
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoapi: make cgroup_get_subsys_mount_point_end() more useful
Kamalesh Babulal [Mon, 14 Feb 2022 15:11:25 +0000 (08:11 -0700)] 
api: make cgroup_get_subsys_mount_point_end() more useful

Currently cgroup_get_subsys_mount_point_end(), does nothing more than
returning zero, it was caught by LGTM altering:
"This expression has no effect (because
cgroup_get_subsys_mount_point_end has no external side effects)."

make the function more useful like other *_end() functions by including
the check for cgroup_initialized and assigning NULL to the handle used
for iterating over controller mount points.

Reported-by: LGTM
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agowrapper: remove false checks for snprintf
Kamalesh Babulal [Mon, 14 Feb 2022 15:11:08 +0000 (08:11 -0700)] 
wrapper: remove false checks for snprintf

LGTM, reported that the negative value checks for snprintf() will
always be false.  The reason being the snprintf() are used to print
into a character buffer, hence chances of stream error or wide
characters encoding error are not valid here. Remove the negative
return value check across the file done after snprintf().

Reported-by: LGTM
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agotools/cgsnapshot: rename FILE *of to output_f
Kamalesh Babulal [Mon, 14 Feb 2022 15:10:43 +0000 (08:10 -0700)] 
tools/cgsnapshot: rename FILE *of to output_f

LGTM, complained about using FILE *of as shorthand for the output file
and recommended using something descriptive. Rename usage of with
output_f, to keep it happy.

Reported-by: LGTM
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoIntroduce vim modeline for python sources
Kamalesh Babulal [Mon, 14 Feb 2022 14:54:19 +0000 (07:54 -0700)] 
Introduce vim modeline for python sources

Introduce vim modeline to python source files. This sets up the
vim editor to PEP-8 recommend editing style. The vim modeline added:
"# vim: set et ts=4 sw=4:"

'et' converts the tabs to spaces, 'ts' set the tabs indentation/tabstop
to 4 characters and 'sw' sets the shiftwidth to 4 characters.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agodocs: add library version updates to release process
Kamalesh Babulal [Thu, 10 Feb 2022 21:49:29 +0000 (14:49 -0700)] 
docs: add library version updates to release process

Add step to update Major, Minor and Release versions in configure.ac to
both release documents.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoIntroduce vim modeline for python sources
Kamalesh Babulal [Thu, 10 Feb 2022 21:44:05 +0000 (14:44 -0700)] 
Introduce vim modeline for python sources

Introduce vim modeline to python source files. This sets up the
vim editor to PEP-8 recommend editing style. The vim modeline added:
"# vim: set et ts=4 sw=4:"

'et' converts the tabs to spaces, 'ts' set the tabs indentation/tabstop
to 4 characters and 'sw' sets the shiftwidth to 4 characters.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoMerge pull request #94 from drakenclimber/issues/emptycgcreate
Tom Hromatka [Thu, 10 Feb 2022 21:39:43 +0000 (14:39 -0700)] 
Merge pull request #94 from drakenclimber/issues/emptycgcreate

Add support for creating an empty cgroup v2 cgroup

3 years agopython: Add support to create a cgroup on-disk 94/head
Tom Hromatka [Wed, 9 Feb 2022 19:28:57 +0000 (12:28 -0700)] 
python: Add support to create a cgroup on-disk

Add support to the python bindings to create a cgroup
on disk.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agocgcreate, tools: Allow cgroup creation with no controllers attached
Tom Hromatka [Wed, 9 Feb 2022 19:28:44 +0000 (12:28 -0700)] 
cgcreate, tools: Allow cgroup creation with no controllers attached

Add support for creating a cgroup with no controllers attached.  This
is only supported on cgroup v2.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoapi.c: Refactor cgroup_create_cgroup()
Tom Hromatka [Wed, 9 Feb 2022 19:27:43 +0000 (12:27 -0700)] 
api.c: Refactor cgroup_create_cgroup()

Non-functional change to refactor cgroup_create_cgroup().  Move
the contents of this "for" loop to its own function:
for (k = 0; k < cgroup->index; k++)

This will be used as a building block for the next commit to allow
the creation of cgroups with no controllers attached.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoMerge pull request #34 from drakenclimber/issues/emptycgcreate
Tom Hromatka [Thu, 10 Feb 2022 21:13:00 +0000 (14:13 -0700)] 
Merge pull request #34 from drakenclimber/issues/emptycgcreate

Add tests for empty cgcreate

3 years agoftests: Add a python cgcreate test with an empty controller field
Tom Hromatka [Mon, 7 Feb 2022 22:03:38 +0000 (15:03 -0700)] 
ftests: Add a python cgcreate test with an empty controller field

Add a functional test that exercises the Python binding's
create() method with no controller specified.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Dec 24 14:59:32
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                            Time (sec)
        ----------------------------------------------------------
        setup                                                 0.00
        044-pybindings-cgcreate_empty_controller.py           0.04
        teardown                                              0.00
        ----------------------------------------------------------
        Total Run Time                                        0.04

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoftests: Add a cgreate test with an empty controller field
Tom Hromatka [Mon, 7 Feb 2022 21:59:22 +0000 (14:59 -0700)] 
ftests: Add a cgreate test with an empty controller field

Add a functional test that exercises cgcreate with no controller
specified, e.g.
cgcreate -g :foo
cgdelete -g :foo

-----------------------------------------------------------------
Test Results:
        Run Date:                          Dec 24 10:55:56
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                 Time (sec)
        -----------------------------------------------
        setup                                      0.00
        043-cgcreate-empty_controller.py           0.04
        teardown                                   0.00
        -----------------------------------------------
        Total Run Time                             0.04

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoapi.c: fix the buffer size to read /proc/cgroups
Kamalesh Babulal [Tue, 8 Feb 2022 16:44:50 +0000 (09:44 -0700)] 
api.c: fix the buffer size to read /proc/cgroups

In cgroup_init(), the first line/header of /proc/cgroups helps in
interpreting the values in the remaining of the file.  We are interested
in the rest of the file and a temporary buffer of size FILENAME_MAX is
allocated/deallocated after reading the header. The length of the header
is only 56 characters in length, excluding the newline. This patch
reduces it to LL_MAX a.k.a 100 characters.

LL_MAX is used instead of introducing another new length macro.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agolibcgroup-internal.h: remove FIXME comment
Kamalesh Babulal [Tue, 8 Feb 2022 16:44:36 +0000 (09:44 -0700)] 
libcgroup-internal.h: remove FIXME comment

As per Linux Kernel uidgid.h file, that represents internal Kernel types
for uids/gids. Initialized invalid uids/gids to -1:

  #define INVALID_UID KUIDT_INIT(-1)
  #define INVALID_GID KGIDT_INIT(-1)

initializing them to -1 is a valid, remove the FIXME comment that says
otherwise.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoapi.c: add return value check for strdup()
Kamalesh Babulal [Tue, 8 Feb 2022 16:44:19 +0000 (09:44 -0700)] 
api.c: add return value check for strdup()

In function cg_build_path_locked(), check for return value from
strdup(). This fixes, one of the long pending FIXME.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoerror.h: make errno number reading easier
Kamalesh Babulal [Tue, 8 Feb 2022 16:15:13 +0000 (09:15 -0700)] 
error.h: make errno number reading easier

Trying to match error number with enum requires manual effort. Make it
easier by adding a comment with errno for every enum value.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoMerge pull request #28 from drakenclimber/issues/cgxget5-pybindings4
Tom Hromatka [Thu, 3 Feb 2022 22:06:27 +0000 (15:06 -0700)] 
Merge pull request #28 from drakenclimber/issues/cgxget5-pybindings4

Cgroup v1/v2 Abstraction Layer Tests

3 years agogit: tools: Ignore cgxget and cgxset
Tom Hromatka [Wed, 15 Dec 2021 21:27:39 +0000 (21:27 +0000)] 
git: tools: Ignore cgxget and cgxset

Git ignore the executables cgxget and cgxset

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agogithub: Add a code coverage action
Tom Hromatka [Wed, 15 Dec 2021 21:27:26 +0000 (21:27 +0000)] 
github: Add a code coverage action

Add a code coverage action to the Github workflow.  As part
of this code coverage action, ignore the C file that is
auto-generated from the Cython code.  Also ignore a couple Python
header files that were confusing lcov.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agopython: Add python bindings using Cython
Tom Hromatka [Wed, 15 Dec 2021 21:26:02 +0000 (21:26 +0000)] 
python: Add python bindings using Cython

Add python bindings via the --enable-python configure flag.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agolibcgroup.so: Add a function to get the library version
Tom Hromatka [Wed, 15 Dec 2021 21:22:20 +0000 (21:22 +0000)] 
libcgroup.so: Add a function to get the library version

Add a function, cgroup_version(), that returns the current
version of the libcgroup library.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agocgxset: libcgroup.so: Add cgroup_cgxset() to library
Tom Hromatka [Fri, 28 Jan 2022 21:29:44 +0000 (14:29 -0700)] 
cgxset: libcgroup.so: Add cgroup_cgxset() to library

Add cgroup_cgxset() to libcgroup.so.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agocgxget: libcgroup.so: Add cgroup_cgxget() to library
Tom Hromatka [Fri, 28 Jan 2022 21:28:57 +0000 (14:28 -0700)] 
cgxget: libcgroup.so: Add cgroup_cgxget() to library

Add cgroup_cgxget() to libcgroup.so.  Create a new header
file, libcgroup/tools.h, to hold C APIs that are exported
from the tools folder.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agopython: Delete old python bindings
Tom Hromatka [Wed, 15 Dec 2021 21:04:06 +0000 (21:04 +0000)] 
python: Delete old python bindings

Remove the old python bindings.  They will be replaced with Cython
bindings in a subsequent commit.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agogithub: Skip test 38 (cpuset) on VMs hosted by Github Actions
Tom Hromatka [Wed, 15 Dec 2021 21:03:28 +0000 (21:03 +0000)] 
github: Skip test 38 (cpuset) on VMs hosted by Github Actions

Skip test #38 - 038-cgxget-cpuset_settings.py - on servers hosted
by Github Actions.  Test #38 sets/clears the cpuset exclusive bit
and this is not allowed on Github's servers.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoabstraction-map: Add unmappable cpuset cgroup v1 settings
Tom Hromatka [Mon, 31 Jan 2022 16:35:15 +0000 (09:35 -0700)] 
abstraction-map: Add unmappable cpuset cgroup v1 settings

Add several unmappable cpuset settings.  As the name implies, these
settings have no equivalent in cgroup v2:
cpuset.mem_exclusive
cpuset.mem_hardwall
cpuset.memory_migrate
cpuset.memory_pressure
cpuset.mem_pressure_enabled
cpuset.memory_spread_page
cpuset.memory_spread_slab
cpuset.sched_load_balance
cpuset.sched_relax_domain_level

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agocgxset: Add a flag to ignore settings that can't be converted
Tom Hromatka [Mon, 31 Jan 2022 15:21:00 +0000 (08:21 -0700)] 
cgxset: Add a flag to ignore settings that can't be converted

Add a flag, "-i", to cgxset to ignore settings that can't be
converted from cgroup v1 to cgroup v2 or vice versa.

Some cgroup v1 settings, e.g. cpuset.sched_relax_domain_level,
don't have a cgroup v2 equivalent and likely never will.  This
flag allows users to ignore errors from these unconvertable
settings.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agocgxget: Add a flag to ignore settings that can't be converted
Tom Hromatka [Fri, 28 Jan 2022 21:22:53 +0000 (14:22 -0700)] 
cgxget: Add a flag to ignore settings that can't be converted

Add a flag, "-i", to cgxget to ignore settings that can't be
converted from cgroup v1 to cgroup v2 or vice versa.

Some cgroup v1 settings, e.g. cpuset.sched_relax_domain_level,
don't have a cgroup v2 equivalent and likely never will.  This
flag allows users to ignore errors from these unconvertable
settings.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoabstraction-map: Add (currently) unmappable cpu.stat
Tom Hromatka [Mon, 31 Jan 2022 16:30:56 +0000 (09:30 -0700)] 
abstraction-map: Add (currently) unmappable cpu.stat

Add an unmappable mapping for the cpu.stat setting.  While
the filename, cpu.stat, maps perfectly from v1 <-> v2, the
contents do not.  At this time, let's set this as unmappable
and revisit it when we've thought through the best way to
map the contents.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoabstraction: Add support for unmappable settings
Tom Hromatka [Wed, 15 Dec 2021 21:13:29 +0000 (21:13 +0000)] 
abstraction: Add support for unmappable settings

Add a function to explicitly handle settings that cannot
be mapped from v1 to v2 or vice versa.  This function returns
ECGNOVERSIONCONVERT which cgxget, cgxset, etc. can then
monitor and if requested by the user, ignore.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoabstraction-map: Add cpuset.cpu_exclusive <-> cpuset.cpus.partition mapping
Tom Hromatka [Fri, 28 Jan 2022 17:23:55 +0000 (10:23 -0700)] 
abstraction-map: Add cpuset.cpu_exclusive <-> cpuset.cpus.partition mapping

Add custom functions to map cpuset.cpu_exclusive <->
cpuset.cpus.partition.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoabstraction-map: Add cpuset.{cpus,mems} <-> cpuset.{cpus,mems} mapping
Tom Hromatka [Wed, 15 Dec 2021 20:48:56 +0000 (20:48 +0000)] 
abstraction-map: Add cpuset.{cpus,mems} <-> cpuset.{cpus,mems} mapping

Add a passthrough mapping for:
cpuset.cpus <-> cpuset.cpus
cpuset.mems <-> cpuset.mems

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoabstraction-map: Add cpuset.effective_{cpus,mems} <-> cpuset.{cpus,mems}.effective...
Tom Hromatka [Wed, 15 Dec 2021 20:48:31 +0000 (20:48 +0000)] 
abstraction-map: Add cpuset.effective_{cpus,mems} <-> cpuset.{cpus,mems}.effective mapping

Add a name-only mapping to convert:
cpuset.effective_cpus <-> cpuset.cpus.effective
cpuset.effective_mems <-> cpuset.mems.effective

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoabstraction-map: Add cpu.cfs_{quota,period}_us <-> cpu.max mapping
Tom Hromatka [Mon, 31 Jan 2022 16:21:54 +0000 (09:21 -0700)] 
abstraction-map: Add cpu.cfs_{quota,period}_us <-> cpu.max mapping

Add custom functions to map cpu.cfs_quota_us <-> cpu.max and
cpu.cfs_period_us <-> cpu.max.  These mappings can be 1->N or
N->1 and utilize custom values for limits, "-1" in cgroup v1
and "max" in cgroup v2.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agowrapper: Add function to remove name/value pair from a controller
Tom Hromatka [Wed, 15 Dec 2021 20:39:52 +0000 (20:39 +0000)] 
wrapper: Add function to remove name/value pair from a controller

Add a function to remove a name/value settings pair from
a cgroup_controller instance.  As part of this change, I did a small
refactor on cgroup_free_controllers() to make the code more reusable
throughout libcgroup.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoapi.c: Add const qualifier to parameters in cgroup_read_value_begin()
Tom Hromatka [Wed, 15 Dec 2021 20:39:22 +0000 (20:39 +0000)] 
api.c: Add const qualifier to parameters in cgroup_read_value_begin()

Make two string parameters passed into cgroup_read_value_begin()
fully constant, i.e. const char * const.  These parameters,
controller and name, are only used as read-only variables
within cgroup_read_value_begin() and are not intended to be
modified.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoapi.c/wrapper/abstraction: Save previous setting name in control_value
Tom Hromatka [Wed, 15 Dec 2021 20:37:37 +0000 (20:37 +0000)] 
api.c/wrapper/abstraction: Save previous setting name in control_value

When there's an N->1 mapping, the abstraction layer needs
to know which "1" setting to map back to.  Add a field to
struct control_value that saves off the original setting,
so that the abstraction layer can know how to map back from
an N->1 setting.

A good example of this is cpu.max/cpu.cfs_quota_us.  The
abstraction layer will map cpu.cfs_quota_us to cpu.max.
During the return conversion, the abstraction layer needs
to know whether to map cpu.max to cfs_quota_us or
cfs_period_us.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoabstraction: Add passthrough function
Tom Hromatka [Wed, 15 Dec 2021 21:12:09 +0000 (21:12 +0000)] 
abstraction: Add passthrough function

Add a passthrough function for settings/values that require
no conversion.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoabstraction: Add name conversion function
Tom Hromatka [Wed, 15 Dec 2021 21:11:28 +0000 (21:11 +0000)] 
abstraction: Add name conversion function

Add a function to the abstraction layer that can convert from
one cgroup setting name to another setting name.  The values are
not adjusted by this function.  For example, this can be used for
conversions like cpuset.effective_cpus to cpuset.cpus.effective.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agocgxset: Introduce cgxset
Tom Hromatka [Fri, 28 Jan 2022 17:22:49 +0000 (10:22 -0700)] 
cgxset: Introduce cgxset

Add a new libcgroup tool - cgxset.  cgxset is based upon cgset,
but it supports converting from cgroup version to another.

For example, a request like the following will work on a system
running the cgroup v1 cpu controller or the cgroup v2 cpu
controller.
            $ cgxset -2 -r cpu.weight=42 MyCgroup

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agocgxget: Introduce cgxget
Tom Hromatka [Fri, 28 Jan 2022 17:22:11 +0000 (10:22 -0700)] 
cgxget: Introduce cgxget

Add a new libcgroup tool - cgxget.  cgxget is based upon cgget,
but it supports converting from cgroup version to another.

For example, a request like the following will work on a system
running the cgroup v1 cpu controller or the cgroup v2 cpu controller.
$ cgxget -2 -r cpu.weight MyCgroup

The return value to the user will match the cgroup version requested.
If the user requests a v1 setting, the return value will be a cgroup
v1 setting.  If the user requests a v2 setting, the return value will
be a cgroup v2 setting.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoabstraction-map: Add cpu.shares <-> cpu.weight mapping
Tom Hromatka [Wed, 15 Dec 2021 20:19:23 +0000 (20:19 +0000)] 
abstraction-map: Add cpu.shares <-> cpu.weight mapping

Add a mapping from cpu.shares <-> cpu.weight.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoabstraction: Add function to convert from one cgroup version to another
Tom Hromatka [Wed, 15 Dec 2021 20:18:54 +0000 (20:18 +0000)] 
abstraction: Add function to convert from one cgroup version to another

Add a function - cgroup_convert_cgroup() - that can convert from
one cgroup version to another.  This function will be the building
block for the libcgroup abstraction layer.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoabstraction: Add integer conversion function
Tom Hromatka [Wed, 15 Dec 2021 20:14:11 +0000 (20:14 +0000)] 
abstraction: Add integer conversion function

Add a function to the abstraction layer that can convert from
one integer setting to another.  For example, this can be used
for simple conversions like cpu.shares to cpu.weight and vice
versa.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoabstraction: Add mapping tables
Tom Hromatka [Fri, 28 Jan 2022 17:21:10 +0000 (10:21 -0700)] 
abstraction: Add mapping tables

Add a table for cgroup v1 to v2 conversions -
cgroup_v1_to_v2_map[]

Add a table for cgroup v2 to v1 conversions -
cgroup_v2_to_v1_map[]

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoabstraction: Add cgroup_strtol()
Tom Hromatka [Fri, 28 Jan 2022 17:20:38 +0000 (10:20 -0700)] 
abstraction: Add cgroup_strtol()

Add two new files, abstraction-common.[ch], and within them add
a function, cgroup_strtol(), that can convert a string to a long.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoapi.c: Remove static from cgroup_copy_controller_values()
Tom Hromatka [Wed, 15 Dec 2021 19:37:36 +0000 (19:37 +0000)] 
api.c: Remove static from cgroup_copy_controller_values()

Remove static from cgroup_copy_controller_values() in api.c
so that other files within libcgroup can invoke it.  It will
be used by the abstraction layer code in a subsequent commit.

Also, declare *dst as a const pointer and *src as a const *
const pointer.  Subsequent abstraction layer checkins make
heavy use of const and without these changes, warnings (which
continuous integration converts to errors) are thrown.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agowrapper.c: Store the version in struct cgroup_controller
Tom Hromatka [Wed, 15 Dec 2021 19:30:30 +0000 (19:30 +0000)] 
wrapper.c: Store the version in struct cgroup_controller

Store the cgroup version in struct cgroup_controller.  Each
controller can be mounted separately, and thus the cgroup
version is applicable at the controller level.

Note that this commit requires cgroup_init() to be called by
cgconfigparser.  Storing the version in the cgroup_controller
struct requires the cg_mount_table[] to be populated.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agogroups.h: Move cg_version_t to groups.h
Tom Hromatka [Wed, 15 Dec 2021 19:27:19 +0000 (19:27 +0000)] 
groups.h: Move cg_version_t to groups.h

Move cg_version_t to libcgroup/groups.h from libcgroup-internal.h.
Introduce CGROUP_DISK version to indicate the cgroup version in
sysfs.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoautomake: Don't go over 80-character lines
Tom Hromatka [Fri, 28 Jan 2022 17:17:34 +0000 (10:17 -0700)] 
automake: Don't go over 80-character lines

Nonfunctional change to line wrap lines that were 80+
characters long.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoconfigure: set version numbers for releases only
Kamalesh Babulal [Thu, 3 Feb 2022 14:59:20 +0000 (07:59 -0700)] 
configure: set version numbers for releases only

Let's set the version for releases only and set the development/main
branch version to 0.0.0, that differentiate between development and
releases.

Suggested-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoMerge pull request #92 from drakenclimber/issues/finalize
Tom Hromatka [Wed, 2 Feb 2022 23:20:34 +0000 (16:20 -0700)] 
Merge pull request #92 from drakenclimber/issues/finalize

On some pull requests, I have observed that the coveralls summary sometimes runs before all the jobs have completed.  Let's see if this fixes it.

3 years agogithub: Always run the finalize job 92/head
Tom Hromatka [Wed, 2 Feb 2022 22:44:11 +0000 (15:44 -0700)] 
github: Always run the finalize job

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoftests-nocontainer: remove the skip argument
Kamalesh Babulal [Wed, 2 Feb 2022 22:13:42 +0000 (15:13 -0700)] 
ftests-nocontainer: remove the skip argument

Commit f852cad3fd64 ("ftests: Delete the cgclear functional test"),
removed the testcase 028-cgclear-basic_cgclear.py. Drop the skip
argument from the ftests-nocontainer.sh to skip the non-existing
testcase.

Suggested-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoftests: Add a test for unmappable settings
Tom Hromatka [Wed, 2 Feb 2022 17:48:10 +0000 (17:48 +0000)] 
ftests: Add a test for unmappable settings

-----------------------------------------------------------------
Test Results:
        Run Date:                          Feb 02 17:47:50
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                         Time (sec)
        ---------------------------------------
        setup                              0.00
        042-cgxget-unmappable.py           0.19
        teardown                           0.00
        ---------------------------------------
        Total Run Time                     0.19

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoftests: Add a test for the python bindings to library_version()
Tom Hromatka [Thu, 16 Dec 2021 15:06:10 +0000 (08:06 -0700)] 
ftests: Add a test for the python bindings to library_version()

Add a functional test that exercises the library_version() python
bindings.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Oct 27 15:53:49
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        ---------------------------------------------------------
        setup                                         0.00
        040-pybindings-library_version.py             0.00
        teardown                                      0.00
        ---------------------------------------------------------
        Total Run Time                                0.00

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoftests: Add a test for the python bindings to cgroup_cgxset()
Tom Hromatka [Thu, 16 Dec 2021 15:05:42 +0000 (08:05 -0700)] 
ftests: Add a test for the python bindings to cgroup_cgxset()

Add a test for the python bindings to cgroup_cgxset()

-----------------------------------------------------------------
Test Results:
        Run Date:                          Oct 13 15:34:29
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        ---------------------------------------------------------
        setup                                         0.00
        039-pybindings-cgxset.py                      0.06
        teardown                                      0.00
        ---------------------------------------------------------
        Total Run Time                                0.06

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agocgroup.py: Add support for cgcreate flags
Tom Hromatka [Thu, 16 Dec 2021 15:05:15 +0000 (08:05 -0700)] 
cgroup.py: Add support for cgcreate flags

Add support for all of the cgcreate flags.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoftests: Add a test for the python bindings to cgroup_cgxget()
Tom Hromatka [Thu, 16 Dec 2021 15:04:35 +0000 (08:04 -0700)] 
ftests: Add a test for the python bindings to cgroup_cgxget()

Add a functional test that exercises the cgroup_cgxget() python
bindings.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Oct 11 22:11:48
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        ---------------------------------------------------------
        setup                                         0.00
        038-pybindings-cgxget.py                      0.04
        teardown                                      0.00
        ---------------------------------------------------------
        Total Run Time                                0.04

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoftests: Add a cgxget/cgxset test for the cpuset controller
Tom Hromatka [Thu, 16 Dec 2021 15:04:17 +0000 (08:04 -0700)] 
ftests: Add a cgxget/cgxset test for the cpuset controller

Add a functional test that exercises the cpuset v1/v2 mappings.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Sep 08 11:17:19
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        ---------------------------------------------------------
        setup                                         0.00
        038-cgxget-cpuset_settings.py                 1.34
        teardown                                      0.00
        ---------------------------------------------------------
        Total Run Time                                1.34

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoftests: Add more cpu abstraction tests
Tom Hromatka [Thu, 16 Dec 2021 15:03:32 +0000 (08:03 -0700)] 
ftests: Add more cpu abstraction tests

Add tests for cpu.cfs_quota_us, cpu.cfs_period_us, cpu.max, and
cpu.stat to test 036-cgxget-cpu_settings.py

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoftests: Add a cgxget/cgxset test for the cpu controller
Tom Hromatka [Thu, 16 Dec 2021 14:59:44 +0000 (07:59 -0700)] 
ftests: Add a cgxget/cgxset test for the cpu controller

Add a functional test that exercises the cpu v1/v2 mappings.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Apr 19 18:39:16
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        ---------------------------------------------------------
        setup                                         0.00
        037-cgxget-cpu_settings.py                    0.50
        teardown                                      0.00
        ---------------------------------------------------------
        Total Run Time                                0.50

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoftests: Add support for cgxset to the Cgroup class
Tom Hromatka [Thu, 16 Dec 2021 14:59:11 +0000 (07:59 -0700)] 
ftests: Add support for cgxset to the Cgroup class

Add support for cgxset to the Cgroup class

The pydoc for Cgroup.xset() is available by running:
$ python -c "from cgroup import Cgroup;help(Cgroup.xset)"

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoftests: Add support for cgxget to the Cgroup class
Tom Hromatka [Thu, 16 Dec 2021 14:58:56 +0000 (07:58 -0700)] 
ftests: Add support for cgxget to the Cgroup class

Add support for cgxget to the Cgroup class

The pydoc for Cgroup.xget() is available by running:
$ python -c "from cgroup import Cgroup;help(Cgroup.xget)"

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoapi.c: add support for cgroup.threads
Kamalesh Babulal [Thu, 27 Jan 2022 19:33:52 +0000 (12:33 -0700)] 
api.c: add support for cgroup.threads

cgroup_build_tasks_procs_path(), that builds the proc path for moving
the tid, doesn't check for the cgroup type and appends cgroup.procs for
both cgroup v1/v2.  With cgroup v2, this results in building a wrong
proc path if the cgroup type is threaded. This patch adds support to
check for the cgroup v2 type and build the proc path according to the
below table:

cgroup.type     | proc file      | Description                        |
----------------+----------------+------------------------------------+
domain          | cgroup.procs   | regular cgroup, all threads gets   |
                |                | moved to the cgroup.               |
domain threaded | cgroup.procs   | root of threaded subtree, all      |
                |                | threads gets moved to the cgroup.  |
threaded        | cgroup.threads | cgroup under threaded subtree,     |
|  | single threads with matching tid,  |
|  | gets moved to the cgroup.          |
domain invalid  | N/A            | invalid state of a cgroup under the|
                |                | threaded subtree.                  |

Closes: https://github.com/libcgroup/libcgroup/issues/64
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoftests: add a test for cgroup v2 threaded support
Kamalesh Babulal [Tue, 25 Jan 2022 15:57:03 +0000 (15:57 +0000)] 
ftests: add a test for cgroup v2 threaded support

Add a functional test to verify threaded cgroup support on a
cgroup v2 filesystem.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Jan 25 10:41:34
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                          Time (sec)
        ----------------------------------------
        setup                               0.00
        036-cgset-multi_thread.py           0.10
        teardown                            0.00
        ----------------------------------------
        Total Run Time                      0.10

Suggested-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Minor cleanups to utilize the new set_and_validate() method

3 years agoprocess.py: add support to spawn a multithreaded process
Kamalesh Babulal [Tue, 25 Jan 2022 15:47:27 +0000 (15:47 +0000)] 
process.py: add support to spawn a multithreaded process

Add support for creating a multithreaded process. The multithreaded
process gets created by spawning a new process, that in turn creates
N threads. The thread function is a while loop, that sleeps for N
seconds. Currently, there is no support for waiting for the threads
to join, and to stop the threads, the spawned process needs to be
terminated/killed.

Suggested-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoMerge pull request #32 from drakenclimber/issues/validate
Tom Hromatka [Tue, 25 Jan 2022 15:09:18 +0000 (08:09 -0700)] 
Merge pull request #32 from drakenclimber/issues/validate

ENH: Refactor get/compare/fail logic

3 years agoftests: Utilize the new Cgroup validate functions
Tom Hromatka [Fri, 21 Jan 2022 22:19:30 +0000 (22:19 +0000)] 
ftests: Utilize the new Cgroup validate functions

Replace the boilerplate copy/paste code of get, compare,
and fail-on-error with calls to Cgroup.get_and_validate()
and Cgroup.set_and_validate().  This is purely a cleanup
commit and is nonfunctional.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agocgroup: Add helper methods to validate get/set
Tom Hromatka [Fri, 21 Jan 2022 22:15:35 +0000 (22:15 +0000)] 
cgroup: Add helper methods to validate get/set

Add helper methods, get_and_validate() and set_and_validate().
These methods do not map directly to any libcgroup command
line interfaces, but should be useful in reducing copy/paste
boilerplate code.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoMerge pull request #86 from drakenclimber/issues/lgtm
Tom Hromatka [Thu, 20 Jan 2022 22:26:10 +0000 (15:26 -0700)] 
Merge pull request #86 from drakenclimber/issues/lgtm

ENH: Add LGTM badge to README.md

3 years agoREADME.md: Add LGTM badge 86/head
Tom Hromatka [Wed, 12 Jan 2022 21:32:25 +0000 (14:32 -0700)] 
README.md: Add LGTM badge

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoMerge pull request #85 from drakenclimber/issues/codeql
Tom Hromatka [Wed, 19 Jan 2022 17:42:49 +0000 (10:42 -0700)] 
Merge pull request #85 from drakenclimber/issues/codeql

ENH: Add Security Features

3 years agoapi.c: Fix TOCTOU race in cgroup_get_procs() 85/head
Tom Hromatka [Wed, 19 Jan 2022 17:03:28 +0000 (10:03 -0700)] 
api.c: Fix TOCTOU race in cgroup_get_procs()

codeql flagged a potential race between the time-of-check
and time-of-use (CWE-367) of the cgroup.procs file in
cgroup_get_procs().

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agogithub: Add a code security scan
Tom Hromatka [Wed, 12 Jan 2022 19:32:22 +0000 (12:32 -0700)] 
github: Add a code security scan

Add a code security scan, CodeQL to the Github Actions
continuous integration.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoSECURITY.md: Add security file
Tom Hromatka [Wed, 12 Jan 2022 19:30:44 +0000 (12:30 -0700)] 
SECURITY.md: Add security file

Add a SECURITY.md file that outlines the process for handling
security-related vulnerabilities.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
3 years agoapi.c: cache cgrules with CGFLAG_USECACHE flag
Kamalesh Babulal [Tue, 18 Jan 2022 15:22:13 +0000 (08:22 -0700)] 
api.c: cache cgrules with CGFLAG_USECACHE flag

pam_cgroup.so plugin uses /etc/cgrules.conf to assign processes
to the requested cgroup.  This works well with active
cgrulesengd but in the instances where cgrulesengd is disabled,
the rules are not read and cached by default. Fix this is by
reloading and caching the rules when called with CGFLAG_USECACHE
flag.

Fixes: https://github.com/libcgroup/libcgroup/issues/84
Reported-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Minor commit comment changes

3 years agoMerge pull request #29 from drakenclimber/issues/ci
Tom Hromatka [Tue, 11 Jan 2022 22:17:34 +0000 (15:17 -0700)] 
Merge pull request #29 from drakenclimber/issues/ci

ENH: Add a Github Actions continuous integration workflow

3 years agoftests: Fix syntax error in container.py
Tom Hromatka [Wed, 5 Jan 2022 20:22:47 +0000 (13:22 -0700)] 
ftests: Fix syntax error in container.py

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoftests: Fix syntax errors in test 025
Tom Hromatka [Wed, 5 Jan 2022 20:22:28 +0000 (13:22 -0700)] 
ftests: Fix syntax errors in test 025

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agogithub: Add continuous integration workflow
Tom Hromatka [Wed, 5 Jan 2022 20:18:29 +0000 (13:18 -0700)] 
github: Add continuous integration workflow

Add a continuous integration workflow that runs on Github
Actions.  Enable the python syntax errors action.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
3 years agoMerge pull request #83 from drakenclimber/issues/doxygen_badge
Tom Hromatka [Mon, 3 Jan 2022 15:08:50 +0000 (08:08 -0700)] 
Merge pull request #83 from drakenclimber/issues/doxygen_badge

README.md: Add Doxygen badge

3 years agoREADME.md: Add Doxygen badge 83/head
Tom Hromatka [Mon, 20 Dec 2021 15:18:35 +0000 (08:18 -0700)] 
README.md: Add Doxygen badge

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal kamalesh.babulal@oracle.com