1
0
mirror of https://github.com/ARM-software/devlib.git synced 2024-10-06 19:00:50 +01:00

Merge pull request #84 from bjackman/cgroups-fix-run-into

Some fixes for running commands into cgroups
This commit is contained in:
setrofim 2017-01-12 17:04:58 +00:00 committed by GitHub
commit 76c4a725ed

View File

@ -373,6 +373,13 @@ class CgroupsModule(Module):
return self.controllers[kind] return self.controllers[kind]
def run_into_cmd(self, cgroup, cmdline): def run_into_cmd(self, cgroup, cmdline):
"""
Get the command to run a command into a given cgroup
:param cmdline: Commdand to be run into cgroup
:param cgroup: Name of cgroup to run command into
:returns: A command to run `cmdline` into `cgroup`
"""
return 'CGMOUNT={} {} cgroups_run_into {} {}'\ return 'CGMOUNT={} {} cgroups_run_into {} {}'\
.format(self.cgroup_root, self.target.shutils, .format(self.cgroup_root, self.target.shutils,
cgroup, cmdline) cgroup, cmdline)
@ -380,12 +387,16 @@ class CgroupsModule(Module):
def run_into(self, cgroup, cmdline): def run_into(self, cgroup, cmdline):
""" """
Run the specified command into the specified CGroup Run the specified command into the specified CGroup
"""
return self.target._execute_util(
'CGMOUNT={} cgroups_run_into {} {}'\
.format(self.cgroup_root, cgroup, cmdline),
as_root=True)
:param cmdline: Command to be run into cgroup
:param cgroup: Name of cgroup to run command into
:returns: Output of command.
"""
cmd = self.run_into_cmd(cgroup, cmdline)
raw_output = self.target.execute(cmd)
# First line of output comes from shutils; strip it out.
return raw_output.split('\n', 1)[1]
def cgroups_tasks_move(self, srcg, dstg, exclude=''): def cgroups_tasks_move(self, srcg, dstg, exclude=''):
""" """