From c89f712923fbd4d09375596d28f5f8025dfcd1d8 Mon Sep 17 00:00:00 2001 From: Brendan Jackman Date: Fri, 25 Nov 2016 11:56:42 +0000 Subject: [PATCH] cgroups: Raise RuntimeError in freeze if no freezer controller Without this patch, this will result in an error due to trying to call `.cgroup` on None. Making this a RuntimeError instaed means that a) you get a more useful error message and b) you can catch the exception without blanket `except Exception as e`. --- devlib/module/cgroups.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/devlib/module/cgroups.py b/devlib/module/cgroups.py index e4b387c..dd514d9 100644 --- a/devlib/module/cgroups.py +++ b/devlib/module/cgroups.py @@ -448,6 +448,8 @@ class CgroupsModule(Module): # Create Freezer CGroup freezer = self.controller('freezer') + if freezer is None: + raise RuntimeError('freezer cgroup controller not present') freezer_cg = freezer.cgroup('/DEVLIB_FREEZER') thawed_cg = freezer.cgroup('/')