pygrub: fix non-interactive parsing of grub1 config files
PATCH 1/1 pygrub: fix non-interactive parsing of grub1 config files
From: David Scott <[email protected]>
Since c/s d1b93ea2, the type of 'sel' now depends on whether pygrub is run interactively or not. In non-interactive / quiet mode it is a string; in interactive mode it is an integer.
When 'sel' is used to index an array it must be used as an integer.
--- tools/pygrub/src/pygrub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/pygrub/src/pygrub +1 -1
@@ -630,7 +630,7 @@ def run_grub(file, entry, fs, cfg_args): sys.exit(1) try: - img = g.cf.images[sel] + img = g.cf.images[int(sel)] except IndexError: img = g.cf.images[0]
Signature · 1 line
1.7.10.4
Quoted 18 lines · David Scott
From: David Scott <[email protected]>
Since c/s
d1b93ea2, the type of 'sel' now depends on whether pygrub is run interactively or not. In non-interactive / quiet mode it is a string; in interactive mode it is an integer.When 'sel' is used to index an array it must be used as an integer.
Signed-off-by David Scott <[email protected]>--- tools/pygrub/src/pygrub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/pygrub/src/pygrub +0
-0
tools/pygrub/src/pygrub def run_grub(file, entry, fs, cfg_args): · line 633
Quoted 5 lines
tools/pygrub/src/pygrub +1
-1@@ -630,7 +630,7 @@ def run_grub(file, entry, fs, cfg_args): sys.exit(1) try: - img = g.cf.images[sel] + img = g.cf.images[int(sel)]
What if sel is a "true" string (i.e. a name of the kernel to boot as opposed to an index)? Should we do the same thing as what Grub:run() does to map value to index?
-boris
Quoted 3 lines
tools/pygrub/src/pygrub +0
-0except IndexError: img = g.cf.images[0]
Quoted 14 lines · Boris Ostrovsky
Quoted 13 lines · David Scott
From: David Scott <[email protected]>
Since c/s
d1b93ea2, the type of 'sel' now depends on whether pygrub is run interactively or not. In non-interactive / quiet mode it is a string; in interactive mode it is an integer.When 'sel' is used to index an array it must be used as an integer.
Signed-off-by David Scott <[email protected]>--- tools/pygrub/src/pygrub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 11 lines
tools/pygrub/src/pygrub def run_grub(file, entry, fs, cfg_args): · line 632
Quoted 9 lines
tools/pygrub/src/pygrub +1
-1@@ -630,7 +630,7 @@ def run_grub(file, entry, fs, cfg_args): sys.exit(1) try: - img = g.cf.images[sel] + img = g.cf.images[int(sel)]What if sel is a "true" string (i.e. a name of the kernel to boot as opposed to an index)? Should we do the same thing as what Grub:run() does to map value to index?
Redefining ‘sel’ from an index into an array into to a key of a dictionary sounds plausible to me… but I’m not really familiar enough with pygrub to offer a trustworthy opinion.
I’ve cc:d Simon Rowe who is more familiar with pygrub — he may have some useful thoughts.
Dave
Quoted 6 lines
-boris
Quoted 2 lines
tools/pygrub/src/pygrub +0
-0except IndexError: img = g.cf.images[0]
Quoted 29 lines · Dave Scott
Quoted 14 lines · Boris Ostrovsky
Quoted 13 lines · David Scott
From: David Scott <[email protected]>
Since c/s
d1b93ea2, the type of 'sel' now depends on whether pygrub is run interactively or not. In non-interactive / quiet mode it is a string; in interactive mode it is an integer.When 'sel' is used to index an array it must be used as an integer.
Signed-off-by David Scott <[email protected]>--- tools/pygrub/src/pygrub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 11 lines
tools/pygrub/src/pygrub def run_grub(file, entry, fs, cfg_args): · line 632
Quoted 9 lines
tools/pygrub/src/pygrub +1
-1@@ -630,7 +630,7 @@ def run_grub(file, entry, fs, cfg_args): sys.exit(1) try: - img = g.cf.images[sel] + img = g.cf.images[int(sel)]What if sel is a "true" string (i.e. a name of the kernel to boot as opposed to an index)? Should we do the same thing as what Grub:run() does to map value to index?
Quoted 4 lines
Redefining ?sel? from an index into an array into to a key of a dictionary sounds plausible to me? but I?m not really familiar enough with pygrub to offer a trustworthy opinion.
I?ve cc:d Simon Rowe who is more familiar with pygrub ? he may have some useful thoughts.
ping ?
Quoted 13 lines
Dave
Quoted 6 lines
-boris
Quoted 2 lines
tools/pygrub/src/pygrub +0
-0except IndexError: img = g.cf.images[0]_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 8 lines · Konrad Rzeszutek Wilk
Quoted 5 lines · Dave Scott
Redefining ?sel? from an index into an array into to a key of a dictionary sounds plausible to me? but I?m not really familiar enough with pygrub to offer a trustworthy opinion.
I?ve cc:d Simon Rowe who is more familiar with pygrub ? he may have some useful thoughts.
ping ?
I think this changeset could just cause a ValueError to be thrown if a label was in cf.default at this point. I've got a patch I'm dev testing, I'll post it shortly,
Simon