From: Keir Fraser Date: Thu, 1 May 2008 08:55:45 +0000 (+0100) Subject: [Xend/ACM] Provide explicit initialization function for bootloader class X-Git-Tag: 3.3.0-rc1~238^2~58 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=a2f23ae851a744beb582ab4f11d654516fde1e78;p=xen.git [Xend/ACM] Provide explicit initialization function for bootloader class This patch refactors the initialization code for the bootloader class and puts it into an explicit initialization function that is called from another class. Signed-off-by: Stefan Berger --- diff --git a/tools/python/xen/util/bootloader.py b/tools/python/xen/util/bootloader.py index 58c904f070..d3b2de7fcc 100644 --- a/tools/python/xen/util/bootloader.py +++ b/tools/python/xen/util/bootloader.py @@ -26,8 +26,6 @@ from xen.xend.XendLogging import log from xen.util import mkdir import xen.util.xsm.xsm as security -__bootloader = None - # # Functions for modifying entries in the bootloader, i.e. adding # a module to boot the system with a policy. @@ -513,8 +511,11 @@ class LatePolicyLoader(Bootloader): Bootloader.__init__(self) def probe(self): - _dir=os.path.dirname(self.FILENAME) - mkdir.parents(_dir, stat.S_IRWXU) + try: + _dir=os.path.dirname(self.FILENAME) + mkdir.parents(_dir, stat.S_IRWXU) + except: + return False return True def get_default_title(self): @@ -614,10 +615,12 @@ class LatePolicyLoader(Bootloader): __bootloader = Bootloader() -grub = Grub() -if grub.probe() == True: - __bootloader = grub -else: - late = LatePolicyLoader() - if late.probe() == True: - __bootloader = late +def init(): + global __bootloader + grub = Grub() + if grub.probe() == True: + __bootloader = grub + else: + late = LatePolicyLoader() + if late.probe() == True: + __bootloader = late diff --git a/tools/python/xen/xend/XendXSPolicyAdmin.py b/tools/python/xen/xend/XendXSPolicyAdmin.py index 633c62b228..e6b536e624 100644 --- a/tools/python/xen/xend/XendXSPolicyAdmin.py +++ b/tools/python/xen/xend/XendXSPolicyAdmin.py @@ -46,6 +46,7 @@ class XSPolicyAdmin: self.maxpolicies = maxpolicies self.policies = {} self.xsobjs = {} + bootloader.init() act_pol_name = self.get_hv_loaded_policy_name() initialize()