Skip to contentSkip to conversation

pvgrub2 legacy_configfile issues: /sbin/init exec error -8

DISCUSSION Andy Smith 3 participants 12 messages Feb 11, 2017 – Feb 25, 2017

lore
Share & tools
lore

Andy Smith

author
#0 lore raw

Hi,

I'm experimenting with pvgrub2 for the first time, and having some problems getting a grub-legacy menu.lst config to work.

Using a Debian jessie Xen dom0 and guest. In dom0, grub is built from git:

----------------------------------------------------------------------

$ sudo apt-get build-dep grub
$ git clone git://git.savannah.gnu.org/grub.git
$ cd grub/
$ ./autogen.sh
$ ./configure --prefix=/opt/grub --target=amd64 --with-platform=xen
$ make
$ sudo make install
$ sudo mkdir -vp /opt/grub/share/memdisk
$ sudo tar -C /opt/grub/share/memdisk -cvf /opt/grub/share/memdisk.tar grub.cfg
$ sudo /opt/grub/bin/grub-mkimage -O x86_64-xen -c /opt/grub/etc/grub-bootstrap.cfg -m /opt/grub/share/memdisk.tar -o /opt/grub/lib/grub-x86_64-xen.bin -p /boot/grub /opt/grub/lib/grub/x86_64-xen/*.mod
----------------------------------------------------------------------

Contents of /opt/grub/etc/grub-bootstrap.cfg:

----------------------------------------------------------------------
normal (memdisk)/grub.cfg
----------------------------------------------------------------------

Contents of /opt/grub/share/memdisk/grub.cfg:

----------------------------------------------------------------------
if search -s -f /boot/xen/pvboot-x86_64.elf ; then

        echo "Chainloading (${root})/boot/xen/pvboot-x86_64.elf"
        read
        multiboot "/boot/xen/pvboot-x86_64.elf"
        boot

fi

if search -s -f /xen/pvboot-x86_64.elf ; then

        echo "Chainloading (${root})/xen/pvboot-x86_64.elf"
        read
        multiboot "/xen/pvboot-x86_64.elf"
        boot

fi

if search -s -f /boot/grub/grub.cfg ; then

        echo "Reading (${root})/boot/grub/grub.cfg"
        read
        configfile /boot/grub/grub.cfg

fi

if search -s -f /grub/grub.cfg ; then

        echo "Reading (${root})/grub/grub.cfg"
        read
        configfile /grub/grub.cfg

fi

if search -s -f /boot/grub/menu.lst ; then

        echo "Reading (${root})/boot/grub/menu.lst"
        read
        legacy_configfile /boot/grub/menu.lst

fi

if search -s -f /grub/menu.lst ; then

        set root=(xen/xvda,msdos1)
        echo "Reading (${root})/grub/menu.lst"
        read
        legacy_configfile /grub/menu.lst

fi
----------------------------------------------------------------------

Contents of /boot/grub/menu.lst in guest:

----------------------------------------------------------------------
default 0
timeout 5
color cyan/blue white/blue

title           Debian GNU/Linux, kernel 3.16.0-4-amd64
root            (hd0,0)
kernel          /boot/vmlinuz-3.16.0-4-amd64 root=UUID=38420e46-6123-477d-ba23-baeba8ac0d59 ro 
initrd          /boot/initrd.img-3.16.0-4-amd64

----------------------------------------------------------------------

So, purpose of the grub.cfg in the dom0 memdisk is to try to, in order:

1. Chainload pvgrub from guest, in boot/xen/ or in /xen/.

2. Parse guest's /boot/grub/grub.cfg or /grub/grub.cfg in pvgrub2.

3. Parse guest's legacy /boot/grub/menu.lst or /grub/menu.lst in pvgrub2.

(The "read" commands were used just to make it pause until I hit return so I could read the "echo" before it.)

I've tested that outcomes (1) and (2) work. That is, chainload to pvgrub2 in guest works and so does pvgrub parsing guest's grub.cfg.

After purging grub-xen and grub-pc packages from the guest and installing grub-legacy, ensuring there is no /boot/xen/*, no /boot/grub/grub.cfg, and that there is a /boot/grub/menu.lst as above, an attempt to boot the guest results in a kernel panic at the point where the guest kernel tries to execute /sbin/init:

----------------------------------------------------------------------
.
.
.

[    1.470403] Freeing unused kernel memory: 216K (ffff8800017ca000 - ffff880001800000)
[    1.471934] Failed to execute /init (error -8)
[    1.472673] Starting init: /sbin/init exists but couldn't execute it (error -8)
[    1.473359] Starting init: /bin/sh exists but couldn't execute it (error -8)
[    1.473365] Kernel panic - not syncing: No working init found.  Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.
[    1.473369] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 3.16.0-4-amd64 #1 Debian 3.16.39-1
[    1.473372]  0000000000000000 ffffffff81514c11 ffffffff81705310 ffff88003e23bf40
[    1.473377]  ffffffff8151195e ffffffff00000008 ffff88003e23bf50 ffff88003e23bef0
[    1.473380]  ffff88003e23bef8 0000000000000000 0000000000000495 0000000000000495
[    1.473384] Call Trace:

----------------------------------------------------------------------

Error -8 is an exec format error, almost as if it got booted as a 32-bit guest and tried to execute a 64-bit binary.

Switching the guest config back to pygrub allows it to boot without any alteration of the menu.lst inside the guest.

So, I feel I am missing something very simple here, but much searching has not produced any answer. Has anyone seen this before?

I appreciate I may have sent this query to the wrong place. It doesn't feel like a Xen issue so I haven't yet tried xen-devel list. Yet also probably not a bug in grub, just my misunderstanding, so I didn't put anything in your bugzilla. If you think there is a more appropriate place to send the query please do let me know.

Cheers,
Andy

#1 lore raw

11.02.2017 16:53, Andy Smith пишет:
...

Quoted 15 lines

if search -s -f /grub/menu.lst ; then

        set root=(xen/xvda,msdos1)
        echo "Reading (${root})/grub/menu.lst"
        read
        legacy_configfile /grub/menu.lst

fi
----------------------------------------------------------------------

Contents of /boot/grub/menu.lst in guest:

----------------------------------------------------------------------
default 0
timeout 5
color cyan/blue white/blue

Quoted 6 lines
title           Debian GNU/Linux, kernel 3.16.0-4-amd64
root            (hd0,0)
kernel          /boot/vmlinuz-3.16.0-4-amd64 root=UUID=38420e46-6123-477d-ba23-baeba8ac0d59 ro 
initrd          /boot/initrd.img-3.16.0-4-amd64

----------------------------------------------------------------------

What happens if you load the same kernel manually in dom0?

linux /boot/vmlinuz ...
initrd /boot/initrd ...

(adjust paths and $root as needed)?

author
#2 lore raw

Hi Andrei,

Quoted 1 line · Andrei Borzenkov

What happens if you load the same kernel manually in dom0?

When I do:

sudo /usr/lib/xen-4.4/bin/pygrub -n /dev/myvg/debtest1_xvda

I get:

linux (kernel '<kernel:/boot/vmlinuz-3.16.0-4-amd64>')(ramdisk '<ramdisk:/boot/initrd.img-3.16.0-4-amd64>')(args 'root=UUID=38420e46-6123-477d-ba23-baeba8ac0d59 ro')

(as mentioned, if I boot it with pygrub then it works)

Putting that directly in a Xen guest config file like:

$ sudo kpartx -va /dev/mapper/myvg-debtest1_xvda add map myvg-debtest1_xvda1 (253:29): 0 10483712 linear /dev/mapper/myvg-debtest1_xvda 2048
$ sudo mount /dev/mapper/myvg-debtest1_xvda1 /mnt/xen
$ sudo cp /mnt/xen/boot/vmlinuz-3.16.0-4-amd64 /tmp/kernel
$ sudo cp /mnt/xen/boot/initrd.img-3.16.0-4-amd64 /tmp/initrd
$ cat /etc/xen/debtest1.conf
name       = "debtest1"
memory     = 1024
vcpus      = 2
vif        = [ … ]
kernel     = '/tmp/kernel'
ramdisk    = '/tmp/initrd'
extra      = 'root=UUID=38420e46-6123-477d-ba23-baeba8ac0d59 ro'
disk       = [ "phy:/dev/myvg/debtest1_xvda,xvda,w",
               "phy:/dev/myvg/debtest1_xvdb,xvdb,w",
               "phy:/dev/myvg/debtest1_xvdc,xvdc,w" ]
on_poweroff = "preserve"
on_reboot   = "preserve"
on_crash    = "preserve"

This boots fine.

What also works with the configuration in dom0 as described in previous email:

- Installing grub-xen in guest and chainloading to that

- Installing grub-pc in guest and using "configfile /boot/grub/grub.cfg"

The only thing that I can't get working is "legacy_configfile /boot/grub/menu.lst"

Here is what the config looks like if I interrupt the boot and go to edit it:

set root='(hd0,1)'; set legacy_hdbias='0'
legacy_kernel '/boot/vmlinuz-3.16.0-4-amd64' '/boot/vmlinuz-3.16.0-4-amd64' 'root=UUID=38420e46-6123-477d-ba23-baeba8ac0d59' 'ro'
legacy_initrd '/boot/initrd.img-3.16.0-4-amd64' '/boot/initrd.img-3.16.0-4-amd64'

Cheers,
Andy

author
#3 lore raw

Hello,

Quoted 6 lines · Andy Smith

Here is what the config looks like if I interrupt the boot and go to edit it:

set root='(hd0,1)'; set legacy_hdbias='0'
legacy_kernel '/boot/vmlinuz-3.16.0-4-amd64' '/boot/vmlinuz-3.16.0-4-amd64' 'root=UUID=38420e46-6123-477d-ba23-baeba8ac0d59' 'ro'
legacy_initrd '/boot/initrd.img-3.16.0-4-amd64' '/boot/initrd.img-3.16.0-4-amd64'

Over on the xen-users list, Sarah Newman pointed out that the legacy_initrd line should not have a repeated argument:

    https://lists.xenproject.org/archives/html/xen-users/2017-02/msg00029.html

If I edit away the repetition, so that the config line is:

legacy_initrd '/boot/initrd.img-3.16.0-4-amd64'

then this boots fine.

Should I report this in grub's bugzilla?

Thanks,
Andy

#4 lore raw

11.02.2017 20:19, Andy Smith пишет:

Quoted 13 lines

Hello,

Quoted 6 lines · Andy Smith

Here is what the config looks like if I interrupt the boot and go to edit it:

set root='(hd0,1)'; set legacy_hdbias='0'
legacy_kernel '/boot/vmlinuz-3.16.0-4-amd64' '/boot/vmlinuz-3.16.0-4-amd64' 'root=UUID=38420e46-6123-477d-ba23-baeba8ac0d59' 'ro'
legacy_initrd '/boot/initrd.img-3.16.0-4-amd64' '/boot/initrd.img-3.16.0-4-amd64'

Over on the xen-users list, Sarah Newman pointed out that the legacy_initrd line should not have a repeated argument:

Quoted 8 lines
    https://lists.xenproject.org/archives/html/xen-users/2017-02/msg00029.html

If I edit away the repetition, so that the config line is:

legacy_initrd '/boot/initrd.img-3.16.0-4-amd64'

then this boots fine.

This was explicitly added in commit 9fb175ed9a48102543867f8006842628cc41217c. I do not understand the purpose of this (is there any requirement that multiboot kernel/module gets its name as the first parameter?)

@Vladimir? Either we need to revert this, or add similar handling to legacy_initrd, but I miss why we need it in the first place.

Quoted 2 lines

Should I report this in grub's bugzilla?

Sure. Although I still wonder why it fails. I.e. kernel should simply extract the same initrd content twice, why it causes such effect?

#5 lore raw
Quoted 27 lines · On Sat, 11 Feb 2017, 19:45 Andrei Borzenkov <[email protected]> wrote:

11.02.2017 20:19, Andy Smith пишет:

Quoted 8 lines

Hello,

Quoted 5 lines · Andy Smith

Here is what the config looks like if I interrupt the boot and go to edit it:

set root='(hd0,1)'; set legacy_hdbias='0'
legacy_kernel '/boot/vmlinuz-3.16.0-4-amd64'

'/boot/vmlinuz-3.16.0-4-amd64' 'root=UUID=38420e46-6123-477d-ba23-baeba8ac0d59' 'ro'

Quoted 1 line
Quoted 1 line

legacy_initrd '/boot/initrd.img-3.16.0-4-amd64'

'/boot/initrd.img-3.16.0-4-amd64'

Quoted 5 lines

Over on the xen-users list, Sarah Newman pointed out that the legacy_initrd line should not have a repeated argument:

https://lists.xenproject.org/archives/html/xen-users/2017-02/msg00029.html

Quoted 7 lines

If I edit away the repetition, so that the config line is:

legacy_initrd '/boot/initrd.img-3.16.0-4-amd64'

then this boots fine.

Quoted 8 lines

This was explicitly added in commit 9fb175ed9a48102543867f8006842628cc41217c. I do not understand the purpose of this (is there any requirement that multiboot kernel/module gets its name as the first parameter?)

@Vladimir? Either we need to revert this, or add similar handling to legacy_initrd, but I miss why we need it in the first place.

For multiboot module old grub was passing module file name on module command line, so legacy_configfile should replicate this behaviour. But in Linux case it shouldn't have ended up loading twice. We need additional code in legacy_initrd. Please try the attached patch

Quoted 4 lines
Quoted 3 lines

Should I report this in grub's bugzilla?

Quoted 8 lines

Sure. Although I still wonder why it fails. I.e. kernel should simply extract the same initrd content twice, why it causes such effect?

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

grub-core/commands/legacycfg.c +1 -1
index dd9d9f1..24546bf 100644
@@ -517,7 +517,7 @@ grub_cmd_legacy_initrd (struct grub_command *mycmd __attribute__ ((unused)),
 #endif
 			   );
 
-      return cmd->func (cmd, argc, args);
+      return cmd->func (cmd, argc ? argc - 1 : 0, args + 1);
     }
   if (kernel_type == MULTIBOOT)
     {
#6 lore raw

Actually patch is wrong, I'll correct and send improved version

Quoted 57 lines · On Sat, 11 Feb 2017, 22:07 Vladimir 'phcoder' Serbinenko <[email protected]>…

On Sat, 11 Feb 2017, 19:45 Andrei Borzenkov <[email protected]> wrote:

11.02.2017 20:19, Andy Smith пишет:

Quoted 8 lines

Hello,

Quoted 5 lines · Andy Smith

Here is what the config looks like if I interrupt the boot and go to edit it:

set root='(hd0,1)'; set legacy_hdbias='0'
legacy_kernel '/boot/vmlinuz-3.16.0-4-amd64'

'/boot/vmlinuz-3.16.0-4-amd64' 'root=UUID=38420e46-6123-477d-ba23-baeba8ac0d59' 'ro'

Quoted 1 line
Quoted 1 line

legacy_initrd '/boot/initrd.img-3.16.0-4-amd64'

'/boot/initrd.img-3.16.0-4-amd64'

Quoted 5 lines

Over on the xen-users list, Sarah Newman pointed out that the legacy_initrd line should not have a repeated argument:

https://lists.xenproject.org/archives/html/xen-users/2017-02/msg00029.html

Quoted 7 lines

If I edit away the repetition, so that the config line is:

legacy_initrd '/boot/initrd.img-3.16.0-4-amd64'

then this boots fine.

This was explicitly added in commit 9fb175ed9a48102543867f8006842628cc41217c. I do not understand the purpose of this (is there any requirement that multiboot kernel/module gets its name as the first parameter?)

@Vladimir? Either we need to revert this, or add similar handling to legacy_initrd, but I miss why we need it in the first place.

For multiboot module old grub was passing module file name on module command line, so legacy_configfile should replicate this behaviour. But in Linux case it shouldn't have ended up loading twice. We need additional code in legacy_initrd. Please try the attached patch

Quoted 2 lines

Should I report this in grub's bugzilla?

Sure. Although I still wonder why it fails. I.e. kernel should simply extract the same initrd content twice, why it causes such effect?

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#7 lore raw
In reply to Vladimir 'phcoder' Serbinenko

12.02.2017 00:07, Vladimir 'phcoder' Serbinenko пишет:
...

Quoted 6 lines
Quoted 1 line

For multiboot module old grub was passing module file name on module command line, so legacy_configfile should replicate this behaviour. But in Linux case it shouldn't have ended up loading twice. We need additional code in legacy_initrd. Please try the attached patch

...

grub-core/commands/legacycfg.c grub_cmd_legacy_initrd (struct grub_command *mycmd __attribute__ ((unused)), · line 520

Quoted 12 lines
grub-core/commands/legacycfg.c +1 -1
index dd9d9f1..24546bf 100644
@@ -517,7 +517,7 @@ grub_cmd_legacy_initrd (struct grub_command *mycmd __attribute__ ((unused)),
 #endif
 			   );
 
-      return cmd->func (cmd, argc, args);
+      return cmd->func (cmd, argc ? argc - 1 : 0, args + 1);

If the goal is to be compatible with legacy grub, it is not compatible (nor was) - legacy grub "initrd" ignored all extra arguments to "initrd" command while we attempt to load them as additional initrd components.

Nor did legacy grub attempt to quote command line for multiboot kernel or modules.

Quoted 11 lines
grub-core/commands/legacycfg.c +0 -0
     }
   if (kernel_type == MULTIBOOT)
     {

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#8 lore raw
Quoted 25 lines · On Sun, 12 Feb 2017, 08:06 Andrei Borzenkov <[email protected]> wrote:

12.02.2017 00:07, Vladimir 'phcoder' Serbinenko пишет:
...

Quoted 3 lines
Quoted 1 line

For multiboot module old grub was passing module file name on module command line, so legacy_configfile should replicate this behaviour. But

in

Quoted 3 lines

Linux case it shouldn't have ended up loading twice. We need additional code in legacy_initrd. Please try the attached patch

...

Review

Quoted 3 lines
(quoted diff) +0 -0

b/grub-core/commands/legacycfg.c

grub-core/commands/legacycfg.c grub_cmd_legacy_initrd (struct grub_command *mycmd

Quoted 4 lines

index dd9d9f1..24546bf 100644

grub-core/commands/legacycfg.c +0 -0
@@ -517,7 +517,7 @@ grub_cmd_legacy_initrd (struct grub_command *mycmd

__attribute__ ((unused)),

grub-core/commands/legacycfg.c grub_cmd_legacy_initrd (struct grub_command *mycmd __attribute__ ((unused)), · line 520

Quoted 5 lines
grub-core/commands/legacycfg.c +1 -1
 #endif
                         );
 
-      return cmd->func (cmd, argc, args);
+      return cmd->func (cmd, argc ? argc - 1 : 0, args + 1);
Quoted 7 lines

If the goal is to be compatible with legacy grub, it is not compatible (nor was) - legacy grub "initrd" ignored all extra arguments to "initrd" command while we attempt to load them as additional initrd components.

Nor did legacy grub attempt to quote command line for multiboot kernel or modules.

Agreed on both. That's why I said that previous patch is wrong and I'm working on new one

Quoted 19 lines
Quoted 7 lines
grub-core/commands/legacycfg.c +0 -0
     }
   if (kernel_type == MULTIBOOT)
     {
Quoted 5 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#9 lore raw
Quoted 33 lines · On Sun, Feb 12, 2017, 11:52 Vladimir 'phcoder' Serbinenko <[email protected]>…

On Sun, 12 Feb 2017, 08:06 Andrei Borzenkov <[email protected]> wrote:

12.02.2017 00:07, Vladimir 'phcoder' Serbinenko пишет:
...

Quoted 3 lines
Quoted 1 line

For multiboot module old grub was passing module file name on module command line, so legacy_configfile should replicate this behaviour. But

in

Quoted 3 lines

Linux case it shouldn't have ended up loading twice. We need additional code in legacy_initrd. Please try the attached patch

...

Review

Quoted 3 lines
(quoted diff) +0 -0

b/grub-core/commands/legacycfg.c

grub-core/commands/legacycfg.c grub_cmd_legacy_initrd (struct grub_command *mycmd

Quoted 4 lines

index dd9d9f1..24546bf 100644

grub-core/commands/legacycfg.c +0 -0
@@ -517,7 +517,7 @@ grub_cmd_legacy_initrd (struct grub_command *mycmd

__attribute__ ((unused)),

grub-core/commands/legacycfg.c grub_cmd_legacy_initrd (struct grub_command *mycmd · line 520

Quoted 5 lines
grub-core/commands/legacycfg.c +1 -1
 #endif
                         );
 
-      return cmd->func (cmd, argc, args);
+      return cmd->func (cmd, argc ? argc - 1 : 0, args + 1);

If the goal is to be compatible with legacy grub, it is not compatible (nor was) - legacy grub "initrd" ignored all extra arguments to "initrd" command while we attempt to load them as additional initrd components.

Quoted 6 lines

Nor did legacy grub attempt to quote command line for multiboot kernel or modules.

Agreed on both. That's why I said that previous patch is wrong and I'm working on new one

For first point, see attached patch.
Second point isn't a problem as legacycfg will already split along spaces and hence quoting code will not be triggered.

grub-core/commands/legacycfg.c +0 -0
index dd9d9f1..b32f3c7 100644
@@ -517,7 +517,7 @@ grub_cmd_legacy_initrd (struct grub_command *mycmd

__attribute__ ((unused)),
#endif
);

- return cmd->func (cmd, argc, args);
+ return cmd->func (cmd, argc ? 1 : 0, args);
}
if (kernel_type == MULTIBOOT)
{

#10 lore raw

25.02.2017 02:22, Vladimir 'phcoder' Serbinenko пишет:

Quoted 39 lines
Quoted 36 lines · On Sun, Feb 12, 2017, 11:52 Vladimir 'phcoder' Serbinenko <[email protected]>…

On Sun, 12 Feb 2017, 08:06 Andrei Borzenkov <[email protected]> wrote:

12.02.2017 00:07, Vladimir 'phcoder' Serbinenko пишет:
...

Quoted 3 lines
Quoted 1 line

For multiboot module old grub was passing module file name on module command line, so legacy_configfile should replicate this behaviour. But

in

Quoted 3 lines

Linux case it shouldn't have ended up loading twice. We need additional code in legacy_initrd. Please try the attached patch

...

Review

Quoted 3 lines
(quoted diff) +0 -0

b/grub-core/commands/legacycfg.c

grub-core/commands/legacycfg.c grub_cmd_legacy_initrd (struct grub_command *mycmd

Quoted 4 lines

index dd9d9f1..24546bf 100644

grub-core/commands/legacycfg.c +0 -0
@@ -517,7 +517,7 @@ grub_cmd_legacy_initrd (struct grub_command *mycmd

__attribute__ ((unused)),

grub-core/commands/legacycfg.c grub_cmd_legacy_initrd (struct grub_command *mycmd · line 520

Quoted 5 lines
grub-core/commands/legacycfg.c +1 -1
 #endif
                         );
 
-      return cmd->func (cmd, argc, args);
+      return cmd->func (cmd, argc ? argc - 1 : 0, args + 1);

If the goal is to be compatible with legacy grub, it is not compatible (nor was) - legacy grub "initrd" ignored all extra arguments to "initrd" command while we attempt to load them as additional initrd components.

Nor did legacy grub attempt to quote command line for multiboot kernel or modules.

Quoted 7 lines
Quoted 3 lines

Agreed on both. That's why I said that previous patch is wrong and I'm working on new one

For first point, see attached patch.
Second point isn't a problem as legacycfg will already split along spaces and hence quoting code will not be triggered.

It will.

      while (*c)
        {
          if (*c == '\\' || *c == '\'' || *c == '"')
            *buf++ = '\\';
          *buf++ = *c;
          c++;
        }

In particular, this is a problem with Linux which does not interpret these quotes at all (it only supports " .... " without any way to escape nested `"'). That's something for post 2.02 now, but I still would like to know what was the reason for this code in the first place.

Quoted 14 lines
grub-core/commands/legacycfg.c +1 -1
index dd9d9f1..b32f3c7 100644
@@ -517,7 +517,7 @@ grub_cmd_legacy_initrd (struct grub_command *mycmd
 __attribute__ ((unused)),
 #endif
 );
 
- return cmd->func (cmd, argc, args);
+ return cmd->func (cmd, argc ? 1 : 0, args);
 }
 if (kernel_type == MULTIBOOT)
Quoted 2 lines

{

Looks OK as stop gap. @Andy, could you test it?

I still do not understand why initrd is parsed as TYPE_FILE_NO_CONSUME, nor why we handle multiboot kernel in legacy_initrd in the first place. Legacy grub only supported Linux kernel with initrd command.

  switch (kernel_type)
    {
    case KERNEL_TYPE_LINUX:
    case KERNEL_TYPE_BIG_LINUX:
      if (! load_initrd (arg))
        return 1;
      break;
    default:
      errnum = ERR_NEED_LX_KERNEL;
      return 1;
    }

Although this probably does not really matter now.

author
#11 lore raw

Hi Andrei, Vladimir,

Quoted 10 lines · Andrei Borzenkov

25.02.2017 02:22, Vladimir 'phcoder' Serbinenko пишет:

Quoted 9 lines
grub-core/commands/legacycfg.c +0 -0
index dd9d9f1..b32f3c7 100644
@@ -517,7 +517,7 @@ grub_cmd_legacy_initrd (struct grub_command *mycmd
 __attribute__ ((unused)),
 #endif
 );
 
Quoted 8 lines
Quoted 6 lines
grub-core/commands/legacycfg.c +1 -1
- return cmd->func (cmd, argc, args);
+ return cmd->func (cmd, argc ? 1 : 0, args);
 }
 if (kernel_type == MULTIBOOT)

{

Looks OK as stop gap. @Andy, could you test it?

Yep, this works also.

Cheers,
Andy