]> git.ipfire.org Git - thirdparty/libcgroup.git/log
thirdparty/libcgroup.git
2 years agowrapper: cgroup_add_all_controllers(): fix variable typo release-3.0
Kamalesh Babulal [Sun, 23 Apr 2023 11:35:05 +0000 (17:05 +0530)] 
wrapper: cgroup_add_all_controllers(): fix variable typo

Coverity reported uninitialized value:

CID 313909 (#1 of 1): Uninitialized scalar variable (UNINIT)8.
uninit_use_in_call: Using uninitialized value *info.name as argument to
%s when calling fprintf.

In cgroup_add_all_controllers(), fix the wrong variable name in the
error message, while parsing the controller name.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit c0a166f6a217e7cd82aad125e41b352ed6b2fa47)

2 years agoftests: Add a domain invalid test
Tom Hromatka [Mon, 17 Apr 2023 14:58:15 +0000 (14:58 +0000)] 
ftests: Add a domain invalid test

-----------------------------------------------------------------
Test Results:
Run Date:                          Apr 13 19:23:11
Passed:                                  1 test(s)
Skipped:                                 0 test(s)
Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
Test                             Time (sec)
-------------------------------------------
setup                                  0.00
080-kernel-domain_invalid.py           4.22
teardown                               0.00
-------------------------------------------
Total Run Time                         4.22

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit bca30abc50391b674a7caf779c3cd374c8f5a2b5)

2 years agoftests: Add a test to create a default systemd scope via cgcreate
Tom Hromatka [Mon, 17 Apr 2023 14:57:15 +0000 (14:57 +0000)] 
ftests: Add a test to create a default systemd scope via cgcreate

Add a test to create a systemd scope via the cgcreate command
line tool.  The scope is set as the default and used to create
a child cgroup.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Apr 10 21:39:10
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
        Test                                          Time (sec)
        --------------------------------------------------------
        setup                                               0.00
        079-sudo-cgcreate_default_systemd_scope.py          5.06
        teardown                                            0.00
        --------------------------------------------------------
        Total Run Time                                      5.06

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit 8e29c7282c956bfb75847f6d46f55668be786817)

2 years agoftests: Add a test to create a systemd scope via cgcreate
Tom Hromatka [Tue, 4 Apr 2023 22:32:12 +0000 (22:32 +0000)] 
ftests: Add a test to create a systemd scope via cgcreate

Add a test to create a systemd scope via the cgcreate command
line tool.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Apr 05 01:35:43
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                  Time (sec)
        ------------------------------------------------
        setup                                       0.00
        078-sudo-cgcreate_systemd_scope.py          5.03
        teardown                                    0.00
        ------------------------------------------------
        Total Run Time                              5.03

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit ebeaf858d791fab3f64352ad462cc7ed4b603dcd)

2 years agoman: document cgcreate's -c and -S options
Tom Hromatka [Thu, 6 Apr 2023 19:36:57 +0000 (13:36 -0600)] 
man: document cgcreate's -c and -S options

Add documentation about the -c (create scope) option and the -S
(set as default) option in the cgcreate man page. -c instructs
cgcreate to invoke cgroup_create_scope2() and create a systemd
scope.  -S (used in conjunction with -c) will set the provided
scope as the default for subsequent libcgroup operations.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit 962d5e5ddc9ac735a62a557d58b3f50dcd400477)

2 years agoapi: Add support for domain invalid cgroups
Tom Hromatka [Mon, 10 Apr 2023 22:01:23 +0000 (22:01 +0000)] 
api: Add support for domain invalid cgroups

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit 0c84f23e9d831d8ca4a15a395c17989f599b4861)

2 years agosrc: ftests: Better management of libcgroup idle thread
Tom Hromatka [Wed, 5 Apr 2023 15:38:55 +0000 (15:38 +0000)] 
src: ftests: Better management of libcgroup idle thread

Add the libcgroup_systemd_idle_thread to the EXTRA_DIST list. This
makes it available during `make distcheck`.

Modifying the PATH environment variable when running sudo is not
allowed on some systems.  Copy the libcgroup_systemd_idle_thread
to /bin to overcome this.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit 3f3e0dc1fdadfd9cd0de227c568fb90eea63d9a0)

2 years agoftests: Add support for lists in Cgroup.exists()
Tom Hromatka [Fri, 7 Apr 2023 22:18:30 +0000 (16:18 -0600)] 
ftests: Add support for lists in Cgroup.exists()

Add support for checking if a cgroup exists when a list of
controllers is provided.  For example, given:

controllers = ['cpu', 'pids']
cgroup_name = 'test_cgroup'

Cgroup.exists(config, controllers, cgroup_name)

will now work.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit 1e721f1fbe095933b2087ed362ff1e6d1099dcfe)

2 years agoftests: Add cgcreate systemd scope support
Tom Hromatka [Tue, 4 Apr 2023 22:31:51 +0000 (22:31 +0000)] 
ftests: Add cgcreate systemd scope support

Add support for creating systemd scopes via the cgcreate command
line tool.

Python's subprocess.Popen.communicate() will not return until the
spawned process and all of its children finish running.  This will
cause a cgcreate of a scope to hang because libcgroup creates an
idle process in the newly-created scope.  Add a timeout to the run()
method so that it can complete even when a child process remains.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit 5fc8e77fc70667a02af20ad62876f715d96c6241)

2 years agocgcreate: Add support to create a systemd scope
Tom Hromatka [Mon, 3 Apr 2023 15:39:31 +0000 (09:39 -0600)] 
cgcreate: Add support to create a systemd scope

Add support to create a systemd scope.  A user can create a delegated
systemd scope using the following format:
$ cgcreate -c -g <controllers>:<slicename>/<scopename>

e.g.
$ cgcreate -c -g cpu,memory:libcgroup.slice/database.scope

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit d789745d786ac30ec3fdba0525da003abcef120f)

2 years agosystemd: Cleanup return codes in cgroup_create_scope()
Tom Hromatka [Tue, 4 Apr 2023 21:31:12 +0000 (21:31 +0000)] 
systemd: Cleanup return codes in cgroup_create_scope()

cgroup_create_scope() used a single variable, ret, to handle return
codes from systemd/dbus, system calls, and internal libcgroup functions.
Use a separate return variable for each of these three cases to clearly
delineate errors.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit 41a2451f4e360de90c5d00c32464da73c016f016)

2 years agoman/cgget: add '-c' option description
Kamalesh Babulal [Tue, 18 Apr 2023 08:20:54 +0000 (13:50 +0530)] 
man/cgget: add '-c' option description

Add a brief explanation about '-c' option. It displays the controllers
and their versions.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 3371bbb2b388dfa34f948fd8c17261bd31c8c022)

2 years agotools/cgget: add '-c' option
Kamalesh Babulal [Tue, 18 Apr 2023 08:20:48 +0000 (13:50 +0530)] 
tools/cgget: add '-c' option

Add '-c' option to cgget, that prints the controllers and their
versions,
this is useful for the user, who wants to list the available controllers
and/or their version too.

 $ cgget -c
 #Controller     Version
 cpu             2
 memory          2
 cpuset          1
 misc            1
 hugetlb         1
 blkio           1
 net_cls         1
 net_prio        1
 freezer         1
 devices         1
 pids            1
 perf_event      1
 rdma            1

this option works with legacy, unified, and hybrid cgroup setup modes.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Changed comment formatting
(cherry picked from commit fd173c8201a11a77103f166b61f1bf33187195d0)

2 years agotools/cgxget: fix segfault in free path
Kamalesh Babulal [Fri, 14 Apr 2023 15:30:01 +0000 (15:30 +0000)] 
tools/cgxget: fix segfault in free path

cgxget tool crashes, when passing basic operations such as multiple
cgroups as arguments or invalid parameters, it turns out the address of
struct cgroup passed for cgroup_free() has been invalid.

$ sudo ./src/tools/cgxget -1 -r cpu.shares a b
Segmentation fault (core dumped)

$ sudo ./src/tools/cgxget -1 cpu.shares a b
Segmentation fault (core dumped)

this patch fixes it by passing the right address of the struct cgroup[]
to cgroup_free().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit a1299d6cd01fbff653a3fe919a67ea86483a054e)

2 years agotools/cgget: fix '-m' option usage
Kamalesh Babulal [Sun, 16 Apr 2023 04:40:13 +0000 (10:10 +0530)] 
tools/cgget: fix '-m' option usage

'-m' is logically an independent option and should not be mixed and
matched with other options and also when used with '-h', help always
takes precedence over other options. Fix both cases of usage with
a bool flag, that gets set when parsing the command line option but
executes only it meets the rules of not mixing with other options.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit ce809ea7519b2741edbb823618fdf6796de1f4d0)

2 years agoftests: Add test for cgroup_get_procs()
Tom Hromatka [Fri, 17 Mar 2023 15:25:49 +0000 (09:25 -0600)] 
ftests: Add test for cgroup_get_procs()

Add a functional test for cgroup_get_procs()

-----------------------------------------------------------------
Test Results:
Run Date:                          Mar 17 16:11:34
Passed:                                  1 test(s)
Skipped:                                 0 test(s)
Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
Test                                   Time (sec)
-------------------------------------------------
setup                                        0.00
077-pybindings-cgroup_get_procs.py          40.31
teardown                                     0.00
-------------------------------------------------
Total Run Time                              40.31

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit e7efc43140e5be079619a06efb50d859f5027b16)

2 years agoftests: Add controller list() support to Cgroup.classify()
Tom Hromatka [Fri, 17 Mar 2023 15:24:32 +0000 (09:24 -0600)] 
ftests: Add controller list() support to Cgroup.classify()

Add support for passing in a list of controllers to Cgroup.classify().

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit 82183a3612b7547cab47b38cd27096dbfb8456bb)

2 years agopython: Add python bindings for cgroup_get_procs()
Tom Hromatka [Fri, 17 Mar 2023 15:23:59 +0000 (09:23 -0600)] 
python: Add python bindings for cgroup_get_procs()

Add python bindings for cgroup_get_procs().

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit 65f3fce51873b54c6c75b392facedd3a9e8ea14f)

2 years agoftests-070: avoid enabling controller on leaf cgroup node
Kamalesh Babulal [Wed, 12 Apr 2023 14:31:01 +0000 (14:31 +0000)] 
ftests-070: avoid enabling controller on leaf cgroup node

cgroup v2, has no internal process constraint, where the process runs
only on the leaf node of the cgroup hierarchy and no controllers should
be enabled on the leaf cgroup node too. Let's not enable cpu controller
on the leaf cgroup node.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 65c0b7025758d0802b81c0b42c194758316a2b18)

2 years agoftests-068: avoid enabling controller on leaf cgroup node
Kamalesh Babulal [Wed, 12 Apr 2023 14:30:34 +0000 (14:30 +0000)] 
ftests-068: avoid enabling controller on leaf cgroup node

cgroup v2, has no internal process constraint, where the process runs
only on the leaf node of the cgroup hierarchy and no controllers should
be enabled on the leaf cgroup node too. Let's not enable cpu controller
on the leaf cgroup node.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit ca8232385395e662281d948f80c89d701b7e875d)

2 years agoftests-066: avoid enabling controller on leaf cgroup node
Kamalesh Babulal [Wed, 12 Apr 2023 14:28:37 +0000 (14:28 +0000)] 
ftests-066: avoid enabling controller on leaf cgroup node

cgroup v2, has no internal process constraint, where the process runs
only on the leaf node of the cgroup hierarchy and no controllers should
be enabled on the leaf cgroup node too. Let's not enable cpu controller
on the leaf cgroup node. Also, fix the expected stderr, accordingly
while migrating the tasks using cgclassify.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 3ef8bf2a047e05a881a2cef6d38fbed3ea6502f2)

2 years agoftests-064: avoid enabling controller on leaf cgroup node
Kamalesh Babulal [Wed, 12 Apr 2023 14:27:58 +0000 (14:27 +0000)] 
ftests-064: avoid enabling controller on leaf cgroup node

cgroup v2, has no internal process constraint, where the process runs
only on the leaf node of the cgroup hierarchy and no controllers should
be enabled on the leaf cgroup node too. Let's not enable cpu controller
on the leaf cgroup node.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit ddadfd67a161da5052e6e2eba97d3052fd976cca)

2 years agoftests-062: avoid enabling controller on leaf cgroup node
Kamalesh Babulal [Wed, 12 Apr 2023 14:27:06 +0000 (14:27 +0000)] 
ftests-062: avoid enabling controller on leaf cgroup node

cgroup v2, has no internal process constraint, where the process runs
only on the leaf node of the cgroup hierarchy and no controllers should
be enabled on the leaf cgroup node too. Let's not enable cpu controller
on the leaf cgroup node.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 9cf49e499ebfb5b128e3e34d7db69af99ff40b3e)

2 years agoRevert "gunit/test-015: Populate subtree_control for leaf cgroup"
Kamalesh Babulal [Wed, 12 Apr 2023 09:34:19 +0000 (09:34 +0000)] 
Revert "gunit/test-015: Populate subtree_control for leaf cgroup"

This reverts commit 328ec5e8e4f00790cb91f81ff53f2cdd42d0106f.

Revert the logic to rely on the leaf cgroup node's subtree_control file
to examine the enabled controllers, this breaks the cgroup v2's no
internal process constraint and fallback to the original idea of relying
upon on leaf cgroup nodes, parent subtree_control to examine the enabled
controllers.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit f15c995d56be0c13b03ea9ca43919cca261be9b6)

2 years agoRevert "gunit/test-012: Create subtree_control for leaf cgroup"
Kamalesh Babulal [Wed, 12 Apr 2023 09:34:30 +0000 (09:34 +0000)] 
Revert "gunit/test-012: Create subtree_control for leaf cgroup"

This reverts commit c567528cdb9c8394c9c61c906e68daa0d91a80d8.

Fallback to the original approach of no internal process constraint,
revert the logic to enable the controller on the cgroup leaf node.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit c25424bdaa1c5227c640321cf308a094c913e6a9)

2 years agoRevert "api: cgroup v2 – read subtree_control of the leaf node"
Kamalesh Babulal [Wed, 12 Apr 2023 14:51:17 +0000 (20:21 +0530)] 
Revert "api: cgroup v2 â€“ read subtree_control of the leaf node"

This reverts commit 39012eeefa454e09fc4192cacddb508ee00abee6.

As per the no internal process constraint, of cgroup v2 no controller
should be enabled in the leaf cgroup node. This patch breaks this
constraint by assuming the controllers are enabled until the leaf node
of the hierarchy. Let's revert to the original approach of reading
until the parent of the leaf cgroup node.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 59dff6c981b79ab5e92179e187fc065c53aef54f)

2 years agoRevert "api: cgroup v2 – enable controller at the leaf node"
Kamalesh Babulal [Wed, 12 Apr 2023 14:49:45 +0000 (20:19 +0530)] 
Revert "api: cgroup v2 â€“ enable controller at the leaf node"

This reverts commit bb291add5db87fe36a82a18c6eb6aaf64dc07694.

cgroup v2, has no internal process constraint, where the process runs
only on the leaf node of the cgroup hierarchy and no controllers should
be enabled on the leaf cgroup node too, so that they don't compete with
the parent's internal process. This patch broke this rule by enabling
the controller on the leaf node by default. Let's revert to the original
approach of not enabling the controller on the leaf cgroup node.

Signed-by-off: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 9479fedff122ea44c887efafde2aaa3a51f0c623)

2 years agoftests: Add cgconfigparser auto convert test
Kamalesh Babulal [Fri, 7 Apr 2023 14:15:19 +0000 (19:45 +0530)] 
ftests: Add cgconfigparser auto convert test

Add a test to exercise cgconfigparser auto convert functionality.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Apr 07 14:14:57
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                             Time (sec)
        -------------------------------------------
        setup                                  0.00
        076-cgconfig-auto_convert.py           0.11
        teardown                               0.00
        -------------------------------------------
        Total Run Time                         0.11

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Changed test number to 76 and added it to Makefile.am
(cherry picked from commit ed568ec5ac793ac1808e73af1a76a1adcc083fc5)

2 years agocgconfig: auto convert cgroup controller versions
Kamalesh Babulal [Wed, 12 Apr 2023 09:15:01 +0000 (14:45 +0530)] 
cgconfig: auto convert cgroup controller versions

The user might be using cgroup v1 controller settings in the
cgconfig.conf and when migrating to the cgroup v2 setup, they are
required to manually edit the cgconfig.conf file to map v1 controllers
settings to that of v2 settings, this might be cumbersome activity.
This patch tries to address the mapping issue, by silently mapping
the possible controller settings to the current cgroup setup.

Consider the scenario:
$ cgget -m
Unified Mode (Cgroup v2 only).

$ cat cgconfig.conf
group foo {
        cpu {
                cpu.shares = 512;
                cpu.cfs_quota_us = 5000;
        }
        cpuset {
                cpuset.cpus = 0-1;
        }
}

the cpu controller settings are of cgroup v1 but the system is booted
into cgroup v2 setup. Running cgconfigparser without the patch, the user
will be warned about invalid settings and the parser will exit.

$ sudo cgconfigparser -l ./cgconfig.conf
cgconfigparser; error loading cgconfig.conf: Cgroup, requested group parameter does not exist

with this patch, cgconfigparser will attempt to convert the settings.
$ sudo cgconfigparser -l ./cgconfig.conf
$ cat /sys/fs/cgroup/foo/cpu.weight
50
$ cat /sys/fs/cgroup/foo/cpu.max
5000 100000

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 0c421124756a80617612ea1daf55a3c8b16e6b41)

2 years agoftests: cleanup return statements
Kamalesh Babulal [Mon, 10 Apr 2023 12:40:02 +0000 (18:10 +0530)] 
ftests: cleanup return statements

This patch cleans up a few oddities around return statements:
1. Removes redundant return statements across the ftests/*, mostly in
   the function prereqs and a few other places too.
2. Follows the same function template for prereqs, across the ftests/*.,
   and removes the checks for success on return from prereqs function,
   those will be true always.
3. Also, replace consts.TEST_PASSED, None with pass for functions, that
   serves as stub and remove the return value checks for stubs.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 0c65a402990d8657637b10bb4ae02f99ae575082)

2 years agoftests-072: fix flake8 warning
Kamalesh Babulal [Mon, 3 Apr 2023 10:05:08 +0000 (15:35 +0530)] 
ftests-072: fix flake8 warning

Fix "E302 expected 2 blank lines, found 1" flake warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit f6bf9fea34f3551aeb05900773c9022bf37b66d5)

2 years agotests-059: fix flake8 warnings
Kamalesh Babulal [Mon, 3 Apr 2023 10:05:04 +0000 (15:35 +0530)] 
tests-059: fix flake8 warnings

Fix "F401 'utils' imported but unused" and
"E303 too many blank lines (2)" warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit fc3e59ba70fab31955b58ee3271b1d0ba45a5af9)

2 years agoftests-050: fix flake8 unused import warning
Kamalesh Babulal [Mon, 3 Apr 2023 10:05:00 +0000 (15:35 +0530)] 
ftests-050: fix flake8 unused import warning

Fix "F401 'run.Run' imported but unused" flake8 warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit ee448a114de9382bc4cef1cd2c041f00a4009178)

2 years agoftests: Add cgroup_compare_cgroup() test
Tom Hromatka [Tue, 7 Mar 2023 19:49:23 +0000 (12:49 -0700)] 
ftests: Add cgroup_compare_cgroup() test

Add a test for the cgroup_compare_cgroup() python bindings

-----------------------------------------------------------------
Test Results:
Run Date:                          Mar 07 12:49:07
Passed:                                  1 test(s)
Skipped:                                 0 test(s)
Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
Test                                        Time (sec)
------------------------------------------------------
setup                                             0.00
075-pybindings-cgroup_compare_cgroup.py           0.09
teardown                                          0.00
------------------------------------------------------
Total Run Time                                    0.09

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit c9ff26e405141743eec2d271b9c1070a4ef9bb9a)

2 years agopython: Add python bindings for cgroup_compare_cgroup()
Tom Hromatka [Tue, 7 Mar 2023 19:45:35 +0000 (12:45 -0700)] 
python: Add python bindings for cgroup_compare_cgroup()

Add python bindings for comparing two Cgroup instances.  Perform
the usual python comparisons and also invoke cgroup_compare_cgroup()
to ensure the cgroups completely match.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 40b90e7b6ae3f9493db4f44e427349e3e53c05e5)

2 years agowrapper: Make cgroup_compare_cgroup() order agnostic
Tom Hromatka [Tue, 7 Mar 2023 22:34:34 +0000 (15:34 -0700)] 
wrapper: Make cgroup_compare_cgroup() order agnostic

cgroup_compare_cgroup() can be used to compare two struct cgroup
instances.  Improve its comparison algorithm so that it can successfully
identify cgroups as the same if the only difference is the order of the
controllers stored within them.

With this change, the following two cgroups would be identified as
equal.

cgroup_a
name = foo
controller[0] = memory
controller[1] = cpu

cgroup_b
name = foo
controller[0] = cpu
controller[1] = memory

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 50222392d930e7be15231d0cfde9072eea172242)

2 years agoftests: Add a test for cgroup_add_all_controllers()
Tom Hromatka [Sat, 4 Mar 2023 03:14:47 +0000 (03:14 +0000)] 
ftests: Add a test for cgroup_add_all_controllers()

Add a test for cgroup_add_all_controllers()

-----------------------------------------------------------------
Test Results:
Run Date:                          Mar 04 04:00:53
Passed:                                  1 test(s)
Skipped:                                 0 test(s)
Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
Test                                                Time (sec)
--------------------------------------------------------------
setup                                                     0.00
074-pybindings-cgroup_add_all_controllers-v1.py           0.13
teardown                                                  0.00
--------------------------------------------------------------
Total Run Time                                            0.13

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit eca89d792f57b21dda820693a9b9b3fb8d253400)

2 years agoftests: Add a test for cgroup_add_all_controllers()
Tom Hromatka [Fri, 3 Mar 2023 18:16:00 +0000 (11:16 -0700)] 
ftests: Add a test for cgroup_add_all_controllers()

Add a test for cgroup_add_all_controllers()

-----------------------------------------------------------------
Test Results:
        Run Date:                          Mar 03 19:24:58
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                             Time (sec)
        -----------------------------------------------------------
        setup                                                  0.00
        073-pybindings-cgroup_add_all_controllers-v2.py        0.08
        teardown                                               0.00
        -----------------------------------------------------------
        Total Run Time                                         0.08

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit f1ee23f0ea5a57daeb1d00200649c160c23b7995)

2 years agopython: Add python bindings for cgroup_add_all_controllers()
Tom Hromatka [Fri, 3 Mar 2023 17:58:09 +0000 (10:58 -0700)] 
python: Add python bindings for cgroup_add_all_controllers()

Add python bindings for adding all controllers to a cgroup
instance via cgroup_add_all_controllers().

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit 176c3ae82b8e5880e3baca15d7f2a26740bc8b17)

2 years agoapi: Read cgroup.controllers in cgroup_get_cgroup()
Tom Hromatka [Fri, 3 Mar 2023 17:02:50 +0000 (10:02 -0700)] 
api: Read cgroup.controllers in cgroup_get_cgroup()

In cgroup_get_cgroup(), use the cgroup.controllers file
(rather than cgroup.subtree_control) to determine which
controllers are enabled.

To reduce code duplication, refactor cgroupv2_get_subtree_control()
to support reading both files.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit 856ee1af70e7bac2a31be4f555543b0f6d2a133f)

2 years agoftests: Add ability to enable/disable controllers in the subtree control file
Tom Hromatka [Wed, 8 Mar 2023 19:44:56 +0000 (12:44 -0700)] 
ftests: Add ability to enable/disable controllers in the subtree control file

Add a method to the functional tests that can enable/disable controllers
in the cgroup.subtree_control file.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit 5a331e5f20a05ae4bf0c95bc68f62670612546f8)

2 years agowrapper: Add cgroup v2 support to cgroup_add_all_controllers()
Tom Hromatka [Thu, 2 Mar 2023 23:25:12 +0000 (16:25 -0700)] 
wrapper: Add cgroup v2 support to cgroup_add_all_controllers()

Add cgroup v2 support to cgroup_add_all_controllers().  For cgroup v1
(both legacy and hybrid), cgroup_add_all_controllers() reads
/proc/cgroups.  For cgroup v2, cgroup_add_all_controllers() reads the
cgroup's cgroup.controllers file.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
(cherry picked from commit 4124f4d6853a5e12082d277b2320af0adecdbe5a)

2 years agogunit/009: adopt the cgroup_set_values_recursive() changes
Kamalesh Babulal [Tue, 21 Mar 2023 09:12:30 +0000 (09:12 +0000)] 
gunit/009: adopt the cgroup_set_values_recursive() changes

cgroup_set_values_recursive(), third argument ignore_non_dirty_values no
more suppress the errors but skips writing of the controller setting
that isn't marked dirty, propagate the changes to the test cases too.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit fadef32c8f7b09cca543bd111c82d50933c7e387)

2 years agoapi: cgroup_copy_controller_values() mark settings dirty
Kamalesh Babulal [Tue, 21 Mar 2023 09:06:16 +0000 (09:06 +0000)] 
api: cgroup_copy_controller_values() mark settings dirty

Copying controllers settings from source to destination cgroups,
overwrites the value of the destination cgroup controller and hence
the dirty flag for all the controller settings should be
unconditionally set.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 4a31a98174e2593b8cf0be2b8ee23e21ae8a84e5)

2 years agoapi.c: write dirty settings only in cgroup_set_values_recursive()
Kamalesh Babulal [Tue, 21 Mar 2023 09:04:46 +0000 (09:04 +0000)] 
api.c: write dirty settings only in cgroup_set_values_recursive()

cgroup_set_values_recursive() is called by cgroup_modify_cgroup() to
modify controller values, where all the settings modified or not are
written to the disk.  This breaks when writing a new value of a setting
that is linked to another setting of the controller, followed by writing
an unmodified value to the linked setting. This effectively undoes the
modification. For example, consider two linked settings of the cpu
controller: cpu.weight and cpu.weight.nice, where writing the new value
of cpu.weight is followed by unmodified cpu.weight.nice value. Writing
of the latter will undo the new value of the former.

Reproducer:
-----------

int print_cpu_weight()
{
        FILE *fp;
        char value[10];

        fp = fopen(PROC_CPU_WEIGHT, "r");
        if (!fp) {
                fprintf(stderr, "Failed to open %s\n", PROC_CPU_WEIGHT);
                return 1;
        }

        fgets(value, 10, fp);
        fprintf(stderr, "cpu.weight %s", value);
        fclose(fp);

        return 0;
}

int main(void)
{
        struct cgroup_controller *cgc;
        struct cgroup *cgroup;
        int ret;

        ret = cgroup_init();
        if (ret) {
                fprintf(stderr, "cgroup initialization failed\n");
                exit (1);
        }

         /* Create */
        cgroup = cgroup_new_cgroup(CGRP_NAME);
        if (!cgroup) {
                fprintf(stderr, "Failed to allocate cgroup %s\n", CGRP_NAME);
                exit(1);
        }

        cgc = cgroup_add_controller(cgroup, CTRL_NAME);
        if (!cgc) {
                fprintf(stderr, "Failed to add controller %s\n", CTRL_NAME);
                exit (1);
        }

        ret = cgroup_create_cgroup(cgroup, 0);
        if (ret) {
                fprintf(stderr, "Failed to create cgroup %s\n", CGRP_NAME);
                goto out;
        }

        ret = print_cpu_weight();
        if (ret)
                goto out;

        cgroup_free(&cgroup);

        /* Load and modify */
        cgroup = cgroup_new_cgroup(CGRP_NAME);
        if (!cgroup) {
                fprintf(stderr, "Failed to allocate cgroup %s\n", CGRP_NAME);
                exit(1);
        }

        ret = cgroup_get_cgroup(cgroup);
        if (ret) {
                fprintf(stderr, "Failed to get cgroup %s\n", CGRP_NAME);
                goto out;
        }

        cgc = NULL;
        cgc = cgroup_get_controller(cgroup, CTRL_NAME);
        if (!cgc) {
                fprintf(stderr, "Failed to get controller %s\n", CTRL_NAME);
                exit (1);
        }

        ret = cgroup_set_value_string(cgc, CTRL_SETTING, "8");
        if (ret) {
                fprintf(stderr, "Failed to set the %s value\n", CTRL_SETTING);
                goto out;
        }

        ret = cgroup_modify_cgroup(cgroup);
        if (ret) {
                fprintf(stderr, "Failed to modify cgroup\n");\
                goto out;
        }

        ret = print_cpu_weight();
        if (ret)
                goto out;

out:
        cgroup_free(&cgroup);
        return 0;
}

This patch additionally cleans up cgroup_set_values_recursive(), by
renaming the third argument ignore_non_dirty_failure to
ignore_non_dirty_values.  This rename also changes the purpose of the
flag, where the calling functions, set it to ignore the writing of the
controller setting, which is not modified/dirty and introduces extensive
checks for writing the controller setting.

Fixes: https://github.com/libcgroup/libcgroup/issues/323
Reported-by: Justin Israel <justinisrael@gmail.com>
[Justin contributed to the reproducer]
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 395f942761061fc8605b6555cf9d66836633f8db)

2 years agotests/gunit: Extend the fuzzer to test cgroup_get_value_bool()
Kamalesh Babulal [Wed, 8 Mar 2023 15:26:38 +0000 (20:56 +0530)] 
tests/gunit: Extend the fuzzer to test cgroup_get_value_bool()

Add fuzzing to the cgroup_get_value_bool() API, by passing combination
of valid/NULL as arguments to the API.

[----------] 13 tests from APIArgsTest
[ RUN      ] APIArgsTest.API_cgroup_set_permissions
[       OK ] APIArgsTest.API_cgroup_set_permissions (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_new_cgroup
[       OK ] APIArgsTest.API_cgroup_new_cgroup (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_string
[       OK ] APIArgsTest.API_cgroup_set_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_string
[       OK ] APIArgsTest.API_cgroup_get_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_add_controller
[       OK ] APIArgsTest.API_cgroup_add_controller (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_add_value_string
[       OK ] APIArgsTest.API_cgroup_add_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_uid_gid
[       OK ] APIArgsTest.API_cgroup_get_uid_gid (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_int64
[       OK ] APIArgsTest.API_cgroup_set_value_int64 (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_int64
[       OK ] APIArgsTest.API_cgroup_get_value_int64 (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_uint64
[       OK ] APIArgsTest.API_cgroup_set_value_uint64 (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_uint64
[       OK ] APIArgsTest.API_cgroup_get_value_uint64 (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_bool
[       OK ] APIArgsTest.API_cgroup_set_value_bool (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_bool
[       OK ] APIArgsTest.API_cgroup_get_value_bool (0 ms)
[----------] 13 tests from APIArgsTest (1 ms total)

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Fix comment typo
(cherry picked from commit c9b0182b269cae7788f0fb798a0e283cb8323010)

2 years agowrapper: fix segfault in cgroup_get_value_bool()
Kamalesh Babulal [Wed, 8 Mar 2023 15:26:24 +0000 (20:56 +0530)] 
wrapper: fix segfault in cgroup_get_value_bool()

The second and third arguments passed to cgroup_get_value_bool() are of
type pointers and the user might pass NULL in place of one or both of
the arguments, causing a segfault. The reason is, argument values are
used without checks, fix it by checking for NULL pointers before
proceeding.

Reproducer:
-----------

 #include <stdlib.h>
 #include <libcgroup.h>

 int main(void)
 {
  struct cgroup_controller *cgc;
  struct cgroup *cgrp;
  int ret;

  ret = cgroup_init();
  if (ret)
  exit(1);

  cgrp = cgroup_new_cgroup("fuzzer");
  if (!cgrp)
  exit(1);

  cgc = cgroup_add_controller(cgrp, "cpuset");
  if (!cgc)
  exit(1);

  ret = cgroup_add_value_string(cgc, "cpuset.cpu_exclusive", "0");
  if (ret)
  exit (1);

  cgroup_get_value_bool(cgc, "cpuset.cpu_exclusive", NULL);
//should not reach here
  return 0;
 }

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit b701e7de9b9d93aaf2d1cc03f483c7229e6239c3)

2 years agoftests: renumber the test case 098 to 998
Kamalesh Babulal [Wed, 8 Mar 2023 14:32:36 +0000 (07:32 -0700)] 
ftests: renumber the test case 098 to 998

The test cases, that cover the unlikely conditions, are numbered in the
reverse starting from 999, similarly, test case 098 tries to delete a
non-existent shared point.  Re-number it from '099' -> '998' to hint
at the nature of the test case.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 259928ed2aaac5c15a75b42c9c25583a1c707ef8)

2 years agotests/gunit: Extend the fuzzer to test cgroup_set_value_bool()
Kamalesh Babulal [Tue, 7 Mar 2023 05:32:23 +0000 (11:02 +0530)] 
tests/gunit: Extend the fuzzer to test cgroup_set_value_bool()

Add fuzzing to the cgroup_set_value_bool() API, by passing combination
of valid/NULL as arguments to the API.

[----------] 12 tests from APIArgsTest
[ RUN      ] APIArgsTest.API_cgroup_set_permissions
[       OK ] APIArgsTest.API_cgroup_set_permissions (1 ms)
[ RUN      ] APIArgsTest.API_cgroup_new_cgroup
[       OK ] APIArgsTest.API_cgroup_new_cgroup (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_string
[       OK ] APIArgsTest.API_cgroup_set_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_string
[       OK ] APIArgsTest.API_cgroup_get_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_add_controller
[       OK ] APIArgsTest.API_cgroup_add_controller (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_add_value_string
[       OK ] APIArgsTest.API_cgroup_add_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_uid_gid
[       OK ] APIArgsTest.API_cgroup_get_uid_gid (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_int64
[       OK ] APIArgsTest.API_cgroup_set_value_int64 (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_int64
[       OK ] APIArgsTest.API_cgroup_get_value_int64 (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_uint64
[       OK ] APIArgsTest.API_cgroup_set_value_uint64 (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_uint64
[       OK ] APIArgsTest.API_cgroup_get_value_uint64 (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_bool
[       OK ] APIArgsTest.API_cgroup_set_value_bool (0 ms)
[----------] 12 tests from APIArgsTest (1 ms total)

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 235874aea5f1c055c4ae99d0f41ea6e7f650aa96)

2 years agowrapper: fix segfault in cgroup_set_value_bool()
Kamalesh Babulal [Tue, 7 Mar 2023 05:32:09 +0000 (11:02 +0530)] 
wrapper: fix segfault in cgroup_set_value_bool()

The second argument passed to cgroup_set_value_bool() is of type
char * and the user might pass NULL in the place of the argument,
causing a segfault.  The reason is, argument values are used without
checks, fix it by checking for NULL pointers before proceeding.

Reproducer:
----------

 #include <stdlib.h>
 #include <libcgroup.h>

 int main(void)
 {
  struct cgroup_controller *cgc;
  struct cgroup *cgrp;
  int ret;

  ret = cgroup_init();
  if (ret)
  exit(1);

  cgrp = cgroup_new_cgroup("fuzzer");
  if (!cgrp)
  exit(1);

  cgc = cgroup_add_controller(cgrp, "cpuset");
  if (!cgc)
  exit(1);

  ret = cgroup_add_value_string(cgc, "cpuset.cpu_exclusive", "0");
  if (ret)
  exit (1);

  cgroup_set_value_bool(cgc, NULL, 0);
  //should not reach here
  return 0;
 }

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 6b5762ceaca18122b8d7a233b1d3453945594d32)

2 years agotools/cgxset: check for delimiter in name_value string
Kamalesh Babulal [Sat, 4 Mar 2023 06:34:10 +0000 (06:34 +0000)] 
tools/cgxset: check for delimiter in name_value string

While parsing -r option for name, and value pairs, we rely on strtok()
to return NULL, when there is no delimiter and lhf/rhf can't be mapped
into the name, and value tokens. This assumption is not true, strtok()
returns the whole string when it doesn't find the delimiter. Operating
under this assumption also segfaults later in the code.  Fix it, by
checking for the presence of a delimiter in the passed name_value_str
in parse_r_flag().  This also initializes the pointer to NULL, to avoid
reading them before assignment in the error path.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit bc414f494686c3bc66f2747b61c80a4f6e9118f5)

2 years agotools/cgset: check for delimiter in name_value string
Kamalesh Babulal [Sat, 4 Mar 2023 06:20:53 +0000 (06:20 +0000)] 
tools/cgset: check for delimiter in name_value string

While parsing -r option for name, and value pairs, we rely on strtok()
to return NULL, when there is no delimiter and lhf/rhf can't be mapped
into the name, and value tokens. This assumption is not true, strtok()
returns the whole string when it doesn't find the delimiter. Operating
under this assumption also segfaults later in the code.  Fix it, by
checking for the presence of a delimiter in the passed name_value_str
in parse_r_flag().  This also initializes the pointer to NULL, to
avoid reading them before assignment in the error path.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit b29c68bb5d36523e051f7ec0d92b2db93de26bf2)

2 years agotests/gunit: Extend the fuzzer to test cgroup_get_value_uint64()
Kamalesh Babulal [Sat, 4 Mar 2023 06:50:43 +0000 (12:20 +0530)] 
tests/gunit: Extend the fuzzer to test cgroup_get_value_uint64()

Add fuzzing to the cgroup_get_value_uint64() API, by passing combination
of valid/NULL as arguments to the API.

[----------] 11 tests from APIArgsTest
[ RUN      ] APIArgsTest.API_cgroup_set_permissions
[       OK ] APIArgsTest.API_cgroup_set_permissions (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_new_cgroup
[       OK ] APIArgsTest.API_cgroup_new_cgroup (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_string
[       OK ] APIArgsTest.API_cgroup_set_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_string
[       OK ] APIArgsTest.API_cgroup_get_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_add_controller
[       OK ] APIArgsTest.API_cgroup_add_controller (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_add_value_string
[       OK ] APIArgsTest.API_cgroup_add_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_uid_gid
[       OK ] APIArgsTest.API_cgroup_get_uid_gid (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_int64
[       OK ] APIArgsTest.API_cgroup_set_value_int64 (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_int64
[       OK ] APIArgsTest.API_cgroup_get_value_int64 (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_uint64
[       OK ] APIArgsTest.API_cgroup_set_value_uint64 (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_uint64
[       OK ] APIArgsTest.API_cgroup_get_value_uint64 (0 ms)
[----------] 11 tests from APIArgsTest (0 ms total)

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Fix comment typo
(cherry picked from commit 81f12364c78a8f7f1e90b5ce90e9f02cf057c623)

2 years agowrapper: fix segfault in cgroup_get_value_uint64()
Kamalesh Babulal [Sat, 4 Mar 2023 06:50:03 +0000 (12:20 +0530)] 
wrapper: fix segfault in cgroup_get_value_uint64()

The second and third arguments passed to cgroup_get_value_uint64() are
of type char * and the user might pass NULL in place of one or both of
the arguments, causing a segfault. The reason is, argument values are
used without checks, fix it by checking for NULL pointers before
proceeding.

Reproducer:
-----------
 #include <stdlib.h>
 #include <libcgroup.h>

 int main(void)
 {
  struct cgroup_controller *cgc;
  struct cgroup *cgrp;
  int ret;

  ret = cgroup_init();
  if (ret)
  exit(1);

  cgrp = cgroup_new_cgroup("fuzzer");
  if (!cgrp)
  exit(1);

  cgc = cgroup_add_controller(cgrp, "cpu");
  if (!cgc)
  exit(1);

  ret = cgroup_add_value_string(cgc, "cpu.shares", "512");
  if (ret)
  exit (1);

  cgroup_get_value_uint64(cgc, NULL, NULL);
  // should not reach here.
  return 0;
 }

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 5ac8e5e4cfca037198b729435bdeb692ec90d351)

2 years agotests/gunit: Extend the fuzzer to test cgroup_set_value_uint64()
Kamalesh Babulal [Sat, 4 Mar 2023 04:19:23 +0000 (09:49 +0530)] 
tests/gunit: Extend the fuzzer to test cgroup_set_value_uint64()

Add fuzzing to the cgroup_set_value_uint64() API, by passing combination
of valid/NULL as arguments to the API.

[----------] 10 tests from APIArgsTest
[ RUN      ] APIArgsTest.API_cgroup_set_permissions
[       OK ] APIArgsTest.API_cgroup_set_permissions (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_new_cgroup
[       OK ] APIArgsTest.API_cgroup_new_cgroup (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_string
[       OK ] APIArgsTest.API_cgroup_set_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_string
[       OK ] APIArgsTest.API_cgroup_get_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_add_controller
[       OK ] APIArgsTest.API_cgroup_add_controller (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_add_value_string
[       OK ] APIArgsTest.API_cgroup_add_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_uid_gid
[       OK ] APIArgsTest.API_cgroup_get_uid_gid (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_int64
[       OK ] APIArgsTest.API_cgroup_set_value_int64 (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_int64
[       OK ] APIArgsTest.API_cgroup_get_value_int64 (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_uint64
[       OK ] APIArgsTest.API_cgroup_set_value_uint64 (0 ms)
[----------] 10 tests from APIArgsTest (0 ms total)

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 4467ccbd0bf54aa4ad8c7c50628ce2a46668181f)

2 years agowrapper: fix segfault in cgroup_set_value_uint64()
Kamalesh Babulal [Sat, 4 Mar 2023 04:18:53 +0000 (09:48 +0530)] 
wrapper: fix segfault in cgroup_set_value_uint64()

The second argument passed to cgroup_set_value_uint64() is of type
char * and the user might pass NULL in the place of the argument,
causing a segfault.  The reason is, argument values are used without
checks, fix it by checking for NULL pointers before proceeding.

Reproducer:
-----------
 #include <stdlib.h>
 #include <libcgroup.h>

 int main(void)
 {
         struct cgroup_controller *cgc;
         struct cgroup *cgrp;
         int ret;

         ret = cgroup_init();
         if (ret)
                 exit(1);

         cgrp = cgroup_new_cgroup("fuzzer");
         if (!cgrp)
                 exit(1);

         cgc = cgroup_add_controller(cgrp, "cpu");
         if (!cgc)
                 exit(1);

         ret = cgroup_add_value_string(cgc, "cpu.shares", "512");
         if (ret)
                 exit (1);

         cgroup_set_value_uint64(cgc, NULL, 512);
         // should not reach here.
         return 0;
 }

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit afb6c6ab0ca1c7812bb8229c7054ba4917402f67)

2 years agotests/gunit: Extend the fuzzer to test cgroup_get_value_int64()
Kamalesh Babulal [Fri, 3 Mar 2023 04:31:57 +0000 (10:01 +0530)] 
tests/gunit: Extend the fuzzer to test cgroup_get_value_int64()

Add fuzzing to the cgroup_get_value_int64() API, by passing combination
of valid/NULL as arguments to the API.

[----------] 9 tests from APIArgsTest
[ RUN      ] APIArgsTest.API_cgroup_set_permissions
[       OK ] APIArgsTest.API_cgroup_set_permissions (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_new_cgroup
[       OK ] APIArgsTest.API_cgroup_new_cgroup (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_string
[       OK ] APIArgsTest.API_cgroup_set_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_string
[       OK ] APIArgsTest.API_cgroup_get_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_add_controller
[       OK ] APIArgsTest.API_cgroup_add_controller (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_add_value_string
[       OK ] APIArgsTest.API_cgroup_add_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_uid_gid
[       OK ] APIArgsTest.API_cgroup_get_uid_gid (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_int64
[       OK ] APIArgsTest.API_cgroup_set_value_int64 (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_int64
[       OK ] APIArgsTest.API_cgroup_get_value_int64 (0 ms)
[----------] 9 tests from APIArgsTest (0 ms total)

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit f9c1524f8e8c855885982ace43ca655bea077468)

2 years agowrapper: fix segfault in cgroup_get_value_int64()
Kamalesh Babulal [Fri, 3 Mar 2023 04:31:41 +0000 (10:01 +0530)] 
wrapper: fix segfault in cgroup_get_value_int64()

The second and third arguments passed to cgroup_get_value_int64() are of
type char * and the user might pass NULL in place of one or both of the
arguments, causing a segfault. The reason is, argument values are used
without checks, fix it by checking for NULL pointers before proceeding.

Reproducer:
-----------
 #include <stdlib.h>
 #include <libcgroup.h>

 int main(void)
 {
  struct cgroup_controller *cgc;
  struct cgroup *cgrp;
  int ret;

  ret = cgroup_init();
  if (ret)
  exit(1);

  cgrp = cgroup_new_cgroup("fuzzer");
  if (!cgrp)
  exit(1);

  cgc = cgroup_add_controller(cgrp, "cpu");
  if (!cgc)
  exit(1);

  ret = cgroup_add_value_string(cgc, "cpu.shares", "512");
  if (ret)
  exit (1);

  cgroup_get_value_int64(cgc, NULL, NULL);
  // should not reach here.
  return 0;
 }

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit cf616d09d740e7a890e8af3ec9d5799f1713718b)

2 years agotests/gunit: Extend the fuzzer to test cgroup_set_value_int64()
Kamalesh Babulal [Thu, 2 Mar 2023 05:05:04 +0000 (10:35 +0530)] 
tests/gunit: Extend the fuzzer to test cgroup_set_value_int64()

Add fuzzing to the cgroup_set_value_int64() API, by passing combination
of valid/NULL as arguments to the API.

[----------] 8 tests from APIArgsTest
[ RUN      ] APIArgsTest.API_cgroup_set_permissions
[       OK ] APIArgsTest.API_cgroup_set_permissions (1 ms)
[ RUN      ] APIArgsTest.API_cgroup_new_cgroup
[       OK ] APIArgsTest.API_cgroup_new_cgroup (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_string
[       OK ] APIArgsTest.API_cgroup_set_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_string
[       OK ] APIArgsTest.API_cgroup_get_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_add_controller
[       OK ] APIArgsTest.API_cgroup_add_controller (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_add_value_string
[       OK ] APIArgsTest.API_cgroup_add_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_uid_gid
[       OK ] APIArgsTest.API_cgroup_get_uid_gid (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_int64
[       OK ] APIArgsTest.API_cgroup_set_value_int64 (0 ms)
[----------] 8 tests from APIArgsTest (1 ms total)

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit bcecc2d45b3848c5d1075a6f24f4c2302621fedf)

2 years agowrapper: fix segfault in cgroup_set_value_int64()
Kamalesh Babulal [Thu, 2 Mar 2023 05:04:49 +0000 (10:34 +0530)] 
wrapper: fix segfault in cgroup_set_value_int64()

The second argument passed to cgroup_set_value_int64() is of type char *
and the user might pass NULL in the place of the argument, causing a
segfault.  The reason is, argument values are used without checks, fix
it by checking for NULL pointers before proceeding.

Reproducer:
-----------
 #include <stdlib.h>
 #include <libcgroup.h>

 int main(void)
 {
         struct cgroup_controller *cgc;
         struct cgroup *cgrp;
         int ret;

         ret = cgroup_init();
         if (ret)
                 exit(1);

         cgrp = cgroup_new_cgroup("fuzzer");
         if (!cgrp)
                 exit(1);

         cgc = cgroup_add_controller(cgrp, "cpu");
         if (!cgc)
                 exit(1);

         ret = cgroup_add_value_string(cgc, "cpu.shares", "512");
         if (ret)
                 exit (1);

         cgroup_set_value_int64(cgc, NULL, 512);
         // should not reach here.
         return 0;
 }

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 3d56cb07193682da2df078820427e45b458b5823)

2 years agoftests: Cleanup pid logic in functional tests
Tom Hromatka [Fri, 17 Feb 2023 22:16:34 +0000 (15:16 -0700)] 
ftests: Cleanup pid logic in functional tests

PIDs were inconsistently being managed in the functional tests.  Some
functions treated them as `int` and in others they were `str`.  Modify
all functions that deal with PIDs to treat them as `int` or a list of
`int`s.

Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 8483426ea7dcfe1e513ecbfc287a3a51f1097335)

2 years agotests/gunit: Extend the fuzzer to test cgroup_get_uid_gid()
Kamalesh Babulal [Tue, 28 Feb 2023 09:15:11 +0000 (14:45 +0530)] 
tests/gunit: Extend the fuzzer to test cgroup_get_uid_gid()

Add fuzzing to the cgroup_get_uid_gid() API, by passing combination of
of valid/NULL as arguments to the API.

[----------] 7 tests from APIArgsTest
[ RUN      ] APIArgsTest.API_cgroup_set_permissions
[       OK ] APIArgsTest.API_cgroup_set_permissions (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_new_cgroup
[       OK ] APIArgsTest.API_cgroup_new_cgroup (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_string
[       OK ] APIArgsTest.API_cgroup_set_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_string
[       OK ] APIArgsTest.API_cgroup_get_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_add_controller
[       OK ] APIArgsTest.API_cgroup_add_controller (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_add_value_string
[       OK ] APIArgsTest.API_cgroup_add_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_uid_gid
[       OK ] APIArgsTest.API_cgroup_get_uid_gid (0 ms)

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 72a3d75036f00541cbc4a0dac3d9c6ca138869e8)

2 years agowrapper: fix segfault in cgroup_get_uid_gid()
Kamalesh Babulal [Tue, 28 Feb 2023 09:15:05 +0000 (14:45 +0530)] 
wrapper: fix segfault in cgroup_get_uid_gid()

The arguments passed to cgroup_get_uid_gid() are of type pointers and
the user might pass NULL in place of or all of the arguments, causing
a segfault. segfault is triggered when the NULL, argument value is
passed without check, fix it by checking for NULL before proceeding.

Reproducer:
-----------

int main(void)
{
struct cgroup *cgrp;
uid_t tuid, cuid;
gid_t tgid, cgid;

int ret;

ret = cgroup_init();
if (ret) {
printf("Failed to initialize: %s\n", cgroup_strerror(ret));
exit (1);
}

cgrp = cgroup_new_cgroup("fuzzer");
if (!cgrp) {
printf("Failed to allocate cgroup fuzzer\n");
exit(1);
}

ret = cgroup_create_cgroup(cgrp, 1);
if (ret) {
printf("failed to create %s: %s\n", "fuzzer", cgroup_strerror(ret));
goto err;
}

cgroup_get_uid_gid(cgrp, NULL, NULL, NULL, NULL);
// should not reach here

return 0;
}

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 3d439e58f2487dca33ebf568ac323714a5c1ecfc)

2 years agogithub/actions: Introduce a timeout to avoid apt races
Kamalesh Babulal [Wed, 22 Feb 2023 14:43:45 +0000 (20:13 +0530)] 
github/actions: Introduce a timeout to avoid apt races

There are chances that apt-get operations are run on the same VM by
different runners both competing to get apt locks. Introduce timeout of
3 seconds, in case the lock is already taken by another instance of
a runner.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit ddcd79dede4265d891247004432f9c4e845a5a4a)

2 years agotests/ftests: synchronize between github runners
Kamalesh Babulal [Wed, 22 Feb 2023 17:06:13 +0000 (10:06 -0700)] 
tests/ftests: synchronize between github runners

If a VM is shared between multiple github runners, there are chances of
each other stomping over other's run, if executed parallelly.  To avoid
the race between the runners, introduce lock file, that gets acquired
(created) when ftest.sh starts and get removed by ftest-nocontainer.sh,
this ensures that both test cases are executed before other runner,
that's waiting for its chance to run.  A runner would wait for
10 minutes before re-trying to run.  At the max, a runner would wait for
50 minutes (5 retries) before giving up.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit ec78fee3b4970f24024be21fd20e3031dcbc71ab)

2 years agotests/gunit: Extend the fuzzer to test cgroup_add_value_string()
Kamalesh Babulal [Mon, 27 Feb 2023 04:21:19 +0000 (09:51 +0530)] 
tests/gunit: Extend the fuzzer to test cgroup_add_value_string()

Add fuzzing to the cgroup_add_value_string() API, by passing combination
of valid/NULL as arguments to the API.

[----------] 6 tests from APIArgsTest
[ RUN      ] APIArgsTest.API_cgroup_set_permissions
[       OK ] APIArgsTest.API_cgroup_set_permissions (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_new_cgroup
[       OK ] APIArgsTest.API_cgroup_new_cgroup (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_string
[       OK ] APIArgsTest.API_cgroup_set_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_string
[       OK ] APIArgsTest.API_cgroup_get_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_add_controller
[       OK ] APIArgsTest.API_cgroup_add_controller (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_add_value_string
[       OK ] APIArgsTest.API_cgroup_add_value_string (0 ms)
[----------] 6 tests from APIArgsTest (0 ms total)

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit aa1148a7b50e7f8bc33cad0a013b9545716365a2)

2 years agowrapper: fix segfault in cgroup_add_value_string
Kamalesh Babulal [Mon, 27 Feb 2023 04:20:34 +0000 (09:50 +0530)] 
wrapper: fix segfault in cgroup_add_value_string

The second and third arguments passed to cgroup_add_value_string() are
of type char * and the user might pass NULL in place of one or both of
the arguments, causing a segfault.  segfault is trigger when the NULL,
argument value is passed to second argument without check, fix it by
checking for NULL before proceeding.

Reproducer:
----------

int main(void)
{
        struct cgroup_controller *cgc;
        struct cgroup *cgrp;
        int ret;

        ret = cgroup_init();
        if (ret)
exit (1);

        cgrp = cgroup_new_cgroup("fuzzer");
        if (!cgrp)
exit (1);

        cgc = cgroup_add_controller(cgrp, "cpu");
        if (!cgc)
exit (1);

        cgroup_add_value_string(cgc, NULL, NULL);

// should not reach here
return 0;
}

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 097a766dd055c41cc6639276d54b8817e512a252)

2 years agotools/cgxset: Fix potential memory leak in converted_src_cgroup
Tom Hromatka [Wed, 22 Feb 2023 21:09:07 +0000 (14:09 -0700)] 
tools/cgxset: Fix potential memory leak in converted_src_cgroup

There's a brief window where converted_src_cgroup is allocated but
hasn't been assigned to the *cgroup pointer.  If a failure occurs in
this window, then converted_src_cgroup must be freed before doing the
goto to the error path.

Also, simplify the error-handling logic in cgxset::main() by having all
errors goto "err".

Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit f1579cec2734c767d24f69944e1e5f07e1c1e3af)

2 years agotests/gunit: Extend the fuzzer to test cgroup_add_controller()
Kamalesh Babulal [Fri, 24 Feb 2023 05:35:07 +0000 (11:05 +0530)] 
tests/gunit: Extend the fuzzer to test cgroup_add_controller()

Add fuzzing to the cgroup_add_controller() API, by passing combination
of valid/NULL as arguments to the API.

[----------] 5 tests from APIArgsTest
[ RUN      ] APIArgsTest.API_cgroup_set_permissions
[       OK ] APIArgsTest.API_cgroup_set_permissions (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_new_cgroup
[       OK ] APIArgsTest.API_cgroup_new_cgroup (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_string
[       OK ] APIArgsTest.API_cgroup_set_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_string
[       OK ] APIArgsTest.API_cgroup_get_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_add_controller
[       OK ] APIArgsTest.API_cgroup_add_controller (0 ms)
[----------] 5 tests from APIArgsTest (0 ms total)

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 4bec8844d71e3c7428dddcff29c7006dc378a5ec)

2 years agowrapper: fix segfault in cgroup_add_controller()
Kamalesh Babulal [Fri, 24 Feb 2023 05:35:02 +0000 (11:05 +0530)] 
wrapper: fix segfault in cgroup_add_controller()

The second argument passed to cgroup_add_controller() is of type
char * and the user might pass NULL in place of the arguments, causing
a segfault.  segfault is trigger when the NULL, argument values is used
without checks, fix it by checking for NULL before proceeding.

Reproducer:
-----------

int main(void)
{
struct cgroup_controller *cgc;
struct cgroup *cgrp;
int ret;

cgroup_init();
if (ret)
exit(1);

cgrp = cgroup_new_cgroup("fuzzer");
if (!cgrp)
exit(1);

cgc = cgroup_add_controller(cgrp, "cpu");
if (!cgc)
exit(1);

cgroup_add_controller(cgrp, NULL);

// should not reach here
return 0;
}

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 42436e7e32412c32d2130198fe8a4c0ff48e1d07)

2 years agoapi: allocate correct value size to copy value provided to cgroup_set_value_string
Justin Israel [Thu, 23 Feb 2023 22:53:17 +0000 (11:53 +1300)] 
api: allocate correct value size to copy value provided to cgroup_set_value_string

Signed-off-by: Justin Israel <justinisrael@gmail.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit b90efb3e2d7741e16bebee9774453346f45ba258)

2 years agotests/ftest: use string filter() to concatenation cause
Kamalesh Babulal [Thu, 23 Feb 2023 13:45:54 +0000 (13:45 +0000)] 
tests/ftest: use string filter() to concatenation cause

if, then, else construction is used to concatenate the 'cause' string,
that appends the reason for the test failures.  The reason to use the
checks to TypeError that occurs while concatenating None and str type.
Replace them with a one-liner string.filter(), across the test sources.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 5d4bd5c2532a7ffdbf0bab333dee4a9be4cb17ba)

2 years agotests/gunit: Extend the fuzzer to test cgroup_get_value_string()
Kamalesh Babulal [Tue, 21 Feb 2023 13:10:05 +0000 (13:10 +0000)] 
tests/gunit: Extend the fuzzer to test cgroup_get_value_string()

Add fuzzing to the cgroup_get_value_string() API, by passing combination
of valid/NULL as arguments to the API.

s
[----------] 4 tests from APIArgsTest
[ RUN      ] APIArgsTest.API_cgroup_set_permissions
[       OK ] APIArgsTest.API_cgroup_set_permissions (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_new_cgroup
[       OK ] APIArgsTest.API_cgroup_new_cgroup (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_string
[       OK ] APIArgsTest.API_cgroup_set_value_string (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_get_value_string

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 689d7fb7105727675ba6487530903b1f7e6ef50a)

2 years agowrapper: fix segfault in cgroup_get_value_string()
Kamalesh Babulal [Tue, 21 Feb 2023 10:49:06 +0000 (10:49 +0000)] 
wrapper: fix segfault in cgroup_get_value_string()

The second and third arguments passed to cgroup_get_value_string() are
of type char * and the user might pass NULL in place of one or both of
the arguments, causing a segfault.  segfault is trigger when the NULL,
argument values are used without checks, fix it by checking for NULL
before proceeding.

Reproducer:
-----------

int main(void)
{
        struct cgroup_controller *cgc;
        struct cgroup *cgrp;
        int ret;

        cgroup_init();
        if (ret)
                exit(1);

        cgrp = cgroup_new_cgroup("fuzzer");
        if (!cgrp)
                exit(1);

        cgc = cgroup_add_controller(cgrp, "cpu");
        if (!cgc)
                exit(1);

        ret = cgroup_add_value_string(cgc, "cpu.shares", "1024");
        if (!cgc)
                exit(1);

        ret = cgroup_create_cgroup(cgrp, 1);
        if (ret)
                exit(1);

        cgc = cgroup_get_controller(cgrp, "cpu");
        if (!cgc)
                exit(1);

        cgroup_get_value_string(cgc, NULL, NULL);

        return 0;
}

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 08bb9a32592079b982e93b1e21fc084431334c2d)

2 years agotests/gunit: Extend the fuzzer to test cgroup_set_value_string()
Kamalesh Babulal [Tue, 21 Feb 2023 13:13:25 +0000 (13:13 +0000)] 
tests/gunit: Extend the fuzzer to test cgroup_set_value_string()

Add fuzzing to the cgroup_set_value_string() API, by passing combination
of valid/NULL as arguments to the API.

[----------] 3 tests from APIArgsTest
[ RUN      ] APIArgsTest.API_cgroup_set_permissions
[       OK ] APIArgsTest.API_cgroup_set_permissions (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_new_cgroup
[       OK ] APIArgsTest.API_cgroup_new_cgroup (0 ms)
[ RUN      ] APIArgsTest.API_cgroup_set_value_string
[       OK ] APIArgsTest.API_cgroup_set_value_string (19 ms)
[----------] 3 tests from APIArgsTest (19 ms total)

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit c259bb79641582f08a5ddd3e1f85aa7a018ba716)

2 years agowrapper: fix segfault in cgroup_set_value_string()
Kamalesh Babulal [Mon, 20 Feb 2023 15:09:07 +0000 (15:09 +0000)] 
wrapper: fix segfault in cgroup_set_value_string()

The second and third arguments passed to cgroup_set_value_string() are
of type char * and the user might pass NULL in place of one or both of
the arguments, causing a segfault.  segfault is trigger when the NULL,
argument values are used without checks, fix it by checking for NULL
before proceeding.

Reproducer:
-----------

int main(void)
{
        struct cgroup_controller *cgc;
        struct cgroup *cgrp;

        cgroup_init();
        if (ret)
exit(1);

        cgrp = cgroup_new_cgroup("fuzzer");
        if (!cgrp)
                exit(1);

        cgc = cgroup_add_controller(cgrp, "cpu");
        if (!cgc)
exit(1);

        ret = cgroup_create_cgroup(cgrp, 1);
        if (ret)
exit(1);

        cgroup_set_value_string(cgc, NULL, NULL);

// should not reach here.
return 0;
}

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 3eabc319b1af5ab8024eb9145e196270c4cdec94)

2 years agoftests: Add cgroup_get_cgroup() pybindings test
Tom Hromatka [Wed, 15 Feb 2023 21:50:14 +0000 (14:50 -0700)] 
ftests: Add cgroup_get_cgroup() pybindings test

Add a test to exercise cgroup_get_cgroup() and its python bindings.

-----------------------------------------------------------------
Test Results:
Run Date:                          Feb 15 14:50:00
Passed:                                  1 test(s)
Skipped:                                 0 test(s)
Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
Test                                    Time (sec)
--------------------------------------------------
setup                                         0.00
072-pybindings-cgroup_get_cgroup.py           2.66
teardown                                      0.00
--------------------------------------------------
Total Run Time                                2.66

Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 62426a9b1395c34b2527eb1b193eaaa8b5906b35)

2 years agoapi: Don't return an error when no cgroups are enabled
Tom Hromatka [Tue, 21 Feb 2023 21:17:58 +0000 (14:17 -0700)] 
api: Don't return an error when no cgroups are enabled

Don't return an error, ECGROUPNOTEXIST (50002), from cgroup_get_cgroup()
when no controllers are enabled in a cgroup v2 cgroup.

Simple reproducer:
sudo mkdir -p /sys/fs/cgroup/foo/bar

#!/usr/bin/env python3
from libcgroup import Cgroup, Version

cg = Cgroup('foo/bar', Version.CGROUP_V2)
cg.get()
print(cg)

Prior to this change, the above python code returned ECGROUPNOTEXIST in
the cg.get() line.  Now it successfully completes, but no controllers
are populated.

Reported-by: Justin Israel <justinisrael@gmail.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 7c99c8a385c5946c8873313b8c99cc9b5cf25bfd)

2 years agoapi: Add support for "cgroup" controller in cgroup v2
Tom Hromatka [Tue, 14 Feb 2023 19:58:59 +0000 (12:58 -0700)] 
api: Add support for "cgroup" controller in cgroup v2

The "cgroup" controller has settings that the user may want to
read/write, e.g. cgroup.controllers, cgroup.subtree_control,
cgroup.procs, etc.

Add support for this controller when the cgroup v2 mount table is
parsed by creating a custom controller for the "cgroup" settings.
Note that this feature has not been added to cgroup v1 and cgroup v1
will continue to have limited access to the cgroup.* files.

Reported-by: Justin Israel <justinisrael@gmail.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit b09f6e750ecdf605f5b9cae97e6b831b6ecf187d)

2 years agoapi: Support specifying controllers in cgroup_get_cgroup()
Tom Hromatka [Tue, 14 Feb 2023 19:53:03 +0000 (12:53 -0700)] 
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>
(cherry picked from commit 6bb000d2dc90eb0e9966bba0aaf70c0daa655e09)

2 years agotools/cgset: fix Uninitialized pointer read
Kamalesh Babulal [Fri, 17 Feb 2023 09:59:30 +0000 (09:59 +0000)] 
tools/cgset: fix Uninitialized pointer read

Fix Uninitialized pointer read, reported by Coverity Tool:

CID 307779 (#2 of 2): Uninitialized pointer read (UNINIT)22.
uninit_use_in_call: Using uninitialized value src_cgroup when calling
cgroup_free.

In main(), src_cgrp points to a valid struct cgroup only when the
user calls cgxset using --copy-from flag, Coverity warns about the
freeing src_cgrp, which is uninitialized in the error path.  This patch
initializes converted_src_cgroup, src_cgroup and cgroup uninitialized
pointers and checks is src_cgrp is valid pointer before passing it to
cgroup_free()

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 94ba8b65f8b3424232cf3fea5a06fbbfb921789a)

2 years agotools/cgset: fix Uninitialized pointers read
Kamalesh Babulal [Fri, 17 Feb 2023 09:54:50 +0000 (09:54 +0000)] 
tools/cgset: fix Uninitialized pointers read

Fix Uninitialized pointer read, reported by Coverity Tool:

CID 307778 (#2 of 2): Uninitialized pointer read (UNINIT)22.
uninit_use_in_call: Using uninitialized value src_cgroup when calling
cgroup_free.

In main(), src_cgrp points to a valid struct cgroup only when the user
calls cgset using --copy-from flag, Coverity warns about the freeing
src_cgrp, which is uninitialized in the error path.  This patch
initializes src_cgrp and cgroup uninitialized pointers and checks
is src_cgrp is valid pointer before passing it to cgroup_free()

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 4611135a0672ba2bb2b275cd71e57873da4ec293)

2 years agotests: Add a test for the python bindings to cgroup_set_default_systemd_cgroup
Kamalesh Babulal [Thu, 16 Feb 2023 13:36:48 +0000 (13:36 +0000)] 
tests: Add a test for the python bindings to cgroup_set_default_systemd_cgroup

Add a test for the python bindings to cgroup_set_default_systemd_cgroup()

-----------------------------------------------------------------
Test Results:
        Run Date:                          Feb 16 13:36:28
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                       Time (sec)
        -----------------------------------------------------
        setup                                            0.00
        071-sudo-set_default_systemd_cgroup.py           0.02
        teardown                                         0.00
        -----------------------------------------------------
        Total Run Time                                   0.02

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Remove unnecessary int() typecast and add the test to Makefile.am
(cherry picked from commit 0b4016adcb47ee4dd5f478389281e84386527d89)

2 years agopython: binding to read and set systemd_default_cgroup
Kamalesh Babulal [Mon, 13 Feb 2023 06:49:59 +0000 (06:49 +0000)] 
python: binding to read and set systemd_default_cgroup

Add an python binding that reads /run/libcgroup/systemd and if the file
exists, sets the systemd_default_cgroup. Then on all the paths
constructed, has the systemd_default_cgroup appended to it.  This is
used when cgroup sub-tree is constructed for systemd delegation.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 67805afc3f02495ab32fdc640f062c48b6e6b8f0)

2 years agoman: document cgexec's -b (systemd) option
Kamalesh Babulal [Thu, 16 Feb 2023 12:08:54 +0000 (17:38 +0530)] 
man: document cgexec's -b (systemd) option

Add documentation about the -b option in the cgexec's man page. This
option ignores the default systemd delegated hierarchy path and
constructs the path of the control groups relative to the cgroup root
hierarchy.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 9be92b8ddb2f63201ae028bee9d44e5a01e93b9a)

2 years agoman: document cgclassify's -b (systemd) option
Kamalesh Babulal [Thu, 16 Feb 2023 12:08:54 +0000 (17:38 +0530)] 
man: document cgclassify's -b (systemd) option

Add documentation about the -b option in the cgclassify's man page.
This option ignores the default systemd delegated hierarchy path
and constructs the path of the control groups relative to the cgroup
root hierarchy.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit ba505b05cd22370de0d0bf37818275075199afe7)

2 years agoman: document cgcreate's -b (systemd) option
Kamalesh Babulal [Thu, 16 Feb 2023 12:08:54 +0000 (17:38 +0530)] 
man: document cgcreate's -b (systemd) option

Add documentation about the -b option in the cgcreate's man page. This
option ignores the default systemd delegated hierarchy path and
constructs the path of the control groups relative to the cgroup root
hierarchy.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 230dbbe679688864ce2a7005b5bea3d246efdd11)

2 years agoman: document cgxset's -b (systemd) option
Kamalesh Babulal [Thu, 16 Feb 2023 12:08:54 +0000 (17:38 +0530)] 
man: document cgxset's -b (systemd) option

Add documentation about the -b option in the cgxset's man page. This
option ignores the default systemd delegated hierarchy path and
constructs the path of the control groups relative to the cgroup root
hierarchy.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit ae92896abd762cbc8cdcd66387931913f0e13eb7)

2 years agoman: document cgxget's -b (systemd) option
Kamalesh Babulal [Thu, 16 Feb 2023 12:08:54 +0000 (17:38 +0530)] 
man: document cgxget's -b (systemd) option

Add documentation about the -b option in the cgxget's man page. This
option ignores the default systemd delegated hierarchy path and
constructs the path of the control groups relative to the cgroup root
hierarchy.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit d4e4bff5b612939267779f0a14f6b2a261bb0744)

2 years agoman: document cgdelete's -b (systemd) option
Kamalesh Babulal [Thu, 16 Feb 2023 12:08:54 +0000 (17:38 +0530)] 
man: document cgdelete's -b (systemd) option

Add documentation about the -b option in the cgdelete's man page. This
option ignores the default systemd delegated hierarchy path and
constructs the path of the control groups relative to the cgroup root
hierarchy.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 7992ea983fdf5a819b7daeb9b0791e2e5cb331e1)

2 years agoman: document cgset's -b (systemd) option
Kamalesh Babulal [Thu, 16 Feb 2023 12:08:54 +0000 (17:38 +0530)] 
man: document cgset's -b (systemd) option

Add documentation about the -b option in the cgset's man page. This
option ignores the default systemd delegated hierarchy path and
constructs the path of the control groups relative to the cgroup root
hierarchy.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit a3319e29f07172b0c906e83109e86b8360813502)

2 years agoman: document cgget's -b (systemd) option
Kamalesh Babulal [Thu, 16 Feb 2023 12:08:54 +0000 (17:38 +0530)] 
man: document cgget's -b (systemd) option

Add documentation about the -b option in the cgget's man page. This
option ignores the default systemd delegated hierarchy path and
constructs the path of the control groups relative to the cgroup root
hierarchy.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 2df89264ac8c8ba6693d3e48cc2424a9e73ff951)

2 years agoman: document cgget's -m option
Kamalesh Babulal [Thu, 16 Feb 2023 12:05:02 +0000 (17:35 +0530)] 
man: document cgget's -m option

Add documentation about the -m option in the cgget's man page. This
option prints the current cgroup setup mode.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 625e35fb05dcc898e32687026454146f03df4807)

2 years agopybindings: Fix a build warning on Fedora
Kamalesh Babulal [Wed, 15 Feb 2023 19:06:33 +0000 (12:06 -0700)] 
pybindings: Fix a build warning on Fedora

While building python bindings on Fedora 34, gcc 11.3.1 triggers a
build warning:
[1/1] Cythonizing libcgroup.pyx
In file included from /usr/include/bits/libc-header-start.h:33,
                 from /usr/include/limits.h:26,
                 from /usr/lib/gcc/x86_64-redhat-linux/11/include/limits.h:203,
                 from /usr/lib/gcc/x86_64-redhat-linux/11/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/11/include/limits.h:34,
                 from /usr/include/python3.9/Python.h:11,
                 from libcgroup.c:25:
/usr/include/features.h:397:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
  397 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
      |    ^~~~~~~

the reason being the default compiler flags for c/c++ includes
'-Wp,-D_FORTIFY_SOURCE=2' and '-D_FORTIFY_SOURCE=2'. Whereas Ubuntu
compilers include '-D_FORTIFY_SOURCE=2' option only.  This can be
fixed by adding '-O2' to the CPP Flags in the pybinding Makefile and
there is no side effect in both Fedora and Ubuntu because by default
'-D_FORTIFY_SOURCE=2' is included. The Ubuntu automatically auto
includes '-D_FORTIFY_SOURCE=2' when '-O2' is passed but here it's been
already explicitly passed.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 577d364472701b24a85a1bdadd8ec32b76c45eb5)

2 years agoRFE: Bump redhat-plumbers-in-action/differential-shellcheck from 3 to 4
dependabot[bot] [Fri, 10 Feb 2023 22:12:16 +0000 (15:12 -0700)] 
RFE: Bump redhat-plumbers-in-action/differential-shellcheck from 3 to 4

Bumps [redhat-plumbers-in-action/differential-shellcheck](https://github.com/redhat-plumbers-in-action/differential-shellcheck) from 3 to 4.
- [Release notes](https://github.com/redhat-plumbers-in-action/differential-shellcheck/releases)
- [Changelog](https://github.com/redhat-plumbers-in-action/differential-shellcheck/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/redhat-plumbers-in-action/differential-shellcheck/compare/v3...v4)

---
updated-dependencies:
- dependency-name: redhat-plumbers-in-action/differential-shellcheck
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit db6d69cbdaddda50bd3b23751c26e84eab7cfc83)

2 years agoftests: Add a test to validate cgx{get,set} systemd options (cgroup v2)
Kamalesh Babulal [Fri, 10 Feb 2023 21:54:22 +0000 (14:54 -0700)] 
ftests: Add a test to validate cgx{get,set} systemd options (cgroup v2)

Add a test case to validate cgx{get, set} tool's systemd options on
cgroup unified setup mode.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Feb 05 08:15:40
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                           Time (sec)
        ---------------------------------------------------------
        setup                                                0.00
        070-sudo-systemd_cgxget-cpu-settings-v2.py           3.00
        teardown                                             0.00
        ---------------------------------------------------------
        Total Run Time

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 418842dcae4285741f1a8ed22a41bfe03d58bdb7)

2 years agoftests: Add a test to validate cgx{get,set} systemd options (cgroup v1)
Kamalesh Babulal [Fri, 10 Feb 2023 21:54:10 +0000 (14:54 -0700)] 
ftests: Add a test to validate cgx{get,set} systemd options (cgroup v1)

Add a test case to validate cgx(get, set} tool's systemd options on
cgroup legacy/hybrid setup modes.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Feb 05 08:09:43
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                           Time (sec)
        ---------------------------------------------------------
        setup                                                0.00
        069-sudo-systemd_cgxget-cpu-settings-v1.py           2.74
        teardown                                             0.00
        ---------------------------------------------------------
        Total Run Time                                       2.74

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit c1adfed29ff3d475484ba57d4a910679d9ecc493)

2 years agoftests: Add a test to validate cgexec's systemd options (cgroup v2)
Kamalesh Babulal [Fri, 10 Feb 2023 21:53:58 +0000 (14:53 -0700)] 
ftests: Add a test to validate cgexec's systemd options (cgroup v2)

Add a test case to validate cgexec tool's systemd options on cgroup
unified setup mode.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Feb 05 07:57:18
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                              Time (sec)
        --------------------------------------------
        setup                                   0.00
        068-sudo-systemd_cgexec-v2.py           5.53
        teardown                                0.00
        --------------------------------------------
        Total Run Time                          5.53

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit b2cd7beb5b6b6bab43495cbb6b82a58fa5dee152)

2 years agoftests: Add a test to validate cgexec's systemd options (cgroup v1)
Kamalesh Babulal [Fri, 10 Feb 2023 21:53:48 +0000 (14:53 -0700)] 
ftests: Add a test to validate cgexec's systemd options (cgroup v1)

Add a test case to validate cgexec tool's systemd options on cgroup
legacy/hybrid setup modes.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Feb 05 07:48:48
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                              Time (sec)
        --------------------------------------------
        setup                                   0.00
        067-sudo-systemd_cgexec-v1.py           5.32
        teardown                                0.00
        --------------------------------------------
        Total Run Time                          5.32

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 4e3dc1b617881f0dcfc75e83a345779eca61e8c8)

2 years agoftests: Add a test to validate cgclassify's systemd options (cgroup v2)
Kamalesh Babulal [Fri, 10 Feb 2023 21:53:33 +0000 (14:53 -0700)] 
ftests: Add a test to validate cgclassify's systemd options (cgroup v2)

Add a test case to validate cgclassify tool's systemd options on cgroup
unified mode.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Feb 05 07:43:23
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                  Time (sec)
        ------------------------------------------------
        setup                                       0.00
        066-sudo-systemd_cgclassify-v2.py           7.57
        teardown                                    0.00
        ------------------------------------------------
        Total Run Time                              7.57

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 98c11c7ba4f7269627c523f3c81b386e795e72c3)