xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [Xen-devel] [PATCH] failing to set value to 0 in Grub2ConfigFile
@ 2019-08-13 21:02 YOUNG, MICHAEL A.
  2019-08-13 21:09 ` Andrew Cooper
  2019-08-14 11:17 ` Andrew Cooper
  0 siblings, 2 replies; 5+ messages in thread
From: YOUNG, MICHAEL A. @ 2019-08-13 21:02 UTC (permalink / raw)
  To: xen-devel

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

I have been looking at the pygrub code to see if it is possible to cope 
with grub files with BLSCFG and spotted this minor issue in GrubConf.py 
where the code intends to replace ${saved_entry} and ${next_entry} with 0 
but doesn't succeed.

Signed-off-by: Michael Young <m.a.young@durham.ac.uk>


[-- Attachment #2: 0001-failing-to-set-value-to-0-in-Grub2ConfigFile.patch --]
[-- Type: text/plain, Size: 1382 bytes --]

From a08eff9b1b881dc61f9427153706e2d5b3bd0e01 Mon Sep 17 00:00:00 2001
From: Michael Young <m.a.young@durham.ac.uk>
Date: Tue, 13 Aug 2019 21:15:02 +0100
Subject: [PATCH] failing to set value to 0 in Grub2ConfigFile

In Grub2ConfigFile the code to handle ${saved_entry} and ${next_entry}
sets arg = "0" but this now does nothing following
"tools/pygrub: Make pygrub understand default entry in string format"
d1b93ea2615bd789ee28901f1f1c05ffb319cb61
which replaced arg.strip() with arg_strip in the following line.
This patch restores the previous behaviour.
---
 tools/pygrub/src/GrubConf.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/pygrub/src/GrubConf.py b/tools/pygrub/src/GrubConf.py
index 594139bac7..73f1bbed2f 100644
--- a/tools/pygrub/src/GrubConf.py
+++ b/tools/pygrub/src/GrubConf.py
@@ -440,7 +440,7 @@ class Grub2ConfigFile(_GrubConfigFile):
                     arg_strip = arg.strip()
                     if arg_strip == "${saved_entry}" or arg_strip == "${next_entry}":
                         logging.warning("grub2's saved_entry/next_entry not supported")
-                        arg = "0"
+                        arg_strip = "0"
                     setattr(self, self.commands[com], arg_strip)
                 else:
                     logging.info("Ignored directive %s" %(com,))
-- 
2.21.0


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

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH] failing to set value to 0 in Grub2ConfigFile
  2019-08-13 21:02 [Xen-devel] [PATCH] failing to set value to 0 in Grub2ConfigFile YOUNG, MICHAEL A.
@ 2019-08-13 21:09 ` Andrew Cooper
  2019-08-13 21:51   ` YOUNG, MICHAEL A.
  2019-08-14 11:17 ` Andrew Cooper
  1 sibling, 1 reply; 5+ messages in thread
From: Andrew Cooper @ 2019-08-13 21:09 UTC (permalink / raw)
  To: YOUNG, MICHAEL A., xen-devel; +Cc: Steven Haigh

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

On 13/08/2019 22:02, YOUNG, MICHAEL A. wrote:
> I have been looking at the pygrub code to see if it is possible to cope 
> with grub files with BLSCFG and spotted this minor issue in GrubConf.py 
> where the code intends to replace ${saved_entry} and ${next_entry} with 0 
> but doesn't succeed.
>
> Signed-off-by: Michael Young <m.a.young@durham.ac.uk>

Ah - this looks suspiciously like it might be the bugfix for an issue
reported by Steven.

Steven - do you mind giving this patch a try for your "Fedora 30 DomU -
pygrub always boots the second menu option" problem?

~Andrew

[-- Attachment #2: 0001-failing-to-set-value-to-0-in-Grub2ConfigFile.patch --]
[-- Type: text/plain, Size: 1351 bytes --]

From a08eff9b1b881dc61f9427153706e2d5b3bd0e01 Mon Sep 17 00:00:00 2001
From: Michael Young <m.a.young@durham.ac.uk>
Date: Tue, 13 Aug 2019 21:15:02 +0100
Subject: [PATCH] failing to set value to 0 in Grub2ConfigFile

In Grub2ConfigFile the code to handle ${saved_entry} and ${next_entry}
sets arg = "0" but this now does nothing following
"tools/pygrub: Make pygrub understand default entry in string format"
d1b93ea2615bd789ee28901f1f1c05ffb319cb61
which replaced arg.strip() with arg_strip in the following line.
This patch restores the previous behaviour.
---
 tools/pygrub/src/GrubConf.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/pygrub/src/GrubConf.py b/tools/pygrub/src/GrubConf.py
index 594139bac7..73f1bbed2f 100644
--- a/tools/pygrub/src/GrubConf.py
+++ b/tools/pygrub/src/GrubConf.py
@@ -440,7 +440,7 @@ class Grub2ConfigFile(_GrubConfigFile):
                     arg_strip = arg.strip()
                     if arg_strip == "${saved_entry}" or arg_strip == "${next_entry}":
                         logging.warning("grub2's saved_entry/next_entry not supported")
-                        arg = "0"
+                        arg_strip = "0"
                     setattr(self, self.commands[com], arg_strip)
                 else:
                     logging.info("Ignored directive %s" %(com,))
-- 
2.21.0


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

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH] failing to set value to 0 in Grub2ConfigFile
  2019-08-13 21:09 ` Andrew Cooper
@ 2019-08-13 21:51   ` YOUNG, MICHAEL A.
  2019-08-14  5:14     ` Steven Haigh
  0 siblings, 1 reply; 5+ messages in thread
From: YOUNG, MICHAEL A. @ 2019-08-13 21:51 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: xen-devel, Steven Haigh

On Tue, 13 Aug 2019, Andrew Cooper wrote:

> On 13/08/2019 22:02, YOUNG, MICHAEL A. wrote:
>> I have been looking at the pygrub code to see if it is possible to cope
>> with grub files with BLSCFG and spotted this minor issue in GrubConf.py
>> where the code intends to replace ${saved_entry} and ${next_entry} with 0
>> but doesn't succeed.
>>
>> Signed-off-by: Michael Young <m.a.young@durham.ac.uk>
>
> Ah - this looks suspiciously like it might be the bugfix for an issue
> reported by Steven.
>
> Steven - do you mind giving this patch a try for your "Fedora 30 DomU -
> pygrub always boots the second menu option" problem?

Sadly I don't think it is that simple and to it properly would require 
parsing if clauses in the grub file and also reading variables from the 
grubenv file.

I do however have an idea which might work which is to ignore anything in 
if clauses, read the grubenv file (which I now have a hacky way of doing) 
and treating the value of next_entry or saved_entry as the setting for
the default kernel to pick. If I finish a patch that does this I will post
it on the list, but I very much doubt it will be of commitable quality.

 	Michael Young

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH] failing to set value to 0 in Grub2ConfigFile
  2019-08-13 21:51   ` YOUNG, MICHAEL A.
@ 2019-08-14  5:14     ` Steven Haigh
  0 siblings, 0 replies; 5+ messages in thread
From: Steven Haigh @ 2019-08-14  5:14 UTC (permalink / raw)
  To: YOUNG, MICHAEL A.; +Cc: Andrew Cooper, xen-devel

I've had a tinker with the patch - I don't have a Fedora build system 
atm - so I just edited the file on the Dom0 and removed the pyc/pyo 
files. Same issue:

    pyGRUB  version 0.6
 
┌────────────────────────────────────────────────────────────────────────┐
 │ Fedora (5.2.6-200.fc30.x86_64) 30 (Thirty)                         
    │
 │ Fedora (0-rescue-ee4b18b1898e4bf2b36ff71077b23b5e) 30 (Thirty)     
    │
 │                                                                    
    │
 │                                                                    
    │
 │                                                                    
    │
 │                                                                    
    │
 │                                                                    
    │
 │                                                                    
    │
 
└────────────────────────────────────────────────────────────────────────┘
     Use the ^ and v keys to select which entry is highlighted.
     Press enter to boot the selected OS, 'e' to edit the
     commands before booting, 'a' to modify the kernel arguments
     before booting, or 'c' for a command line.

The rescue entry is selected in the above example.

My crappy hack has been to edit /usr/libexec/xen/bin/pygrub and add 
sel=0 as follows:

    def image_index(self):
        if isinstance(self.cf.default, int):
            sel = self.cf.default
        elif self.cf.default.isdigit():
            sel = int(self.cf.default)
            sel = 0
        else:

I know this is horrible!

I'm still disabling BLSCFG in /etc/default/grub - otherwise the pygrub 
menu is completely empty.

I don't know what the solution is right now - but I do somewhat agree 
with ignoring anything inside an if statement in grub.cfg - as the 
logic is ignored anyway. Do you still need to read the grubenv in doing 
this?

I assume the read for grubenv is to get the 'saved_entry' value?

Steven Haigh

📧 netwiz@crc.id.au     💻 https://www.crc.id.au
📞 +613 9001 6090       📱 +614 1293 5897


On Wed, Aug 14, 2019 at 7:51 AM, "YOUNG, MICHAEL A." 
<m.a.young@durham.ac.uk> wrote:
> On Tue, 13 Aug 2019, Andrew Cooper wrote:
> 
>>  On 13/08/2019 22:02, YOUNG, MICHAEL A. wrote:
>>>  I have been looking at the pygrub code to see if it is possible to 
>>> cope
>>>  with grub files with BLSCFG and spotted this minor issue in 
>>> GrubConf.py
>>>  where the code intends to replace ${saved_entry} and ${next_entry} 
>>> with 0
>>>  but doesn't succeed.
>>> 
>>>  Signed-off-by: Michael Young <m.a.young@durham.ac.uk>
>> 
>>  Ah - this looks suspiciously like it might be the bugfix for an 
>> issue
>>  reported by Steven.
>> 
>>  Steven - do you mind giving this patch a try for your "Fedora 30 
>> DomU -
>>  pygrub always boots the second menu option" problem?
> 
> Sadly I don't think it is that simple and to it properly would require
> parsing if clauses in the grub file and also reading variables from 
> the
> grubenv file.
> 
> I do however have an idea which might work which is to ignore 
> anything in
> if clauses, read the grubenv file (which I now have a hacky way of 
> doing)
> and treating the value of next_entry or saved_entry as the setting for
> the default kernel to pick. If I finish a patch that does this I will 
> post
> it on the list, but I very much doubt it will be of commitable 
> quality.
> 
>  	Michael Young
> 
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xenproject.org
> https://lists.xenproject.org/mailman/listinfo/xen-devel



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

* Re: [Xen-devel] [PATCH] failing to set value to 0 in Grub2ConfigFile
  2019-08-13 21:02 [Xen-devel] [PATCH] failing to set value to 0 in Grub2ConfigFile YOUNG, MICHAEL A.
  2019-08-13 21:09 ` Andrew Cooper
@ 2019-08-14 11:17 ` Andrew Cooper
  1 sibling, 0 replies; 5+ messages in thread
From: Andrew Cooper @ 2019-08-14 11:17 UTC (permalink / raw)
  To: YOUNG, MICHAEL A., xen-devel

On 13/08/2019 22:02, YOUNG, MICHAEL A. wrote:
> I have been looking at the pygrub code to see if it is possible to cope 
> with grub files with BLSCFG and spotted this minor issue in GrubConf.py 
> where the code intends to replace ${saved_entry} and ${next_entry} with 0 
> but doesn't succeed.
>
> Signed-off-by: Michael Young <m.a.young@durham.ac.uk>

Irrespective of other issues, this is clearly a good bugfix.  Committed.

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

end of thread, other threads:[~2019-08-14 11:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-13 21:02 [Xen-devel] [PATCH] failing to set value to 0 in Grub2ConfigFile YOUNG, MICHAEL A.
2019-08-13 21:09 ` Andrew Cooper
2019-08-13 21:51   ` YOUNG, MICHAEL A.
2019-08-14  5:14     ` Steven Haigh
2019-08-14 11:17 ` Andrew Cooper

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).