xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pyGrub: Fix default when out of range
@ 2010-06-28 17:26 Michal Novotny
  2010-06-29 13:54 ` Ian Jackson
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Novotny @ 2010-06-28 17:26 UTC (permalink / raw)
  To: 'xen-devel@lists.xensource.com'

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

Hi,
this is the patch to fix pyGrub default value when it's being set out of 
range. This patch makes the quiet and interactive mode select the same 
default image when the default value for boot entry is out of range, 
i.e. when the guest is having wrong configuration in it's boot loader 
(like 3 entries with default mistakenly set to 10 etc).

When the boot entry number is being set out of range it falls back to 0 
(first entry of boot loader).

Michal

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

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


[-- Attachment #2: xen-pygrub-fix-default-out-of-range.patch --]
[-- Type: text/x-patch, Size: 560 bytes --]

diff -r 7b00193bd033 tools/pygrub/src/pygrub
--- a/tools/pygrub/src/pygrub	Mon Jun 28 17:40:16 2010 +0100
+++ b/tools/pygrub/src/pygrub	Mon Jun 28 19:21:20 2010 +0200
@@ -415,6 +415,9 @@ class Grub:
         timeout = int(self.cf.timeout)
 
         self.selected_image = self.cf.default
+        # If the selected (default) image doesn't exist we select the first entry
+        if self.selected_image > len(self.cf.images):
+            self.selected_image = 0
         self.isdone = False
         while not self.isdone:
             self.run_main(timeout)

[-- 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] 4+ messages in thread

* Re: [PATCH] pyGrub: Fix default when out of range
  2010-06-28 17:26 [PATCH] pyGrub: Fix default when out of range Michal Novotny
@ 2010-06-29 13:54 ` Ian Jackson
  2010-06-29 14:24   ` Michal Novotny
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Jackson @ 2010-06-29 13:54 UTC (permalink / raw)
  To: Michal Novotny; +Cc: 'xen-devel@lists.xensource.com'

Michal Novotny writes ("[Xen-devel] [PATCH] pyGrub: Fix default when out of range"):
> this is the patch to fix pyGrub default value when it's being set out of 
> range. This patch makes the quiet and interactive mode select the same 
> default image when the default value for boot entry is out of range, 
> i.e. when the guest is having wrong configuration in it's boot loader 
> (like 3 entries with default mistakenly set to 10 etc).

I'm not sure this is right.  What does grub proper do with invalid
defaults ?  Is it really correct to blunder on and just use the first
one as a default ?

Sorry to quibble.

Ian.

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

* Re: [PATCH] pyGrub: Fix default when out of range
  2010-06-29 13:54 ` Ian Jackson
@ 2010-06-29 14:24   ` Michal Novotny
  2010-06-29 15:23     ` Ian Jackson
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Novotny @ 2010-06-29 14:24 UTC (permalink / raw)
  To: Ian Jackson; +Cc: 'xen-devel@lists.xensource.com'

On 06/29/2010 03:54 PM, Ian Jackson wrote:
> Michal Novotny writes ("[Xen-devel] [PATCH] pyGrub: Fix default when out of range"):
>    
>> this is the patch to fix pyGrub default value when it's being set out of
>> range. This patch makes the quiet and interactive mode select the same
>> default image when the default value for boot entry is out of range,
>> i.e. when the guest is having wrong configuration in it's boot loader
>> (like 3 entries with default mistakenly set to 10 etc).
>>      
> I'm not sure this is right.  What does grub proper do with invalid
> defaults ?  Is it really correct to blunder on and just use the first
> one as a default ?
>
> Sorry to quibble.
>
> Ian.
>    

Hi Ian,
I did try it using the real (bare-metal) grub 0.97 (in RHEL-5) to set 
the default out of range and it was set to the first entry so it matches 
the bare-metal grub behavior now. So the quiet mode was having it right 
all the time but interactive mode didn't so this is basically fix for 
interactive mode of pygrub.

Michal

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

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

* Re: [PATCH] pyGrub: Fix default when out of range
  2010-06-29 14:24   ` Michal Novotny
@ 2010-06-29 15:23     ` Ian Jackson
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Jackson @ 2010-06-29 15:23 UTC (permalink / raw)
  To: Michal Novotny; +Cc: 'xen-devel@lists.xensource.com'

Michal Novotny writes ("Re: [Xen-devel] [PATCH] pyGrub: Fix default when out of range"):
> I did try it using the real (bare-metal) grub 0.97 (in RHEL-5) to set 
> the default out of range and it was set to the first entry so it matches 
> the bare-metal grub behavior now. So the quiet mode was having it right 
> all the time but interactive mode didn't so this is basically fix for 
> interactive mode of pygrub.

Excellent, thanks for the clarification.  I have applied your patch.

Ian.

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

end of thread, other threads:[~2010-06-29 15:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-28 17:26 [PATCH] pyGrub: Fix default when out of range Michal Novotny
2010-06-29 13:54 ` Ian Jackson
2010-06-29 14:24   ` Michal Novotny
2010-06-29 15:23     ` Ian Jackson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).