[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] pygrub: parse xen module option in grub


  • To: xen-devel@xxxxxxxxxxxxxxxxxxx
  • From: Wei Kong <weikong.cn@xxxxxxxxx>
  • Date: Fri, 20 Feb 2009 10:40:14 +0800
  • Delivery-date: Thu, 19 Feb 2009 18:41:21 -0800
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=KUq+Rb5bvcyuruzIicFYmgKCVFrWsXrSdwiaFQQGBKrpSSeMeI41Mdl6LpkdlOwUx7 65ay4K2PV6qGT5b/sIeVJaYCjf9aN6grCHSZp1IlNT60X0p0P1lUXZR8gPV+w0/rrurT mLvxZ5UKEIRNG6G6roZJiqUvUvML5XoUIs3Pk=
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

Add function for GrubConf to parse xen module option in grub.
Pygrub should pass args as domUloader did.

Signed-off-by: Wei Kong <weikong.cn@gmail.com>

diff -uNrp a/tools/pygrub/src/GrubConf.py b/tools/pygrub/src/GrubConf.py
--- a/tools/pygrub/src/GrubConf.py    2009-02-20 09:59:40.000000000 +0800
+++ b/tools/pygrub/src/GrubConf.py    2009-02-20 10:11:30.000000000 +0800
@@ -12,7 +12,7 @@
 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 #
 
-import os, sys
+import os, sys, re
 import logging
 
 def grub_split(s, maxsplit = -1):
@@ -91,7 +91,7 @@ class GrubImage(object):
                                    self.args, self.initrd))
 
     def reset(self, lines):
-        self._root = self._initrd = self._kernel = self._args = None
+        self._root = self._initrd = self._kernel = self._args = self._xen = None
         self.title = ""
         self.lines = []
         map(self.set_from_line, lines)
@@ -120,7 +120,22 @@ class GrubImage(object):
         return self._root
     root = property(get_root, set_root)
 
+    def set_module(self, val):
+        if not self._xen:
+            return
+        if (val.find('vmlinuz') != -1):
+            (kernel, args) = val.split(None, 1)
+            self._kernel = get_path(kernel)
+            self._args = args
+        if (val.find('initrd') != -1):
+            self._initrd = get_path(val)
+    module = property(None, set_module)
+
     def set_kernel(self, val):
+        xengz=re.compile(".*xen[\-.0-9]+gz$", re.UNICODE)
+        if xengz.match(val):
+            self._xen = True
+            return
         if val.find(" ") == -1:
             self._kernel = get_path(val)
             self._args = None
@@ -147,8 +162,9 @@ class GrubImage(object):
                  "rootnoverify": "root",
                  "kernel": "kernel",
                  "initrd": "initrd",
+                 "module": "module",
                  "chainloader": None,
-                 "module": None}
+               }
        
 
 class GrubConfigFile(object):
diff -uNrp a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
--- a/tools/pygrub/src/pygrub    2009-02-20 09:59:40.000000000 +0800
+++ b/tools/pygrub/src/pygrub    2009-02-20 10:13:54.000000000 +0800
@@ -682,7 +682,7 @@ if __name__ == "__main__":
     if chosencfg["args"]:
         zfsinfo = fsimage.getbootstring(fs)
         if zfsinfo is None:
-            sxp += "(args \"%s\")" % chosencfg["args"]
+            sxp += "(args \"%s %s\")" % (chosencfg["args"], incfg["args"])
         else:
             e = re.compile("zfs-bootfs=[\w\-\.\:@/]+" )
             (chosencfg["args"],count) = e.subn(zfsinfo, chosencfg["args"])

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.