All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pyGrub: Use proper bootloader class when entering command manually
@ 2010-05-25 14:39 Michal Novotny
  2010-05-25 15:13 ` Michal Novotny
  0 siblings, 1 reply; 5+ messages in thread
From: Michal Novotny @ 2010-05-25 14:39 UTC (permalink / raw)
  To: 'xen-devel@lists.xensource.com'

[-- Attachment #1: Type: text/plain, Size: 822 bytes --]

Hi,
this is the patch to use the proper bootloader class when entering the 
boot commands manually (i.e. using the 'c' option). Before this patch 
the bootloader was always treated to be Grub but when user is using 
Grub2/ExtLinux or Lilo it's rather confusing. After applying this patch 
the proper bootloader image class is being used, e.g. Grub2Image for 
Grub2 etc. when you define the boot commands manually using the 'c' 
command in pyGrub.

Also, fix for using isconfig has been applied since if there is not fs 
set in the run_grub() method the read_config() would fail since it's 
trying to access undefined self.cf which is now being set to parser() 
from cfg_list.

Signed-off-by: Michal Novotny <minovotn@redhat.com>

-- 
Michal Novotny<minovotn@redhat.com>, RHCE
Virtualization Team (xen userspace), Red Hat


[-- Attachment #2: xen-pygrub-command-use-proper-bootloader-class.patch --]
[-- Type: text/x-patch, Size: 1857 bytes --]

diff -r 10ad9b50b4ca tools/pygrub/src/pygrub
--- a/tools/pygrub/src/pygrub	Tue May 25 11:28:58 2010 +0100
+++ b/tools/pygrub/src/pygrub	Tue May 25 16:31:06 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(lines)
                 self.cf.add_image(img)
                 self.selected_image = len(self.cf.images) - 1
                 self.isdone = True
@@ -392,15 +392,28 @@ class Grub:
 
         if not fs:
             # set the config file and parse it
-            self.cf.filename = fn
-            self.cf.parse()
-            return
+            for f,parser in cfg_list:
+                self.cf = parser()
+                self.cf.filename = fn
+                self.cf.parse()
+                return
 
         for f,parser in cfg_list:
             if fs.file_exists(f):
                 print >>sys.stderr, "Using %s to parse %s" % (parser,f)
                 self.cf = parser()
                 self.cf.filename = f
+
+                # Get the bootloader image file constructor to imgcl
+                if type(self.cf) == type(grub.LiloConf.LiloConfigFile):
+                    self.imgcl = grub.LiloConf.LiloImage
+                elif type(self.cf) == type(grub.GrubConf.Grub2ConfigFile):
+                    self.imgcl = grub.GrubConf.Grub2Image
+                elif type(self.cf) == type(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."

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-05-26  9:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-25 14:39 [PATCH] pyGrub: Use proper bootloader class when entering command manually Michal Novotny
2010-05-25 15:13 ` Michal Novotny
2010-05-25 16:22   ` Ian Campbell
2010-05-26  9:27     ` Michal Novotny
2010-05-26  9:29       ` Ian Campbell

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.