Bug#755256: [PATCH] grub-install: Include all decompressor modules in pvxen core image.

2014-11-30 Thread Andrei Borzenkov
В Fri, 28 Nov 2014 17:25:55 +
Ian Campbell i...@hellion.org.uk пишет:

 On Fri, 2014-11-28 at 20:09 +0300, Andrei Borzenkov wrote:
  В Fri, 28 Nov 2014 08:33:34 +
  Ian Campbell i...@hellion.org.uk пишет:
  
   From: Ian Campbell i...@debian.org
   
   This avoids needing to update all the native update-grub stanzas to also 
   probe
   for and arrange to load the relevant decompressor, which would be 
   wasteful on
   native boots.
   
  
  Could you give some more details why you need it?
 
 In order to boot a Linux kernel under Xen grub needs to extract the ELF
 file from the bzImage payload, which is compressed.
 
 The compression algo is a kernel compile time option, gz and xz are the
 most probably ones today.
 

Not directly related but I this comment in Makefile draw my attention:

# Note that the bytes added by size_append will make the xz tool think that
# the file is corrupt. This is expected.

We probably never read vmlinuz to the end anyway, but I wonder if it
could be an issue.

   +push_all_decompressor_modules(void)
   +{
   +  grub_install_push_module (gzio);
   +  grub_install_push_module (xzio);
   +  grub_install_push_module (lzopio);
   +}
   +
  
  It is not enough. Some of them need another modules that are autoloaded
  by normal.
 
 autoloading should work, I think.
 

OK, so you need it post-normal. core.img is really about getting access
to /boot/grub; anything else can be done from within grub.cfg. If you
do not want to load other filters unconditionally, just use

if [ x$grub_platform = xxen ]; then
  insmod xzio
fi

But as far as I understand, CONFIG_KERNEL_XZ is not really dependent on
Xen; so we may want to either load them for real hardware as well or -
better - extend grub-file to check for compression method.

 But if not -- how can one determine which modules are required and/or
 arrange for them to be added automatically?
 
  
   +static void
probe_mods (grub_disk_t disk)
{
  grub_partition_t part;
   @@ -1228,6 +1236,23 @@ main (int argc, char *argv[])
 }
}

   +
   +  switch (platform)
   +{
   +case GRUB_INSTALL_PLATFORM_I386_XEN:
   +case GRUB_INSTALL_PLATFORM_X86_64_XEN:
   +  /* When booting a Xen PV kernel grub may need to decompress the
   +   * kernel which may use a variety of algorithmns. Since we try
   +   * to reuse the native grub.cfg files rather than trying to
   +   * insmod the relevant decompressors on the fly we build them
   +   * into the core image. This means we avoid needlessly loading
   +   * modules on native. */
   +  push_all_decompressor_modules();
   +  break;
   +default:
   +  break;
   +}
   +
  grub_install_copy_files (grub_install_source_directory,
grubdir, platform);

  
  
 
 


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#755256: [PATCH] grub-install: Include all decompressor modules in pvxen core image.

2014-11-30 Thread Ian Campbell
On Sun, 2014-11-30 at 11:51 +, Ian Campbell wrote:
 On Sun, 2014-11-30 at 14:31 +0300, Andrei Borzenkov wrote:
[...]
  We probably never read vmlinuz to the end anyway, but I wonder if it
  could be an issue.
 
 I've no idea. I don't see that comment anywhere in either Linux nor Grub
 codebase though.

NM, I found it in scripts/Makefile.lib...

Doesn't seem to matter in practice though.

Ian.


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#755256: [PATCH] grub-install: Include all decompressor modules in pvxen core image.

2014-11-30 Thread Ian Campbell
On Sun, 2014-11-30 at 14:31 +0300, Andrei Borzenkov wrote:
 В Fri, 28 Nov 2014 17:25:55 +
 Ian Campbell i...@hellion.org.uk пишет:
 
  On Fri, 2014-11-28 at 20:09 +0300, Andrei Borzenkov wrote:
   В Fri, 28 Nov 2014 08:33:34 +
   Ian Campbell i...@hellion.org.uk пишет:
   
From: Ian Campbell i...@debian.org

This avoids needing to update all the native update-grub stanzas to 
also probe
for and arrange to load the relevant decompressor, which would be 
wasteful on
native boots.

   
   Could you give some more details why you need it?
  
  In order to boot a Linux kernel under Xen grub needs to extract the ELF
  file from the bzImage payload, which is compressed.
  
  The compression algo is a kernel compile time option, gz and xz are the
  most probably ones today.
  
 
 Not directly related but I this comment in Makefile draw my attention:
 
 # Note that the bytes added by size_append will make the xz tool think that
 # the file is corrupt. This is expected.
 
 We probably never read vmlinuz to the end anyway, but I wonder if it
 could be an issue.

I've no idea. I don't see that comment anywhere in either Linux nor Grub
codebase though. I do know that insmod xzio makes grub capable of
booting the Debian kernel.

+push_all_decompressor_modules(void)
+{
+  grub_install_push_module (gzio);
+  grub_install_push_module (xzio);
+  grub_install_push_module (lzopio);
+}
+
   
   It is not enough. Some of them need another modules that are autoloaded
   by normal.
  
  autoloading should work, I think.
  
 
 OK, so you need it post-normal. core.img is really about getting access
 to /boot/grub; anything else can be done from within grub.cfg. If you
 do not want to load other filters unconditionally, just use
 
 if [ x$grub_platform = xxen ]; then
   insmod xzio
 fi

I think that could work. Is adding Xen specific stuff to grub.cfg the
preferred way to do this sort of thing then?

 But as far as I understand, CONFIG_KERNEL_XZ is not really dependent on
 Xen; so we may want to either load them for real hardware as well or -
 better - extend grub-file to check for compression method.

On native the bootloader has no reason to decompress the Linux bzImage
payload, the kernel itself can do so. AFAIK decompression is only need
for Xen (and for certain userspace tools like crash and other debuggers,
but they aren't relevant here).

  But if not -- how can one determine which modules are required and/or
  arrange for them to be added automatically?

You'd have to peer into the kernel image, use the bzImage header fields
to locate the payload and then do magic number probing to figure out
which compression algorithm is used.

Ian.


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#755256: [PATCH] grub-install: Include all decompressor modules in pvxen core image.

2014-11-30 Thread Ian Campbell
On Sun, 2014-11-30 at 11:51 +, Ian Campbell wrote:
 On Sun, 2014-11-30 at 14:31 +0300, Andrei Borzenkov wrote:
  if [ x$grub_platform = xxen ]; then
insmod xzio
  fi
 
 I think that could work.

Indeed it does, so how about this instead of the patch at the start of
the thread?

From f4199776eca80dfad4e9378a01ddb5866face3d7 Mon Sep 17 00:00:00 2001
From: Ian Campbell i...@debian.org
Date: Sun, 30 Nov 2014 12:12:52 +
Subject: [PATCH] Arrange to insmod xzio when booting a kernel as a Xen guest

This is needed in case the Linux kernel is compiled with CONFIG_KERNEL_XZ
rather than CONFIG_KERNEL_GZ (gzio is already loaded by grub.cfg).

Signed-off-by: Ian Campbell i...@debian.org

Patch-Name: insmod-xzio-on-xen.patch
---
 util/grub.d/10_linux.in | 1 +
 1 file changed, 1 insertion(+)

diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index 79fa03a..86e35f2 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -150,6 +150,7 @@ linux_entry ()
   fi
 
   echoinsmod gzio | sed s/^/$submenu_indentation/
+  echoif [ x\$grub_platform = xxen ]; then insmod xzio; insmod 
lzopio; fi | sed s/^/$submenu_indentation/
 
   if [ x$dirname = x/ ]; then
 if [ -z ${prepare_root_cache} ]; then
-- 
2.1.3


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#755256: [PATCH] grub-install: Include all decompressor modules in pvxen core image.

2014-11-28 Thread Ian Campbell
From: Ian Campbell i...@debian.org

This avoids needing to update all the native update-grub stanzas to also probe
for and arrange to load the relevant decompressor, which would be wasteful on
native boots.

Signed-off-by: Ian Campbell i...@debian.org
---
 util/grub-install.c | 25 +
 1 file changed, 25 insertions(+)

diff --git a/util/grub-install.c b/util/grub-install.c
index 7a7734e..6ad5afb 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -422,6 +422,14 @@ push_cryptodisk_module (const char *mod, void *data 
__attribute__ ((unused)))
 }
 
 static void
+push_all_decompressor_modules(void)
+{
+  grub_install_push_module (gzio);
+  grub_install_push_module (xzio);
+  grub_install_push_module (lzopio);
+}
+
+static void
 probe_mods (grub_disk_t disk)
 {
   grub_partition_t part;
@@ -1228,6 +1236,23 @@ main (int argc, char *argv[])
}
 }
 
+
+  switch (platform)
+{
+case GRUB_INSTALL_PLATFORM_I386_XEN:
+case GRUB_INSTALL_PLATFORM_X86_64_XEN:
+  /* When booting a Xen PV kernel grub may need to decompress the
+   * kernel which may use a variety of algorithmns. Since we try
+   * to reuse the native grub.cfg files rather than trying to
+   * insmod the relevant decompressors on the fly we build them
+   * into the core image. This means we avoid needlessly loading
+   * modules on native. */
+  push_all_decompressor_modules();
+  break;
+default:
+  break;
+}
+
   grub_install_copy_files (grub_install_source_directory,
   grubdir, platform);
 
-- 
2.1.3


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#755256: [PATCH] grub-install: Include all decompressor modules in pvxen core image.

2014-11-28 Thread Andrei Borzenkov
В Fri, 28 Nov 2014 08:33:34 +
Ian Campbell i...@hellion.org.uk пишет:

 From: Ian Campbell i...@debian.org
 
 This avoids needing to update all the native update-grub stanzas to also probe
 for and arrange to load the relevant decompressor, which would be wasteful on
 native boots.
 

Could you give some more details why you need it?

 Signed-off-by: Ian Campbell i...@debian.org
 ---
  util/grub-install.c | 25 +
  1 file changed, 25 insertions(+)
 
 diff --git a/util/grub-install.c b/util/grub-install.c
 index 7a7734e..6ad5afb 100644
 --- a/util/grub-install.c
 +++ b/util/grub-install.c
 @@ -422,6 +422,14 @@ push_cryptodisk_module (const char *mod, void *data 
 __attribute__ ((unused)))
  }
  
  static void
 +push_all_decompressor_modules(void)
 +{
 +  grub_install_push_module (gzio);
 +  grub_install_push_module (xzio);
 +  grub_install_push_module (lzopio);
 +}
 +

It is not enough. Some of them need another modules that are autoloaded
by normal.

 +static void
  probe_mods (grub_disk_t disk)
  {
grub_partition_t part;
 @@ -1228,6 +1236,23 @@ main (int argc, char *argv[])
   }
  }
  
 +
 +  switch (platform)
 +{
 +case GRUB_INSTALL_PLATFORM_I386_XEN:
 +case GRUB_INSTALL_PLATFORM_X86_64_XEN:
 +  /* When booting a Xen PV kernel grub may need to decompress the
 +   * kernel which may use a variety of algorithmns. Since we try
 +   * to reuse the native grub.cfg files rather than trying to
 +   * insmod the relevant decompressors on the fly we build them
 +   * into the core image. This means we avoid needlessly loading
 +   * modules on native. */
 +  push_all_decompressor_modules();
 +  break;
 +default:
 +  break;
 +}
 +
grub_install_copy_files (grub_install_source_directory,
  grubdir, platform);
  


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#755256: [PATCH] grub-install: Include all decompressor modules in pvxen core image.

2014-11-28 Thread Ian Campbell
On Fri, 2014-11-28 at 20:09 +0300, Andrei Borzenkov wrote:
 В Fri, 28 Nov 2014 08:33:34 +
 Ian Campbell i...@hellion.org.uk пишет:
 
  From: Ian Campbell i...@debian.org
  
  This avoids needing to update all the native update-grub stanzas to also 
  probe
  for and arrange to load the relevant decompressor, which would be wasteful 
  on
  native boots.
  
 
 Could you give some more details why you need it?

In order to boot a Linux kernel under Xen grub needs to extract the ELF
file from the bzImage payload, which is compressed.

The compression algo is a kernel compile time option, gz and xz are the
most probably ones today.

  +push_all_decompressor_modules(void)
  +{
  +  grub_install_push_module (gzio);
  +  grub_install_push_module (xzio);
  +  grub_install_push_module (lzopio);
  +}
  +
 
 It is not enough. Some of them need another modules that are autoloaded
 by normal.

autoloading should work, I think.

But if not -- how can one determine which modules are required and/or
arrange for them to be added automatically?

 
  +static void
   probe_mods (grub_disk_t disk)
   {
 grub_partition_t part;
  @@ -1228,6 +1236,23 @@ main (int argc, char *argv[])
  }
   }
   
  +
  +  switch (platform)
  +{
  +case GRUB_INSTALL_PLATFORM_I386_XEN:
  +case GRUB_INSTALL_PLATFORM_X86_64_XEN:
  +  /* When booting a Xen PV kernel grub may need to decompress the
  +   * kernel which may use a variety of algorithmns. Since we try
  +   * to reuse the native grub.cfg files rather than trying to
  +   * insmod the relevant decompressors on the fly we build them
  +   * into the core image. This means we avoid needlessly loading
  +   * modules on native. */
  +  push_all_decompressor_modules();
  +  break;
  +default:
  +  break;
  +}
  +
 grub_install_copy_files (grub_install_source_directory,
 grubdir, platform);
   
 
 


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org