[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [OSSTEST Nested PATCH v11 2/7] Parsing grub which has 'submenu' primitive
Now auto-gen kernel grub2 config file's boot menu entries can have 2-level hierarchy, containing 'submenu' primitive, which is comprised by several sub-menuentries. Xen boot entries are grouped into such kind of 'submenu' block. This patch adds setupboot_grub2() ability to handle such new grub.cfg format Signed-off-by: longtao.pang <longtaox.pang@xxxxxxxxx> --- Changes in v11: 1. Ian corrects our previous implementation of submenu handling. When selecting submenu's menuentry, it shall be the 2-level format of 'M>N', M is the 'submenu' entry number in first level, N is the sub-menuentry numbering inside 'submenu' block, starting from 0. Ian's correcting patch: http://lists.xenproject.org/archives/html/xen-devel/2015-05/msg03108.html. Based on Ian's correcting patch, we dogmatically alternatively use 'pop/push' to handle array of @offsets. --- Osstest/Debian.pm | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/Osstest/Debian.pm b/Osstest/Debian.pm index 46388d8..b1d1043 100644 --- a/Osstest/Debian.pm +++ b/Osstest/Debian.pm @@ -405,12 +405,22 @@ sub setupboot_grub2 ($$$$) { my $parsemenu= sub { my $f= bl_getmenu_open($ho, $rmenu, "$stash/$ho->{Name}--grub.cfg.1"); - my $count= 0; + my @offsets = (0); my $entry; + my $submenu; while (<$f>) { next if m/^\s*\#/ || !m/\S/; if (m/^\s*\}\s*$/) { - die unless $entry; + die unless $entry || $submenu; + if(!defined $entry && defined $submenu){ + logm("Met end of a submenu starting from ". + "$submenu->{StartLine}. ". + "Our want kern is $want_kernver"); + $submenu=undef; + pop @offsets; + $offsets[$#offsets]++; + next; + } my (@missing) = grep { !defined $entry->{$_} } (defined $xenhopt @@ -438,8 +448,12 @@ sub setupboot_grub2 ($$$$) { } if (m/^menuentry\s+[\'\"](.*)[\'\"].*\{\s*$/) { die $entry->{StartLine} if $entry; - $entry= { Title => $1, StartLine => $., Number => $count }; - $count++; + $entry= { Title => $1, StartLine => $., MenuEntryPath => join ">", @offsets }; + $offsets[$#offsets]++; + } + if (m/^submenu\s+[\'\"](.*)[\'\"].*\{\s*$/) { + $submenu={ StartLine =>$., MenuEntryPath => join ">", @offsets }; + push @offsets,(0); } if (m/^\s*multiboot\s*\/(xen\-[0-9][-+.0-9a-z]*\S+)/) { die unless $entry; @@ -500,7 +514,7 @@ sub setupboot_grub2 ($$$$) { } print ::EO <<END or die $!; -GRUB_DEFAULT=$entry->{Number} +GRUB_DEFAULT="$entry->{MenuEntryPath}" END print ::EO <<END or die $! if defined $xenhopt; -- 1.7.10.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |