Wei Kong
2009-Feb-20 02:40 UTC
[Xen-devel] [PATCH] pygrub: parse xen module option in grub
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@lists.xensource.com http://lists.xensource.com/xen-devel
John Levon
2009-Feb-20 02:55 UTC
Re: [Xen-devel] [PATCH] pygrub: parse xen module option in grub
On Fri, Feb 20, 2009 at 10:40:14AM +0800, Wei Kong wrote:> Add function for GrubConf to parse xen module option in grub.Why?> Pygrub should pass args as domUloader did.domUloader was never in the tree.> - sxp += "(args \"%s\")" % chosencfg["args"] > + sxp += "(args \"%s %s\")" % (chosencfg["args"], incfg["args"])Are you trying to let the user add arguments to the ones specified in grub? Why? The patch is wrong anyway, you can''t just add on the incoming args for Solaris at least. At the very least you need to add the args only when run_grub() is called. john _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Wei Kong
2009-Feb-20 03:20 UTC
Re: [Xen-devel] [PATCH] pygrub: parse xen module option in grub
2009/2/20 John Levon <levon@movementarian.org>> On Fri, Feb 20, 2009 at 10:40:14AM +0800, Wei Kong wrote: > > > Add function for GrubConf to parse xen module option in grub. > > Why?thanks, John Maybe that "guest" doesn''t have right kernel pattern as xen module. o, the "guest" means an os on a phy partition which never be a guest before. Due to sometimes I have many os on different partitions, but I haven''t any guest and I don''t want install one, so just let xen boot any exist os as guest.> > Pygrub should pass args as domUloader did. > > domUloader was never in the tree. > > > - sxp += "(args \"%s\")" % chosencfg["args"] > > + sxp += "(args \"%s %s\")" % (chosencfg["args"], > incfg["args"]) > > Are you trying to let the user add arguments to the ones specified in > grub? Why?Yes, this args is the one user want to pass to guest kernel, domUloader real did this, and sorry for I don''t know domUloader isn''t in this tree.> > The patch is wrong anyway, you can''t just add on the incoming args for > Solaris at least. At the very least you need to add the args only when > run_grub() is called. > > No, I didn''t add any args for solaris.Because I don''t want to add args for Solaris, so I add args here, not in run_grub(). --thanks a lot Kong _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
John Levon
2009-Feb-20 03:24 UTC
Re: [Xen-devel] [PATCH] pygrub: parse xen module option in grub
On Fri, Feb 20, 2009 at 11:20:38AM +0800, Wei Kong wrote:> > The patch is wrong anyway, you can''t just add on the incoming args for > > Solaris at least. At the very least you need to add the args only when > > run_grub() is called. > > > No, I didn''t add any args for solaris. > Because I don''t want to add args for Solaris, so I add args here, not in > run_grub().Please read the code more closely: again, you cannot just pass inargs out again, you must only do so if run_grub() is called. Presuming it even makes sense - why can''t the user edit the grub entry? john _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Wei Kong
2009-Feb-20 04:15 UTC
Re: [Xen-devel] [PATCH] pygrub: parse xen module option in grub
2009/2/20 John Levon <levon@movementarian.org>> On Fri, Feb 20, 2009 at 11:20:38AM +0800, Wei Kong wrote: > > > > The patch is wrong anyway, you can''t just add on the incoming args for > > > Solaris at least. At the very least you need to add the args only when > > > run_grub() is called. > > > > > No, I didn''t add any args for solaris. > > Because I don''t want to add args for Solaris, so I add args here, not in > > run_grub(). > > Please read the code more closely: again, you cannot just pass inargs > out again, you must only do so if run_grub() is called. Presuming it > even makes sense -thanks, john Sorry for I not think about Solaris carefully. Current run_grub() doesn''t get any kernel args from user. We could add another argument for this function and return args back, whatever, it''s hard for run_grub() to pass this args to GRUB() entry to let the user see it again.> why can''t the user edit the grub entry?Yes, but if you could write it in configuration file, why do it by hand. Do you like the below modify? --- xen-unstable.hg.changeset_19232/tools/pygrub/src/pygrub 2009-02-20 12:07:34.000000000 +0800 +++ xen-unstable.hg/tools/pygrub/src/pygrub 2009-02-20 12:07:40.000000000 +0800 @@ -501,7 +501,7 @@ def get_entry_idx(cf, entry): return None -def run_grub(file, entry, fs): +def run_grub(file, entry, fs, arg): global g global sel @@ -534,7 +534,7 @@ def run_grub(file, entry, fs): if img.initrd: grubcfg["ramdisk"] = img.initrd[1] if img.args: - grubcfg["args"] = img.args + grubcfg["args"] = img.args + " " + arg return grubcfg @@ -659,7 +659,7 @@ if __name__ == "__main__": chosencfg = sniff_solaris(fs, incfg) if not chosencfg["kernel"]: - chosencfg = run_grub(file, entry, fs) + chosencfg = run_grub(file, entry, fs, incfg["args"]) data = fs.open_file(chosencfg["kernel"]).read() (tfd, bootcfg["kernel"]) = tempfile.mkstemp(prefix="boot_kernel.", _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
John Levon
2009-Feb-20 04:21 UTC
Re: [Xen-devel] [PATCH] pygrub: parse xen module option in grub
On Fri, Feb 20, 2009 at 12:15:30PM +0800, Wei Kong wrote:> Do you like the below modify?It''s probably nicer to show the incoming arguments in the grub emulation certainly, although I''m still unclear as to why you''d want this. Your patch does fix the Solaris case, so I''m not too fussed either way. regards, john _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel