Skip to contentSkip to conversation

Provide explicit initialization function for booloader class

PATCH New Stefan Berger 1 participant 1 message Apr 29, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Provide explicit initialization function for booloader class

Had forgotten to attach the patch. Here it is.

This patch refactors the initialization code for the bootloader class and puts it into an explicit initialization function that is called from another class.

xen-unstable.hg/tools/python/xen/util/bootloader.py +14 -11
Index: root/xen-unstable.hg/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
xen-unstable.hg/tools/python/xen/xend/XendXSPolicyAdmin.py +1 -0
Index: root/xen-unstable.hg/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()

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel