pygrub: parse xen module option in grub
PATCH 1/1 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.
tools/pygrub/src/GrubConf.py 2009-02-20 10:11:30.000000000 +0800 renamed from tools/pygrub/src/GrubConf.py 2009-02-20 09:59:40.000000000 +0800 +2 -2
@@ -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):
tools/pygrub/src/pygrub 2009-02-20 10:13:54.000000000 +0800 renamed from tools/pygrub/src/pygrub 2009-02-20 09:59:40.000000000 +0800 +1 -1
@@ -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
[email protected]
http://lists.xensource.com/xen-devel
Quoted 1 line · Wei Kong
Add function for GrubConf to parse xen module option in grub.
Why?
Quoted 1 line
Pygrub should pass args as domUloader did.
domUloader was never in the tree.
tools/pygrub/src/pygrub 2009-02-20 10:13:54.000000000 +0800 if __name__ == "__main__": · line 685
Quoted 2 lines
tools/pygrub/src/pygrub 2009-02-20 10:13:54.000000000 +0800 renamed from tools/pygrub/src/pygrub 2009-02-20 09:59:40.000000000 +0800 +1
-1- 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
2009/2/20 John Levon <[email protected]>
Quoted 5 lines · Wei Kong
Quoted 2 lines
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.
Quoted 10 lines
Quoted 1 line
Pygrub should pass args as domUloader did.
domUloader was never in the tree.
Review
Quoted 2 lines
(quoted diff) +1
-1- 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.
Quoted 6 lines
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
[email protected]
http://lists.xensource.com/xen-devel
Quoted 7 lines · Wei Kong
Quoted 4 lines
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 inrun_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
2009/2/20 John Levon <[email protected]>
Quoted 6 lines · Wei Kong
Quoted 5 lines
Quoted 5 lines
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.
Quoted 7 lines
Quoted 3 lines
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 inrun_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.
Quoted 1 line
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
[email protected]
http://lists.xensource.com/xen-devel
Quoted 1 line · Wei Kong
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