1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

cgroups: use shutils for move_tasks

Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
This commit is contained in:
Patrick Bellasi 2016-08-26 16:27:23 +01:00
parent d8ae3aba1a
commit 3cab786d03

View File

@ -117,19 +117,16 @@ class Controller(object):
cgroups.append(cg) cgroups.append(cg)
return cgroups return cgroups
def move_tasks(self, source, dest): def move_tasks(self, source, dest, exclude=[]):
try: try:
srcg = self._cgroups[source] srcg = self._cgroups[source]
dstg = self._cgroups[dest] dstg = self._cgroups[dest]
command = 'for task in $(cat {}); do echo $task>{}; done'
self.target.execute(command.format(srcg.tasks_file, dstg.tasks_file),
# this will always fail as some of the tasks
# are kthreads that cannot be migrated, but we
# don't care about those, so don't check exit
# code.
check_exit_code=False, as_root=True)
except KeyError as e: except KeyError as e:
raise ValueError('Unkown group: {}'.format(e)) raise ValueError('Unkown group: {}'.format(e))
output = self.target._execute_util(
'cgroups_tasks_move {} {} \'{}\''.format(
srcg.directory, dstg.directory, exclude),
as_root=True)
def move_all_tasks_to(self, dest): def move_all_tasks_to(self, dest):
for cgroup in self._cgroups: for cgroup in self._cgroups: