From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Ian Campbell <Ian.Campbell@citrix.com>
Cc: Dave.Scott@citrix.com, Simon Rowe <simon.rowe@eu.citrix.com>,
xen-devel@lists.xen.org, Stefano.Stabellini@citrix.com,
Ian.Jackson@citrix.com,
Boris Ostrovsky <boris.ostrovsky@oracle.com>
Subject: Re: [PATCH] pygrub: fix non-interactive parsing of grub1 config files
Date: Tue, 4 Nov 2014 10:26:31 -0500 [thread overview]
Message-ID: <20141104152631.GD4510@laptop.dumpdata.com> (raw)
In-Reply-To: <1415097997.11486.18.camel@citrix.com>
On Tue, Nov 04, 2014 at 10:46:37AM +0000, Ian Campbell wrote:
> On Mon, 2014-10-27 at 12:35 -0400, Boris Ostrovsky wrote:
> > On 10/27/2014 12:00 PM, Simon Rowe wrote:
> > > Changes to handle non-numeric default attributes for grub2 caused run_grub()
> > > to attempt to index into the images list using a string. Pull out the code
> > > that handles submenus into a new function and use that to ensure sel is
> > > numeric.
> > >
> > > Reported-by: David Scott <dave.scott@citrix.com>
> > > Signed-off-by: Simon Rowe <simon.rowe@eu.citrix.com>
> >
> > Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
>
> Acked-by: Ian Campbell <ian.campbell@citrix.com>
>
> And applied as a bug fix (I'm not sure if Konrad's response was intended
> as a release-ack).
Yes. Thank you for checking this patch in.
>
> >
> > > ---
> > > tools/pygrub/src/pygrub | 23 ++++++++++++++---------
> > > 1 file changed, 14 insertions(+), 9 deletions(-)
> > >
> > > diff --git a/tools/pygrub/src/pygrub b/tools/pygrub/src/pygrub
> > > index 1ae34a2..4cc846f 100644
> > > --- a/tools/pygrub/src/pygrub
> > > +++ b/tools/pygrub/src/pygrub
> > > @@ -456,11 +456,9 @@ class Grub:
> > > del f
> > > self.cf.parse(buf)
> > >
> > > - def run(self):
> > > - timeout = int(self.cf.timeout)
> > > -
> > > + def image_index(self):
> > > if self.cf.default.isdigit():
> > > - self.selected_image = int(self.cf.default)
> > > + sel = int(self.cf.default)
> > > else:
> > > # We don't fully support submenus. Look for the leaf value in
> > > # "submenu0>submenu1>...>menuentry" and hope that it's unique.
> > > @@ -472,16 +470,23 @@ class Grub:
> > > break
> > >
> > > # Map string to index in images array
> > > - self.selected_image = 0
> > > + sel = 0
> > > for i in range(len(self.cf.images)):
> > > if self.cf.images[i].title == title:
> > > - self.selected_image = i
> > > + sel = i
> > > break
> > >
> > > # If the selected (default) image doesn't exist we select the first entry
> > > - if self.selected_image > len(self.cf.images):
> > > + if sel > len(self.cf.images):
> > > logging.warning("Default image not found")
> > > - self.selected_image = 0
> > > + sel = 0
> > > +
> > > + return sel
> > > +
> > > + def run(self):
> > > + timeout = int(self.cf.timeout)
> > > + self.selected_image = self.image_index()
> > > +
> > > self.isdone = False
> > > while not self.isdone:
> > > self.run_main(timeout)
> > > @@ -626,7 +631,7 @@ def run_grub(file, entry, fs, cfg_args):
> > > if interactive and not list_entries:
> > > curses.wrapper(run_main)
> > > else:
> > > - sel = g.cf.default
> > > + sel = g.image_index()
> > >
> > > # set the entry to boot as requested
> > > if entry is not None:
> >
>
>
next prev parent reply other threads:[~2014-11-04 15:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-27 16:00 [PATCH] pygrub: fix non-interactive parsing of grub1 config files Simon Rowe
2014-10-27 16:17 ` for-xen-4.5 Was:Re: " Konrad Rzeszutek Wilk
2014-10-27 16:35 ` Boris Ostrovsky
2014-11-04 10:46 ` Ian Campbell
2014-11-04 15:26 ` Konrad Rzeszutek Wilk [this message]
2014-10-28 12:38 ` Andrew Cooper
-- strict thread matches above, loose matches on Subject: below --
2014-09-08 14:01 David Scott
2014-09-08 17:11 ` Boris Ostrovsky
2014-09-10 12:50 ` Dave Scott
2014-10-24 21:15 ` Konrad Rzeszutek Wilk
2014-10-27 12:51 ` Simon Rowe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141104152631.GD4510@laptop.dumpdata.com \
--to=konrad.wilk@oracle.com \
--cc=Dave.Scott@citrix.com \
--cc=Ian.Campbell@citrix.com \
--cc=Ian.Jackson@citrix.com \
--cc=Stefano.Stabellini@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=simon.rowe@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).