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

Re: [Xen-devel] [PATCH] pygrub: fix extlinux parsing



On Mon, 2012-01-02 at 10:49 +0000, Roger Pau Monne wrote:
> # HG changeset patch
> # User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>
> # Date 1325501151 -3600
> # Node ID bd59a07ed41187bcafc4dd5214f0744c66ef2069
> # Parent  3e02aa9670b3265e36bdddbd4760415cd87d047b
> pygrub: fix extlinux parsing
> 
> pygrub was unable to parse extlinux config files correctly, exactly
> the ones like:
> 
> LABEL grsec
>   KERNEL vmlinuz-3.0.10-grsec
>   APPEND initrd=initramfs-3.0.10-grsec
> root=UUID=cfd4a7b4-8c40-4025-b877-8205f1c622ee
> modules=sd-mod,usb-storage,ext4 xen quiet
> 
> This patch fixes it, adding a new case when parsing the "append" line,
> that searches for the initrd image.
> 
> Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx>

Please could you also supply an example file for your platform as a
patch to tools/pygrub/examples.

> diff -r 3e02aa9670b3 -r bd59a07ed411 tools/pygrub/src/ExtLinuxConf.py
> --- a/tools/pygrub/src/ExtLinuxConf.py        Thu Dec 15 18:55:46 2011 +0100
> +++ b/tools/pygrub/src/ExtLinuxConf.py        Mon Jan 02 11:45:51 2012 +0100
> @@ -60,6 +60,13 @@ class ExtLinuxImage(object):
>  
>                  # Bypass regular self.commands handling
>                  com = None
> +            elif arg.find(" "):
> +                # find initrd image in append line
> +                args = arg.strip().split(" ")
> +                for a in args:
> +                    if a.lower().startswith("initrd"):

Should check for "initrd=" here?

Or perhaps:
        * check for "="
        * split into "k = v"
        * check that k is precisely "initrd"
the first two are probably doable in the same str.split invocation if
you handle the exception correctly.

> +                        setattr(self, "initrd", a.replace("initrd=", ""))
> +                        arg = arg.replace(a, "")
>  
>          if com is not None and self.commands.has_key(com):
>              if self.commands[com] is not None:
> @@ -86,10 +93,12 @@ class ExtLinuxImage(object):
>          self._args = args
>      def get_kernel(self):
>          return self._kernel
> +    def set_args(self, val):
> +        self._args = val
>      def get_args(self):
>          return self._args
>      kernel = property(get_kernel, set_kernel)
> -    args = property(get_args)
> +    args = property(get_args, set_args)

Are these something required by arg.replace?

Ian.



_______________________________________________
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®.