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

Re: [Xen-devel] [PATCH] pyGrub: Use proper bootloader class when enterin

To: Michal Novotny <minovotn@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH] pyGrub: Use proper bootloader class when entering command manually
From: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Date: Tue, 25 May 2010 17:22:33 +0100
Cc: "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Tue, 25 May 2010 09:23:31 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <4BFBE92A.7040603@xxxxxxxxxx>
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>
Organization: Citrix Systems, Inc.
References: <4BFBE114.20208@xxxxxxxxxx> <4BFBE92A.7040603@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Tue, 2010-05-25 at 16:13 +0100, Michal Novotny wrote:
> Ok, I found that the infrastructure of ExtLinuxImage and LiloImage is 
> different so I rewrote it a little (but according to the code the old 
> behaviour should be preserved) and also fixed the isconfig bug (since no 
> img.initrd is accessible that time).
> 
> So please ignore the previous version of my patch and use this one.

Perhaps instead of these two hunks:

--- a/tools/pygrub/src/pygrub   Tue May 25 11:28:58 2010 +0100
+++ b/tools/pygrub/src/pygrub   Tue May 25 17:10:32 2010 +0200
@@ -356,7 +356,7 @@ class Grub:
                     continue
 
                 # if we got boot, then we want to boot the entered image 
-                img = grub.GrubConf.GrubImage(lines)
+                img = self.imgcl("entered", lines)
                 self.cf.add_image(img)
                 self.selected_image = len(self.cf.images) - 1
                 self.isdone = True

[...]
                 self.cf = parser()
                 self.cf.filename = f
+
+                # Get the bootloader image file constructor to imgcl
+                if type(self.cf) == grub.LiloConf.LiloConfigFile:
+                    self.imgcl = grub.LiloConf.LiloImage
+                elif type(self.cf) == grub.GrubConf.Grub2ConfigFile:
+                    self.imgcl = grub.GrubConf.Grub2Image
+                elif type(self.cf) ==
grub.ExtLinuxConf.ExtLinuxConfigFile:
+                    self.imgcl = grub.ExtLinuxConf.ExtLinuxImage
+                else:
+                    self.imgcl = grub.GrubConf.GrubImage
+
                 break
         if self.__dict__.get('cf', None) is None:
             raise RuntimeError, "couldn't find bootloader config file
in the image provided."

We could add a method to each of the self.cf classes which returns a new
image from the title+lines given. Then the first hunk becomes something
like:

-                img = grub.GrubConf.GrubImage(lines)
+                img = self.cf.new_image("entered", lines)

and the second bit goes away. This would be nice since it avoids
hardcoding another list of bootloaders.

Ian.


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