diff --git a/devlib/bin/scripts/shutils.in b/devlib/bin/scripts/shutils.in index 640d65d..fa4ad93 100755 --- a/devlib/bin/scripts/shutils.in +++ b/devlib/bin/scripts/shutils.in @@ -102,7 +102,7 @@ cgroups_get_attributes() { cgroups_run_into() { # Control groups mount point - CGMOUNT=${CGMOUNT:-/sys/fs/cgroup/devlib_*} + CGMOUNT=${CGMOUNT:-/sys/fs/cgroup} # The control group we want to run into CGP=${1} shift 1 diff --git a/devlib/module/cgroups.py b/devlib/module/cgroups.py index dd9543e..001867b 100644 --- a/devlib/module/cgroups.py +++ b/devlib/module/cgroups.py @@ -314,6 +314,10 @@ class CgroupsModule(Module): self.logger = logging.getLogger('CGroups') + # Set Devlib's CGroups mount point + self.cgroup_root = target.path.join( + target.working_directory, 'cgroups') + # Load list of available controllers controllers = [] subsys = self.list_subsystems() @@ -329,9 +333,7 @@ class CgroupsModule(Module): if not controller.probe(self.target): continue try: - cgroup_root = target.path.join(target.working_directory, - 'cgroups') - controller.mount(self.target, cgroup_root) + controller.mount(self.target, self.cgroup_root) except TargetError: message = 'cgroups {} controller is not supported by the target' raise TargetError(message.format(controller.kind)) @@ -359,12 +361,18 @@ class CgroupsModule(Module): return None return self.controllers[kind] + def run_into_cmd(self, cgroup, cmdline): + return 'CGMOUNT={} {} cgroups_run_into {} {}'\ + .format(self.cgroup_root, self.target.shutils, + cgroup, cmdline) + def run_into(self, cgroup, cmdline): """ Run the specified command into the specified CGroup """ return self.target._execute_util( - 'cgroups_run_into {} {}'.format(cgroup, cmdline), + 'CGMOUNT={} cgroups_run_into {} {}'\ + .format(self.cgroup_root, cgroup, cmdline), as_root=True)