Gregory P. Smith | 2 Nov 2010 01:35
Picon
Favicon

Re: [PATCH 1/6] client/bin/kernel.py: default kernel arguments shall be kept

We're running into an unfortunate side effect of this change.


boottool --update-kernel --args=X is buggy when used with lilo and the lilo.conf does not already have an append= section below that kernel's image= line.

What I'm doing as a hack to work around this is the following as the boottool perl code is pretty gross and much less easy to fix for this:


--- client/bin/kernel.py.before 2010-11-01 16:49:45.371159000 -0700
+++ client/bin/kernel.py        2010-11-01 17:25:30.786743000 -0700
<at> <at> -59,13 +59,17 <at> <at>
         else:
             arglist.append(arg)
 
-    # add the kernel entry. it will keep all arguments from the default entry
-    bootloader.add_kernel(image, tag, initrd=initrd, root=root)
+    # Add the kernel entry. it will keep all arguments from the default entry.
+    # args='_dummy_' is used to workaround a boottool limitation of not being
+    # able to add arguments to a kernel that does not already have any of its
+    # own by way of its own append= section below the image= line in lilo.conf.
+    bootloader.add_kernel(image, tag, initrd=initrd, root=root, args='_dummy_')
     # Now, for each argument in arglist, try to add it to the kernel that was
     # just added. In each step, if the arg already existed on the args string,
     # that particular arg will be skipped
     for a in arglist:
         bootloader.add_args(kernel=tag, args=a)
+    bootloader.remove_args(kernel=tag, args='_dummy_')
 
 
 class BootableKernel(object):
--- client/bin/kernel_unittest.py.before        2010-11-01 17:10:15.043835000 -0700
+++ client/bin/kernel_unittest.py       2010-11-01 17:25:54.656370000 -0700
<at> <at> -20,10 +20,11 <at> <at>
         # record
         bootloader.remove_kernel.expect_call(tag)
         bootloader.add_kernel.expect_call(image, tag, initrd=initrd,
-                                          root=bootloader_root)
+                                          args='_dummy_', root=bootloader_root)
 
         for a in bootloader_args.split():
             bootloader.add_args.expect_call(kernel=tag, args=a)
+        bootloader.remove_args.expect_call(kernel=tag, args='_dummy_')
 
         # run and check
         kernel._add_kernel_to_bootloader(



On Mon, Oct 18, 2010 at 10:29 AM, Lucas Meneghel Rodrigues <lmr <at> redhat.com> wrote:
When adding a new kernel to bootload we want the arguments of
the default entry to be kept in the new entry, otherwise that
entry might not boot (example, if we disregard LVM parameters
and the root is on an LVM volume, the entry won't boot).

So, instead of setting the arguments while the kernel entry
is being created (doing this with boottool will completely
disregard any arguments of the default entry), create the
new entry *then* add the additional arguments, one by one.
In every new addition, if the arg is already on the arg list,
the arg won't be added, therefore avoiding duplicate args.

Changes from v1:
- Fix kernel_unittest.py

Signed-off-by: Lucas Meneghel Rodrigues <lmr <at> redhat.com>
---
 client/bin/kernel.py          |   10 +++++++---
 client/bin/kernel_unittest.py |    4 +++-
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/client/bin/kernel.py b/client/bin/kernel.py
index 4b333ea..c71efc2 100644
--- a/client/bin/kernel.py
+++ b/client/bin/kernel.py
<at> <at> -59,9 +59,13 <at> <at> def _add_kernel_to_bootloader(bootloader, base_args, tag, args, image, initrd):
        else:
            arglist.append(arg)

-    # add the kernel entry
-    bootloader.add_kernel(image, tag, initrd=initrd, args=' '.join(arglist),
-                          root=root)
+    # add the kernel entry. it will keep all arguments from the default entry
+    bootloader.add_kernel(image, tag, initrd=initrd, root=root)
+    # Now, for each argument in arglist, try to add it to the kernel that was
+    # just added. In each step, if the arg already existed on the args string,
+    # that particular arg will be skipped
+    for a in arglist:
+        bootloader.add_args(kernel=tag, args=a)


 class BootableKernel(object):
diff --git a/client/bin/kernel_unittest.py b/client/bin/kernel_unittest.py
index fe40e6a..3adba6c 100755
--- a/client/bin/kernel_unittest.py
+++ b/client/bin/kernel_unittest.py
<at> <at> -18,9 +18,11 <at> <at> class TestAddKernelToBootLoader(unittest.TestCase):
        # record
        bootloader.remove_kernel.expect_call(tag)
        bootloader.add_kernel.expect_call(image, tag, initrd=initrd,
-                                          args=bootloader_args,
                                          root=bootloader_root)

+        for a in bootloader_args.split():
+            bootloader.add_args.expect_call(kernel=tag, args=a)
+
        # run and check
        kernel._add_kernel_to_bootloader(bootloader, base_args, tag, args,
                                         image, initrd)
--
1.7.2.3

_______________________________________________
Autotest mailing list
Autotest <at> test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

_______________________________________________
Autotest mailing list
Autotest <at> test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
Lucas Meneghel Rodrigues | 3 Nov 2010 14:44
Picon
Favicon
Gravatar

Re: [PATCH 1/6] client/bin/kernel.py: default kernel arguments shall be kept

On Mon, 2010-11-01 at 17:35 -0700, Gregory P. Smith wrote:
> We're running into an unfortunate side effect of this change.
> 
> 
> boottool --update-kernel --args=X is buggy when used with lilo and the
> lilo.conf does not already have an append= section below that kernel's
> image= line.
> 
> 
> What I'm doing as a hack to work around this is the following as the
> boottool perl code is pretty gross and much less easy to fix for this:
> 

Yep, it seems like more and more we need a boottool2, to handle grub2
and get rid of this legacy code. Will try to allocate some time to work
on such a project.

Meanwhile, applied your change:

http://autotest.kernel.org/changeset/4902

Thanks Greg,

Lucas

Gmane