]> git.ipfire.org Git - thirdparty/libcgroup.git/log
thirdparty/libcgroup.git
11 months agoftests/045: Fix quote warning
Kamalesh Babulal [Sun, 21 Jul 2024 10:35:36 +0000 (16:05 +0530)] 
ftests/045: Fix quote warning

Fix "Q000 Double quotes found but single quotes preferred" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoftests/054: Fix quote warnings
Kamalesh Babulal [Sat, 20 Jul 2024 10:34:38 +0000 (16:04 +0530)] 
ftests/054: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoftests/055: Fix quote warnings
Kamalesh Babulal [Fri, 19 Jul 2024 10:33:03 +0000 (16:03 +0530)] 
ftests/055: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoftests/056: Fix quote warnings
Kamalesh Babulal [Mon, 15 Jul 2024 10:30:35 +0000 (16:00 +0530)] 
ftests/056: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoftests/057: Fix quote warnings
Kamalesh Babulal [Sun, 14 Jul 2024 10:28:56 +0000 (15:58 +0530)] 
ftests/057: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoftests/058: Fix quote warnings
Kamalesh Babulal [Sat, 13 Jul 2024 10:27:20 +0000 (15:57 +0530)] 
ftests/058: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoftests/059: Fix quote warnings
Kamalesh Babulal [Fri, 12 Jul 2024 10:25:38 +0000 (15:55 +0530)] 
ftests/059: Fix quote warnings

Fix multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoftests/071: Fix quote warnings
Kamalesh Babulal [Thu, 11 Jul 2024 10:23:31 +0000 (15:53 +0530)] 
ftests/071: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoftests/078: Fix quote warning
Kamalesh Babulal [Wed, 10 Jul 2024 10:20:16 +0000 (15:50 +0530)] 
ftests/078: Fix quote warning

Fix "Q003 Change outer quotes to avoid escaping inner quotes" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoftests/079: Fix quote warning
Kamalesh Babulal [Tue, 9 Jul 2024 10:19:25 +0000 (15:49 +0530)] 
ftests/079: Fix quote warning

Fix "Q003 Change outer quotes to avoid escaping inner quotes" warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoftests/084: Fix quote warnings
Kamalesh Babulal [Fri, 28 Jun 2024 08:04:14 +0000 (13:34 +0530)] 
ftests/084: Fix quote warnings

Fix multiple "Q003 Change outer quotes to avoid escaping inner quotes"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoftests/076: Fix quote warning
Kamalesh Babulal [Mon, 24 Jun 2024 07:54:37 +0000 (13:24 +0530)] 
ftests/076: Fix quote warning

Fix "Q001 Single quote multiline found but double quotes preferred"
warning.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoftests/081: Fix quote warnings
Kamalesh Babulal [Sun, 23 Jun 2024 07:50:45 +0000 (13:20 +0530)] 
ftests/081: Fix quote warnings

Fix multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoftests/082: Fix quote warnings
Kamalesh Babulal [Sat, 22 Jun 2024 07:48:29 +0000 (13:18 +0530)] 
ftests/082: Fix quote warnings

Fix multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
11 months agoftests/088: Fix quote warnings
Kamalesh Babulal [Fri, 21 Jun 2024 07:41:55 +0000 (13:11 +0530)] 
ftests/088: Fix quote warnings

Fix multiple "Q000 Double quotes found but single quotes preferred"
warnings.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
12 months agotools/cgsnapshot: Fix ret value in load_list()
Kamalesh Babulal [Tue, 16 Jul 2024 07:13:32 +0000 (12:43 +0530)] 
tools/cgsnapshot: Fix ret value in load_list()

The CodeQL reported a warning:
"Incorrect return-value check for a 'scanf'-like function"

More information about the warning:
https://github.com/libcgroup/libcgroup/security/code-scanning/18

Fix the warning by adding an additional "EOF" check for the ret value
from sscanf() in the load_list().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
12 months agosrc/api: Fix ret value in cgroup_get_current_controller_path()
Kamalesh Babulal [Wed, 17 Jul 2024 07:30:48 +0000 (13:00 +0530)] 
src/api: Fix ret value in cgroup_get_current_controller_path()

The CodeQL reported a warning:
"Incorrect return-value check for a 'scanf'-like function"

More information about the warning:
https://github.com/libcgroup/libcgroup/security/code-scanning/16

Fix the warning by adding an additional "EOF" check for the ret value
from fscanf() in the cgroup_get_current_controller_path()

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
12 months agoftests/013: Refactor code to match outputs with same line
Kamalesh Babulal [Mon, 8 Jul 2024 11:16:49 +0000 (16:46 +0530)] 
ftests/013: Refactor code to match outputs with same line

Refactor the code to match controller(s) output, with expected
controller(s) output, where more than one items in the expected output
list matches number of lines. Without this patch, the output is matched
only against the first item matching the line count in the expected
output.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Jun 24 11:17:11
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                              Time (sec)
        --------------------------------------------
        setup                                   0.00
        013-cgget-multiple_g_flags.py           0.05
        teardown                                0.00
        --------------------------------------------
        Total Run Time                          0.05

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
12 months agoftests/010: Refactor code to match outputs with same line
Kamalesh Babulal [Sun, 7 Jul 2024 05:28:49 +0000 (10:58 +0530)] 
ftests/010: Refactor code to match outputs with same line

Refactor the code to match controller(s) output, with expected
controller(s) output, where more than one items in the expected output
list matches number of lines. Without this patch, the output is matched
only against the first item matching the line count in the expected
output.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Jun 23 10:58:49
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                          Time (sec)
        --------------------------------------------------------
        setup                                               0.00
        010-cgget-g_flag_controller_and_cgroup.py           0.03
        teardown                                            0.00
        --------------------------------------------------------
        Total Run Time                                      0.03

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
12 months agoftests/009: Refactor code to match outputs with same line
Kamalesh Babulal [Sat, 6 Jul 2024 10:35:02 +0000 (16:05 +0530)] 
ftests/009: Refactor code to match outputs with same line

Refactor the code to match controller(s) output, with expected
controller(s) output, where more than one items in the expected output
list matches number of lines. Without this patch, the output is matched
only against the first item matching the line count in the expected
output.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Jun 22 10:18:38
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        --------------------------------------------------
        setup                                         0.00
        009-cgget-g_flag_controller_only.py           0.04
        teardown                                      0.00
        --------------------------------------------------
        Total Run Time                                0.04

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
12 months agoftests/utils: Add helper to check if output matches
Kamalesh Babulal [Fri, 5 Jul 2024 09:58:01 +0000 (15:28 +0530)] 
ftests/utils: Add helper to check if output matches

Add a helper to check if the output from the controller(s), matches the
expected controller(s) output. It returns True/False and None in case
of matching output, a line that doesn't match in differing output.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
12 months agoftests: Add more smarts when creating a container
Tom Hromatka [Wed, 17 Jul 2024 19:06:49 +0000 (13:06 -0600)] 
ftests: Add more smarts when creating a container

If lxc returns 'Instance is busy running a "create" operation', the
container was successfully created but it's not yet fully running.  Call
this a success as future operations will succeed once the container has
fully started.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
12 months agoman: cgxset: document -R option
Kamalesh Babulal [Thu, 4 Jul 2024 02:17:30 +0000 (07:47 +0530)] 
man: cgxset: document -R option

Document -R option. It recursively sets variable settings passed with -r
option to cgroup_path and its descendant cgroups.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
12 months agoftests: add test to exercise cgxset recursive set option
Kamalesh Babulal [Wed, 3 Jul 2024 04:08:06 +0000 (09:38 +0530)] 
ftests: add test to exercise cgxset recursive set option

Add a test to recursive set settings of the controller(s) in a cgroup
and its descendants using cgxset '-R' flag.
-----------------------------------------------------------------
Test Results:
        Run Date:                          Jul 03 09:03:39
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                             Time (sec)
        -------------------------------------------
        setup                                  0.00
        090-cgxset-recursive_flag.py           0.15
        teardown                               0.00
        -------------------------------------------
        Total Run Time                         0.15

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
12 months agoftests/cgroup: Add recursive support for set()
Kamalesh Babulal [Tue, 2 Jul 2024 01:10:26 +0000 (06:40 +0530)] 
ftests/cgroup: Add recursive support for set()

Add support to recursively xset controller settings of a cgroup and its
descendants.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
12 months agotools/cgxset: add support for cgroup.subtree_control
Kamalesh Babulal [Mon, 1 Jul 2024 02:25:22 +0000 (07:55 +0530)] 
tools/cgxset: add support for cgroup.subtree_control

The cgroup.subtree_control settings are special, in comparison to other
controller settings. It can both enable and disable the controllers in
the single argument, depending on the argument the cgroup hierarchy walk
is either pre-order or post-order.

example:
--------
$ sudo cgget -n -v -r cgroup.subtree_control a
cpu memory pids
$ sudo cgget -n -v -r cgroup.subtree_control a/b
cpu memory pids
$ sudo cgget -n -v -r cgroup.subtree_control a/b/c

$
$ sudo cgxset -R -r cgroup.subtree_control="-pids +cpuset" a
$ sudo cgget -n -v -r cgroup.subtree_control a
cpuset cpu memory
$ sudo cgget -n -v -r cgroup.subtree_control a/b
cpuset cpu memory
$ sudo cgget -n -v -r cgroup.subtree_control a/b/c

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
12 months agotools/cgxset: add -R option to recursively set variables
Kamalesh Babulal [Sun, 30 Jun 2024 02:21:02 +0000 (07:51 +0530)] 
tools/cgxset: add -R option to recursively set variables

Add -R option to recursively set variable(s) passed to cgroups under
<cgroup_path>. This will help users to set a controller setting for
all the cgroups under a cgroup hierarchy, instead of passing the
cgroups multiple times on the command line.

example:
--------
./cgcreate -gcpu,memory:foo -gcpu:memory:foo/ch1 -gcpu,memory:foo/ch2
./cgget -r cpu.shares foo foo/ch1 foo/ch2
foo:
cpu.shares: 1024

foo/ch1:
cpu.shares: 1024

foo/ch2:
cpu.shares: 1024

Without the patch
------------------
./cgxset -2 -r cpu.weight=256 foo
./cgget -r cpu.shares foo
foo/ch1 foo/ch2
foo:
cpu.shares: 256

foo/ch1:
cpu.shares: 1024

foo/ch2:
cpu.shares: 1024

With the patch
--------------
./cgxset -R -2 -r cpu.weight=50 foo
./cgget -r cpu.shares foo foo/ch1 foo/ch2
foo:
cpu.shares: 512

foo/ch1:
cpu.shares: 512

foo/ch2:
cpu.shares: 512

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
12 months agotools/cgxset: add cgroup_set_cgroup_values() helper
Kamalesh Babulal [Sat, 29 Jun 2024 00:06:38 +0000 (05:36 +0530)] 
tools/cgxset: add cgroup_set_cgroup_values() helper

Move the cgroup controller value setting logic to a helper function,
cgroup_set_cgroup_values() and also introduce program_name variable, to
be used instead of argv[0], when printing the info()/err() messages.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agotools/tools-common.c: handle DT_UNKNOWN from readdir()
Vasil Kolev [Fri, 17 May 2024 10:58:38 +0000 (13:58 +0300)] 
tools/tools-common.c: handle DT_UNKNOWN from readdir()

It's possible that readdir() would return DT_UNKNOWN in d_type for some
filesystems (observed on RHEL 8 with XFS and documented in readdir(3)),
thus the need to do an explicit stat() for such cases.

Signed-off-by: Vasil Kolev <vasil@ludost.net>
Acked-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
13 months agoftests/utils: Fix flake8 warning
Kamalesh Babulal [Tue, 25 Jun 2024 10:06:51 +0000 (15:36 +0530)] 
ftests/utils: Fix flake8 warning

tests/ftests/utils.py:84:1: E302 expected 2 blank lines, found 1

Fixes: aa345bbe1d45 ("ftests/cgroup: Add function to return kernel version")
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/071: Introduce delay before killing cgroup
Kamalesh Babulal [Tue, 18 Jun 2024 06:56:28 +0000 (12:26 +0530)] 
ftests/071: Introduce delay before killing cgroup

Fix the following issue:
071-sudo-set_default_systemd_cgroup.py - cgroup_delete_cgroup failed: 50016

Some older version of Kernel/Python combination, requires few jiffies to
sync the cgroup.procs list of process. Fix it by introducing 0.5 second
delay, before removing the cgroup.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/013: Populate newer cpu controller output
Kamalesh Babulal [Thu, 13 Jun 2024 14:39:57 +0000 (20:09 +0530)] 
ftests/013: Populate newer cpu controller output

Populate the newer cpu controller output with pid controller list() by
adjusting the index.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/consts: Add cpu controller throttled_usec (v2)
Kamalesh Babulal [Wed, 12 Jun 2024 05:46:55 +0000 (11:16 +0530)] 
ftests/consts: Add cpu controller throttled_usec (v2)

Add cpu controller (v2) stat output throttled_usec, introduced by
677ea015f231 ("sched: add throttled time stat for throttled children")

-----------------------------------------------------------------
Test Results:
        Run Date:                          Jun 12 05:46:40
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        --------------------------------------------------
        setup                                         0.00
        009-cgget-g_flag_controller_only.py           0.09
        teardown                                      0.00
        --------------------------------------------------
        Total Run Time                                0.09

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
13 months agoftests/consts: Add cpu controller throttled_usec (v1)
Kamalesh Babulal [Tue, 11 Jun 2024 06:05:38 +0000 (11:35 +0530)] 
ftests/consts: Add cpu controller throttled_usec (v1)

Add cpu controller (v1) stat output throttled_usec, introduced by
677ea015f231 ("sched: add throttled time stat for throttled children")

-----------------------------------------------------------------
Test Results:
        Run Date:                          Jun 11 05:39:08
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        --------------------------------------------------
        setup                                         0.00
        009-cgget-g_flag_controller_only.py           0.07
        teardown                                      0.00
        --------------------------------------------------
        Total Run Time                                0.07

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
14 months agoftests/cgroup: Add support for favordynmods
Kamalesh Babulal [Sun, 9 Jun 2024 11:33:57 +0000 (17:03 +0530)] 
ftests/cgroup: Add support for favordynmods

Upstream Linux Kernel commit 81d3a5be05d3 ("cgroup: add
cgroup_favordynmods= command-line option") introduced
CONFIG_CGROUP_FAVOR_DYNMODS, that would append favordynmods to the mount
options on cgroup v1. This patch strips that option.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
14 months agoftests: Add minimum Python version
Kamalesh Babulal [Sat, 8 Jun 2024 07:28:05 +0000 (12:58 +0530)] 
ftests: Add minimum Python version

Add Python version >= 3.6, as minimum required for executing ftests.
It's required for multi-process/multi-threaded test cases to execute
without time outs.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
14 months agoftests/005: Append newer kernel expected output
Kamalesh Babulal [Thu, 6 Jun 2024 09:58:59 +0000 (15:28 +0530)] 
ftests/005: Append newer kernel expected output

Append newer kernels cpuset controller output to the list of expected
output(s).

-----------------------------------------------------------------
Test Results:
        Run Date:                          Jun 07 15:28:39
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        --------------------------------------------------
        setup                                         0.00
        005-cgsnapshot-basic_snapshot_v2.py           0.27
        teardown                                      0.00
        --------------------------------------------------
        Total Run Time                                0.27

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
14 months agoftests/013: Use the controller list from consts
Kamalesh Babulal [Tue, 4 Jun 2024 15:25:11 +0000 (20:55 +0530)] 
ftests/013: Use the controller list from consts

Use consts.EXPECTED_CPU_OUT_* lists, instead of local EXPECTED_OUT_*
lists. This removes maintaining of duplicate controller output lists.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Jun 04 15:25:17
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                              Time (sec)
        --------------------------------------------
        setup                                   0.00
        013-cgget-multiple_g_flags.py           0.06
        teardown                                0.00
        --------------------------------------------
        Total Run Time                          0.06

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
14 months agoftests/010: Use the controller list from consts
Kamalesh Babulal [Mon, 3 Jun 2024 15:21:53 +0000 (20:51 +0530)] 
ftests/010: Use the controller list from consts

Use consts.EXPECTED_CPU_OUT_* lists, instead of local EXPECTED_OUT_*
lists. This removes maintaining of duplicate controller output lists.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Jun 03 15:22:15
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                          Time (sec)
        --------------------------------------------------------
        setup                                               0.00
        010-cgget-g_flag_controller_and_cgroup.py           0.04
        teardown                                            0.00
        --------------------------------------------------------
        Total Run Time                                      0.04

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
14 months agoftests/009: Use the controller list from consts
Kamalesh Babulal [Sun, 2 Jun 2024 15:11:48 +0000 (20:41 +0530)] 
ftests/009: Use the controller list from consts

Use consts.EXPECTED_CPU_OUT_* lists, instead of local EXPECTED_OUT_*
lists. This removes maintaining of duplicate controller output lists.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Jun 02 15:20:50
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        --------------------------------------------------
        setup                                         0.00
        009-cgget-g_flag_controller_only.py           0.04
        teardown                                      0.00
        --------------------------------------------------
        Total Run Time                                0.04

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
14 months agoftests/consts: Add cpu,pid controllers output lists
Kamalesh Babulal [Sat, 1 Jun 2024 15:01:36 +0000 (20:31 +0530)] 
ftests/consts: Add cpu,pid controllers output lists

Add cpu and pid controllers expected output lists to consts. It helps
in maintaining the controller output(s) list as a single list, lowering
the maintenance overhead for every new Kernels and also removes the
duplication across the test cases.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
14 months agoftests/cgroup: Fix flake8 warning
Kamalesh Babulal [Thu, 30 May 2024 15:46:06 +0000 (21:16 +0530)] 
ftests/cgroup: Fix flake8 warning

Fix pythonlint (flake8) warning:
tests/ftests/cgroup.py:630:22: E275 missing whitespace after keyword

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
14 months agoftests/061: Fix the expected line in cpu controller
Kamalesh Babulal [Tue, 28 May 2024 09:50:35 +0000 (15:20 +0530)] 
ftests/061: Fix the expected line in cpu controller

Cgroup cpu controller output might be less than 10 lines in older
Kernel version <= 5.4, fix it by adjusting the expected outline count
after reading the current kernel's version.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
14 months agoftests/cgroup: Add function to return kernel version
Kamalesh Babulal [Sat, 25 May 2024 09:30:05 +0000 (15:00 +0530)] 
ftests/cgroup: Add function to return kernel version

Add function to return the Major, Minor and Patch level of the current
booted kernel.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Moved function from CgroupVersion class to utils.py

14 months agoftests/060: Add new systemd error message
Kamalesh Babulal [Sun, 26 May 2024 06:42:03 +0000 (12:12 +0530)] 
ftests/060: Add new systemd error message

systemd >= 252 has changed the error message on creating duplicate
transient units, upstream commit 1f83244641f1 ("manager: allow transient
units to have drop-ins"). Adopt the newer systemd error message to avoid
expected failure.

-----------------------------------------------------------------
Test Results:
        Run Date:                          May 26 07:03:01
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                   Time (sec)
        -------------------------------------------------
        setup                                        0.00
        060-sudo-cgconfigparser-systemd.py           3.62
        teardown                                     0.00
        -------------------------------------------------
        Total Run Time                               3.62

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
15 months agofix: cgroupv2_subtree_control_recursive(): test before writing
Adriaan Schmidt [Tue, 2 Apr 2024 12:55:46 +0000 (14:55 +0200)] 
fix: cgroupv2_subtree_control_recursive(): test before writing

cgroupv2_subtree_control_recursive() writes to subtree_control
files in the cgroup tree, starting at the root cgroup. As the
root cgroup is managed by SystemD, its control files belong to the
root user.
This new check ensures that we only attempt to write to subtree_control
if the desired controller is not already active (e.g., because we're
using SystemD Delegation mechanisms), thus better enabling cgroup
manipulations for non-root users.

Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
15 months agoftests/038: fix cpuset_exclusive oddity
Kamalesh Babulal [Fri, 12 Apr 2024 10:18:45 +0000 (15:48 +0530)] 
ftests/038: fix cpuset_exclusive oddity

With upstream commit 7476a636d3100 ("cgroup/cpuset: Show invalid
partition reason string"), doesn't return error but needs to be re-read
again. This oddity is seen in kernel >= 6.5, fix it by introducing some
checks for cpuset_exclusive oddity.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Apr 12 10:20:07
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                              Time (sec)
        --------------------------------------------
        setup                                   0.00
        038-cgxget-cpuset_settings.py          24.75
        teardown                                0.00
        --------------------------------------------
        Total Run Time                         24.75

Fixes: https://github.com/libcgroup/libcgroup/issues/423
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
15 months agoftests/013: add pids controller format
Kamalesh Babulal [Wed, 3 Apr 2024 10:13:27 +0000 (15:43 +0530)] 
ftests/013: add pids controller format

Starting Linux Kernel version 6.1, the pids controller added an new
interface file pids.peak. It was introduced by upstream commit
5251c6c436ed ("cgroup: add pids.peak interface for pids controller").
Append a new expected output with the interface 'pids.peak' to cgroup v1
and v2 valid output.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Apr 04 10:11:31
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                              Time (sec)
        --------------------------------------------
        setup                                   0.00
        013-cgget-multiple_g_flags.py           0.12
        teardown                                0.00
        --------------------------------------------
        Total Run Time                          0.12

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
15 months agoftests/013: add cpu controller format (v2)
Kamalesh Babulal [Mon, 1 Apr 2024 10:19:42 +0000 (15:49 +0530)] 
ftests/013: add cpu controller format (v2)

Starting Linux Kernel version 6.0, the cpu controller cpu.stat (v2)
additionally displays force_idle statistics. It was introduced by
upstream commit 1fcf54deb767 ("sched/core: add forced idle accounting
for cgroups"). Append a new expected output with the field
'core_sched.force_idle_usec' to cgroup v2 valid output.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Apr 03 15:49:31
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                              Time (sec)
        --------------------------------------------
        setup                                   0.00
        013-cgget-multiple_g_flags.py           0.12
        teardown                                0.00
        --------------------------------------------
        Total Run Time                          0.12

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
15 months agoftests/010: add cpu controller format (v2)
Kamalesh Babulal [Fri, 29 Mar 2024 07:18:59 +0000 (12:48 +0530)] 
ftests/010: add cpu controller format (v2)

Starting Linux Kernel version 6.0, the cpu controller cpu.stat (v2)
additionally displays force_idle statistics. It was introduced by
upstream commit 1fcf54deb767 ("sched/core: add forced idle accounting
for cgroups"). Append a new expected output with the field
'core_sched.force_idle_usec' to cgroup v2 valid output.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Apr 03 15:48:51
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                          Time (sec)
        --------------------------------------------------------
        setup                                               0.00
        010-cgget-g_flag_controller_and_cgroup.py           0.09
        teardown                                            0.00
        --------------------------------------------------------
        Total Run Time                                      0.09

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
15 months agoftests/009: add cpu controller format (v2)
Kamalesh Babulal [Thu, 28 Mar 2024 06:07:09 +0000 (11:37 +0530)] 
ftests/009: add cpu controller format (v2)

Starting Linux Kernel version 6.0, the cpu controller cpu.stat (v2)
additionally displays force_idle statistics. It was introduced by
upstream commit 1fcf54deb767 ("sched/core: add forced idle accounting
for cgroups"). Append a new expected output with the field
'core_sched.force_idle_usec' to cgroup v2 valid output.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Apr 03 15:36:32
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                    Time (sec)
        --------------------------------------------------
        setup                                         0.00
        009-cgget-g_flag_controller_only.py           0.10
        teardown                                      0.00
        --------------------------------------------------
        Total Run Time                                0.10

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
16 months agofeat: add cgroup_get_threads()
Adriaan Schmidt [Tue, 27 Feb 2024 12:37:17 +0000 (13:37 +0100)] 
feat: add cgroup_get_threads()

In the same way `cgroup_get_procs()` reads the cgroup.procs
file of a cgroup, the new function reads cgroup.threads, which
is useful to interact with threaded cgroups.

Signed-off-by: Adriaan Schmidt <adriaan.schmidt@siemens.com>
Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
16 months agoftests/092: add test to attach threads to cgroup (v1)
Kamalesh Babulal [Wed, 13 Mar 2024 10:04:25 +0000 (10:04 +0000)] 
ftests/092: add test to attach threads to cgroup (v1)

Add test to attach/move all thread of a tid to cgroup using
cgroup_attach_thread_tid() in cgroup v1.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Mar 13 09:52:58
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                     Time (sec)
        ---------------------------------------------------
        setup                                          0.00
        092-sudo-cgroup_attach_thread_tid.py           0.09
        teardown                                       0.00
        ---------------------------------------------------
        Total Run Time                                 0.09

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
16 months agosrc/python: add attach_threads option to attach()
Kamalesh Babulal [Mon, 11 Mar 2024 03:37:19 +0000 (09:07 +0530)] 
src/python: add attach_threads option to attach()

Add support to move all threads by writing a tid into cgroups
cgroup.procs for the cgroup v1 controller, when attach_threads option in
the attach() is set, by default its false.  When set, it calls
cgroup_attach_thread_tid().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
16 months agoapi: add new API cgroup_attach_thread_tid() (v1)
Kamalesh Babulal [Fri, 8 Mar 2024 01:59:54 +0000 (07:29 +0530)] 
api: add new API cgroup_attach_thread_tid() (v1)

Add a new API cgroup_attach_thread_tid(), that will allow the users to
move all threads sharing the same tid (thread group leader).

Example:
---------
 #include <libcgroup.h>
 #include <stdio.h>
 #include <stdlib.h>

 #define CGRP_NAME "cgrp_foo"

 int main(int argc, char **argv)
 {
         struct cgroup_controller *cgc = NULL;
         struct cgroup *cgroup = NULL;
         int ret = 0;

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

         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, "cpu");
         if (!cgc) {
                 fprintf(stderr, "Failed to add controller cpu cgroup %s\n", CGRP_NAME);
                 exit(1);
         }

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

         ret = cgroup_attach_thread_tid(cgroup, atoi(argv[1]));
         if (ret)
                 fprintf(stderr, "failed to write threads tid %d\n", atoi(argv[1]));

         cgroup_free(&cgroup);

         exit(0);
 }

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
16 months agoapi: add helper to write into cgroup.procs (v1)
Kamalesh Babulal [Thu, 7 Mar 2024 01:58:01 +0000 (07:28 +0530)] 
api: add helper to write into cgroup.procs (v1)

Add helper cgroup_v1_build_cgroup_procs_path(), that constructs the path
to write tid into cgroup.procs, that will allow to move all of the tasks
sharing the same pid (thread leader). This helper, will be called by
cgroup_attach_task_tid() based on the move_threads function argument.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
16 months agoapi: add helper to move threads into cgroup (v1)
Kamalesh Babulal [Wed, 6 Mar 2024 01:55:17 +0000 (07:25 +0530)] 
api: add helper to move threads into cgroup (v1)

Introduce a new helper cgroup_attach_task_tid(), which will be used to
move threads into a cgroup for legacy/hybrid controllers running setup
in cgroup v1 mode. The core of the helper is craved out of
cgroup_attach_task_pid(), now both cgroup_attach_task_pid() and
cgroup_attach_task() calls cgroup_attach_task_tid() in turn.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
18 months agoman: update cgconfig.conf with systemd settings
Kamalesh Babulal [Mon, 1 Jan 2024 09:55:21 +0000 (15:25 +0530)] 
man: update cgconfig.conf with systemd settings

Update the cgconfig.conf for available systemd settings, along with an
example.

Fixes: https://github.com/libcgroup/libcgroup/issues/418
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Minor grammatical changes

18 months agoftests/081: add support for cgroup hybrid mode
Kamalesh Babulal [Wed, 1 Nov 2023 10:43:33 +0000 (16:13 +0530)] 
ftests/081: add support for cgroup hybrid mode

Add support for cgroup hybrid mode with controllers in cgroup v2.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Nov 01 10:40:32
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                                             Time (sec)
        -----------------------------------------------------------
        setup                                                  0.00
        081-pybindings-cgrp_get_curr_ctrl_path-v1.py           2.09
        teardown                                               0.00
        -----------------------------------------------------------
        Total Run Time                                         2.09

Suggested-by: Tom Hromatka <tom.hromatka@oracle.com>
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
18 months agoftests/089: enable controller for hybrid parent cgroup
Kamalesh Babulal [Wed, 1 Nov 2023 07:20:46 +0000 (12:50 +0530)] 
ftests/089: enable controller for hybrid parent cgroup

Enable the cpuset controller for the hybrid parent cgroup, in case of
the cgroup hybrid setup mode with controller enabled.

-----------------------------------------------------------------
Test Results:
        Run Date:                          Nov 01 12:50:20
        Passed:                                  1 test(s)
        Skipped:                                 0 test(s)
        Failed:                                  0 test(s)
-----------------------------------------------------------------
Timing Results:
        Test                            Time (sec)
        ------------------------------------------
        setup                                 0.00
        089-cgset-recursive_flag.py           0.23
        teardown                              0.00
        ------------------------------------------
        Total Run Time                        0.23

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
19 months agoRFE: Bump actions/upload-artifact from 3 to 4
dependabot[bot] [Mon, 18 Dec 2023 22:51:48 +0000 (22:51 +0000)] 
RFE: Bump actions/upload-artifact from 3 to 4

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  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>
19 months agoRFE: Bump github/codeql-action from 2 to 3
dependabot[bot] [Mon, 18 Dec 2023 22:51:45 +0000 (22:51 +0000)] 
RFE: Bump github/codeql-action from 2 to 3

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: github/codeql-action
  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>
19 months agoRFE: Bump actions/setup-python from 4 to 5
dependabot[bot] [Mon, 11 Dec 2023 22:46:52 +0000 (22:46 +0000)] 
RFE: Bump actions/setup-python from 4 to 5

Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-python
  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>
20 months agoapi: export cgroup_is_systemd_enabled()
Kamalesh Babulal [Wed, 6 Dec 2023 15:43:03 +0000 (15:43 +0000)] 
api: export cgroup_is_systemd_enabled()

export cgroup_is_systemd_enabled(), the function will helpful developers
to check if the systemd support is enabled.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/088: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:44:51 +0000 (09:44 +0000)] 
ftests/088: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/086: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:43:48 +0000 (09:43 +0000)] 
ftests/086: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/085: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:42:55 +0000 (09:42 +0000)] 
ftests/085: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/084: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:41:44 +0000 (09:41 +0000)] 
ftests/084: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/079: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:40:30 +0000 (09:40 +0000)] 
ftests/079: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/078: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:38:40 +0000 (09:38 +0000)] 
ftests/078: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/071: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:37:16 +0000 (09:37 +0000)] 
ftests/071: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/070: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:35:26 +0000 (09:35 +0000)] 
ftests/070: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/069: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:34:24 +0000 (09:34 +0000)] 
ftests/069: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/068: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:33:21 +0000 (09:33 +0000)] 
ftests/068: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/067: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:32:28 +0000 (09:32 +0000)] 
ftests/067: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/066: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:31:33 +0000 (09:31 +0000)] 
ftests/066: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/065: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:30:36 +0000 (09:30 +0000)] 
ftests/065: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/064: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:28:14 +0000 (09:28 +0000)] 
ftests/064: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/063: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:27:18 +0000 (09:27 +0000)] 
ftests/063: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/062: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:25:55 +0000 (09:25 +0000)] 
ftests/062: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/061: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:23:05 +0000 (09:23 +0000)] 
ftests/061: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/060: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:22:11 +0000 (09:22 +0000)] 
ftests/060: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/059: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:20:34 +0000 (09:20 +0000)] 
ftests/059: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/058: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:19:10 +0000 (09:19 +0000)] 
ftests/058: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/050: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:18:01 +0000 (09:18 +0000)] 
ftests/050: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/049: skip test on non-systemd configuration
Kamalesh Babulal [Wed, 29 Nov 2023 09:08:14 +0000 (09:08 +0000)] 
ftests/049: skip test on non-systemd configuration

Skip running the testcase, when compiled with --enable-systemd=no,
using Systemd.is_systemd_enabled().

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoftests/systemd: add method to check if systemd support
Tom Hromatka [Wed, 6 Dec 2023 15:37:44 +0000 (15:37 +0000)] 
ftests/systemd: add method to check if systemd support

Add a method to check if libcgroup is compiled with --enable-systemd
support. The newly introduced is_systemd_enabled(), calls systemd C
function is_systemd_enabled(), that return true if configured with
--enable-systemd, false otherwise.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agopython: Introduce is_systemd_enabled()
Tom Hromatka [Thu, 7 Dec 2023 04:20:13 +0000 (04:20 +0000)] 
python: Introduce is_systemd_enabled()

Add python interface for systemd C function cgroup_is_systemd_enabled(),
that return true if the --enable-systemd was set or false.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agopython: compile systemd support by default
Tom Hromatka [Thu, 7 Dec 2023 04:19:07 +0000 (04:19 +0000)] 
python: compile systemd support by default

Compile systemd support file by default, there are two versions of
systemd functions available now, those get called based on the
--enable-systemd configuration, hence remove the #ifdef WITH_SYSTEMD
guards from bindings.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agoinclude/Makefile: install systemd.h by default
Kamalesh Babulal [Mon, 27 Nov 2023 14:37:33 +0000 (20:07 +0530)] 
include/Makefile: install systemd.h by default

Install systemd.h header file by default, as we have stub and defined
versions of the systemd functions for both non-systemd and systemd
enabled configurations.  This will help packagers to ship package
without systemd support (--enable-systemd=no).

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agosrc/Makefile: compile systemd support by default
Kamalesh Babulal [Sat, 25 Nov 2023 14:32:34 +0000 (20:02 +0530)] 
src/Makefile: compile systemd support by default

Compile systemd support file by default, now we have stub and defined
versions of the systemd functions for both non-systemd and systemd
enabled configurations.  Pass linker flag WITH_SYSTEMD only when
--enable-systemd is set, that will call the defined function, otherwise
call the stub functions.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agosystemd: add cgroup_is_systemd_enabled() helper
Tom Hromatka [Wed, 6 Dec 2023 15:07:15 +0000 (15:07 +0000)] 
systemd: add cgroup_is_systemd_enabled() helper

Add a helper function cgroup_is_systemd_enabled(), that would return
true, when compiled with --enabled-systemd option or false when
disabled.

Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agosystemd: add function stubs for non-systemd
Kamalesh Babulal [Mon, 27 Nov 2023 14:30:14 +0000 (20:00 +0530)] 
systemd: add function stubs for non-systemd

Add systemd function stubs for --enable-systemd=no configuration.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agotools/lscgroup: guard systemd default delegate slice
Kamalesh Babulal [Fri, 24 Nov 2023 08:49:51 +0000 (14:19 +0530)] 
tools/lscgroup: guard systemd default delegate slice

Guard setting default systemd delegate slice with WITH_SYSTEMD, to limit
the systemd delegation only to --enable-systemd=yes only.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agotools/cgxset: guard systemd default delegate slice
Kamalesh Babulal [Thu, 23 Nov 2023 08:48:50 +0000 (14:18 +0530)] 
tools/cgxset: guard systemd default delegate slice

Guard setting default systemd delegate slice with WITH_SYSTEMD, to limit
the systemd delegation only to --enable-systemd=yes only.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agotools/cgxget: guard systemd default delegate slice
Kamalesh Babulal [Wed, 22 Nov 2023 08:47:45 +0000 (14:17 +0530)] 
tools/cgxget: guard systemd default delegate slice

Guard setting default systemd delegate slice with WITH_SYSTEMD, to limit
the systemd delegation only to --enable-systemd=yes only.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agotools/cgset: guard systemd default delegate slice
Kamalesh Babulal [Tue, 21 Nov 2023 08:46:47 +0000 (14:16 +0530)] 
tools/cgset: guard systemd default delegate slice

Guard setting default systemd delegate slice with WITH_SYSTEMD, to limit
the systemd delegation only to --enable-systemd=yes only.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agotools/cgget: guard systemd default delegate slice
Kamalesh Babulal [Mon, 20 Nov 2023 08:45:54 +0000 (14:15 +0530)] 
tools/cgget: guard systemd default delegate slice

Guard setting default systemd delegate slice with WITH_SYSTEMD, to limit
the systemd delegation only to --enable-systemd=yes only.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agotools/cgexec: guard systemd default delegate slice
Kamalesh Babulal [Sun, 19 Nov 2023 08:44:57 +0000 (14:14 +0530)] 
tools/cgexec: guard systemd default delegate slice

Guard setting default systemd delegate slice with WITH_SYSTEMD, to limit
the systemd delegation only to --enable-systemd=yes only.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
20 months agotools/cgdelete: guard systemd default delegate slice
Kamalesh Babulal [Sat, 18 Nov 2023 08:43:46 +0000 (14:13 +0530)] 
tools/cgdelete: guard systemd default delegate slice

Guard setting default systemd delegate slice with WITH_SYSTEMD, to limit
the systemd delegation only to --enable-systemd=yes only.

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