]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
ftests/cgroup: Add recursive support for set()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Thu, 12 Oct 2023 09:10:20 +0000 (14:40 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 1 Nov 2023 14:59:13 +0000 (08:59 -0600)
Add support to recursively set 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>
tests/ftests/cgroup.py

index 57fb2a70d31f381798db44f4b8c5da8695039ffc..cbee1f9654b71e730bc5f64702f2e000659f2595 100644 (file)
@@ -246,7 +246,7 @@ class Cgroup(object):
 
     @staticmethod
     def __set(config, cmd, cgname=None, setting=None, value=None,
-              copy_from=None, cghelp=False, ignore_systemd=False):
+              copy_from=None, cghelp=False, ignore_systemd=False, recursive=False):
         if setting is not None or value is not None:
             if isinstance(setting, str) and (isinstance(value, str) or isinstance(value, int)):
                 cmd.append('-r')
@@ -286,6 +286,9 @@ class Cgroup(object):
         if cghelp:
             cmd.append('-h')
 
+        if recursive:
+            cmd.append('-R')
+
         if config.args.container:
             return config.container.run(cmd)
         else:
@@ -293,7 +296,7 @@ class Cgroup(object):
 
     @staticmethod
     def set(config, cgname=None, setting=None, value=None, copy_from=None,
-            cghelp=False, ignore_systemd=False):
+            cghelp=False, ignore_systemd=False, recursive=False):
         """cgset equivalent method
 
         The following variants of cgset are being tested by the
@@ -315,7 +318,7 @@ class Cgroup(object):
         cmd.append(Cgroup.build_cmd_path('cgset'))
 
         return Cgroup.__set(config, cmd, cgname, setting, value, copy_from,
-                            cghelp, ignore_systemd)
+                            cghelp, ignore_systemd, recursive)
 
     @staticmethod
     def xset(config, cgname=None, setting=None, value=None, copy_from=None,