From 103f792736dc461793a020647b196db824e58e0e Mon Sep 17 00:00:00 2001 From: Patrick Bellasi Date: Tue, 29 Nov 2016 10:13:01 +0000 Subject: [PATCH] cgroups: use subsystems namedtuple in the controllers mounting loop This is just a simple re-factoring patch in preparation of the following one. Since we have a list of CGroups subsystems, which includes the hierarchy ID for each entry, let's use directly these namedtuples in the mouting loop. The following patch will make use of the hierarchy ID to properly mount each controller. Signed-off-by: Patrick Bellasi --- devlib/module/cgroups.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/devlib/module/cgroups.py b/devlib/module/cgroups.py index 001867b..111e7b5 100644 --- a/devlib/module/cgroups.py +++ b/devlib/module/cgroups.py @@ -318,17 +318,17 @@ class CgroupsModule(Module): self.cgroup_root = target.path.join( target.working_directory, 'cgroups') - # Load list of available controllers - controllers = [] + # Get the list of the available controllers subsys = self.list_subsystems() - for (n, h, c, e) in subsys: - controllers.append(n) - self.logger.debug('Available controllers: %s', controllers) + if len(subsys) == 0: + self.logger.warning('No CGroups controller available') + return # Initialize controllers + self.logger.info('Available controllers:') self.controllers = {} - for idx in controllers: - controller = Controller(idx) + for ss in subsys: + controller = Controller(ss.name) self.logger.debug('Init %s controller...', controller.kind) if not controller.probe(self.target): continue @@ -338,7 +338,7 @@ class CgroupsModule(Module): message = 'cgroups {} controller is not supported by the target' raise TargetError(message.format(controller.kind)) self.logger.debug('Controller %s enabled', controller.kind) - self.controllers[idx] = controller + self.controllers[ss.name] = controller def list_subsystems(self): subsystems = []