mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-26 12:22:15 +00:00
fix(grub2): a ppc node is given linuxefi when its image carries it
grub2_kernel_commands read the image and not the architecture, so a ppc node whose grub2 image carries linuxefi was given it. linuxefi loads an EFI binary and a ppc loader is not one. The previous commit removed the architecture test along with the defect it carried. The command now needs both: the architecture whose loader is an EFI binary, and an image that carries the command. grub2_netboot_protocol.t covers the three architectures and caught this. Its loader fixture now records the commands it carries, because the configuration follows the image. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -56,14 +56,18 @@ sub volatile_addkcmdline {
|
||||
"can't find command `linuxefi'" and never asks for the kernel.
|
||||
|
||||
Arguments: $image the path of the grub2 image served to the node
|
||||
$arch the architecture of the node
|
||||
Returns: the kernel command and the initial ramdisk command
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
sub grub2_kernel_commands {
|
||||
my ($image) = @_;
|
||||
my ($image, $arch) = @_;
|
||||
|
||||
# linuxefi loads an EFI binary. x86 is the architecture whose grub2 loader is one, so
|
||||
# a ppc node takes linux whatever its image carries.
|
||||
return ('linux', 'initrd') unless defined($arch) && $arch =~ /x86/i;
|
||||
return ('linux', 'initrd') unless grub2_image_provides($image, 'linuxefi');
|
||||
return ('linuxefi', 'initrdefi');
|
||||
}
|
||||
|
||||
@@ -358,7 +358,7 @@ sub setstate {
|
||||
# The commands come from the image served to this node, not from its
|
||||
# architecture: an image built from upstream grub has no linuxefi.
|
||||
my ($kernelcmd, $initrdcmd) =
|
||||
xCAT::BootUtils::grub2_kernel_commands($grub2bin);
|
||||
xCAT::BootUtils::grub2_kernel_commands($grub2bin, $nodearch);
|
||||
|
||||
if ($kern and $kern->{kcmdline}) {
|
||||
my $kcmdline = quote_kcmdline($kern->{kcmdline});
|
||||
|
||||
@@ -13,7 +13,7 @@ use warnings;
|
||||
use File::Spec;
|
||||
use File::Temp qw(tempdir);
|
||||
use FindBin;
|
||||
use Test::More tests => 8;
|
||||
use Test::More tests => 9;
|
||||
|
||||
use lib "$FindBin::Bin/../../perl-xCAT";
|
||||
use xCAT::BootUtils;
|
||||
@@ -36,19 +36,19 @@ sub write_image {
|
||||
my $downstream = write_image('grub2.downstream', qw(linux linuxefi initrd initrdefi));
|
||||
my $upstream = write_image('grub2.upstream', qw(linux initrd));
|
||||
|
||||
is_deeply( [ xCAT::BootUtils::grub2_kernel_commands($downstream) ],
|
||||
is_deeply( [ xCAT::BootUtils::grub2_kernel_commands($downstream, 'x86_64') ],
|
||||
[ 'linuxefi', 'initrdefi' ],
|
||||
'an image that carries linuxefi is given linuxefi and initrdefi' );
|
||||
|
||||
is_deeply( [ xCAT::BootUtils::grub2_kernel_commands($upstream) ],
|
||||
is_deeply( [ xCAT::BootUtils::grub2_kernel_commands($upstream, 'x86_64') ],
|
||||
[ 'linux', 'initrd' ],
|
||||
'an image built from upstream grub is given linux and initrd' );
|
||||
|
||||
# A missing or unreadable image must not produce a command the node cannot run. linux is
|
||||
# carried by every grub2 image, so it is the safe answer.
|
||||
is_deeply( [ xCAT::BootUtils::grub2_kernel_commands( File::Spec->catfile($dir, 'absent') ) ],
|
||||
is_deeply( [ xCAT::BootUtils::grub2_kernel_commands( File::Spec->catfile($dir, 'absent'), 'x86_64' ) ],
|
||||
[ 'linux', 'initrd' ], 'a missing image is given linux and initrd' );
|
||||
is_deeply( [ xCAT::BootUtils::grub2_kernel_commands(undef) ],
|
||||
is_deeply( [ xCAT::BootUtils::grub2_kernel_commands(undef, 'x86_64') ],
|
||||
[ 'linux', 'initrd' ], 'an undefined image is given linux and initrd' );
|
||||
|
||||
ok( xCAT::BootUtils::grub2_image_provides($downstream, 'linuxefi'),
|
||||
@@ -62,3 +62,8 @@ ok( xCAT::BootUtils::grub2_image_provides($upstream, 'linux'),
|
||||
# would look downstream.
|
||||
ok( !xCAT::BootUtils::grub2_image_provides( write_image('grub2.efionly', 'linuxefi'), 'linux' ),
|
||||
'a longer command name does not satisfy a shorter one' );
|
||||
|
||||
# linuxefi loads an EFI binary, and a ppc loader is not one. The image is irrelevant there.
|
||||
is_deeply( [ xCAT::BootUtils::grub2_kernel_commands($downstream, 'ppc64le') ],
|
||||
[ 'linux', 'initrd' ],
|
||||
'a ppc node takes linux even from an image that carries linuxefi' );
|
||||
|
||||
@@ -54,7 +54,11 @@ for my $arch (qw(x86_64 ppc64le aarch64 riscv64)) {
|
||||
my $bootdir = "$tftpdir/boot/grub2";
|
||||
make_path($bootdir);
|
||||
my $loader_arch = $arch eq 'ppc64le' ? 'ppc' : $arch;
|
||||
write_text("$bootdir/grub2.$loader_arch", "fixture loader\n");
|
||||
# The kernel command follows the image, not the architecture, so the fixture
|
||||
# has to say which commands it carries. grub records the name of each command
|
||||
# its modules register. This one stands for a downstream image.
|
||||
write_text("$bootdir/grub2.$loader_arch",
|
||||
"fixture loader\0linux\0linuxefi\0initrd\0initrdefi\0\n");
|
||||
local $::XCATSITEVALS{httpport} = $port;
|
||||
delete $::XCATSITEVALS{httpport} unless defined $port;
|
||||
my %noderes = (tftpserver => 'server');
|
||||
@@ -89,6 +93,8 @@ for my $arch (qw(x86_64 ppc64le aarch64 riscv64)) {
|
||||
my @roots = $entry =~ /^\s*set root=(.*)$/mg;
|
||||
is_deeply(\@roots, [$expected_root], 'transfer protocol and port are correct');
|
||||
my $prefix = $http_paths ? $tftpdir : '';
|
||||
# x86_64 is the architecture whose loader is an EFI binary, and the fixture
|
||||
# above carries linuxefi, so that is what the configuration must use.
|
||||
my $efi = $arch eq 'x86_64' ? 'efi' : '';
|
||||
my @kernels = $entry =~ /^\s*(linux\S* .*)$/mg;
|
||||
is_deeply(\@kernels,
|
||||
|
||||
Reference in New Issue
Block a user