WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] pygrub: parse xen module option in grub
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
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=Wv87ijoWyH4zrTrMjlnfwV+KKsFp6GAny0k2VSo9w2k=; b=UkF5LHZeObeR1+6q8mgukNxZz4w9yKFhc/qyJLCWvDirKOJagDCAbse7/PdZgyYGSA Xu5GHlSKL9AxPFwLZCHEYk6AsQG07N/tMOtWOCkTV1et18d+UrtY2JiqUyNNOxYWnr7f xRRn4fUFPrLZ+p39+etVBt5Kwhng4msV3zxHg=
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=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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