Skip to content

Commit

Permalink
Fixed zipl bootloader setup
Browse files Browse the repository at this point in the history
On zipl we manually move the kernel and initrd file to the
zipl boot path because symlinks can't be read. That move
operation used the wrong filenames and was broken since
baseCreateCommonKernelFile is only used in the legacy
custom kiwi boot images but not in the dracut case.
  • Loading branch information
schaefi committed Jul 1, 2019
1 parent 0092df5 commit efeb727
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 17 deletions.
4 changes: 2 additions & 2 deletions kiwi/bootloader/config/grub2.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ def setup_sysconfig_bootloader(self):
sysconfig_bootloader.write()

def setup_disk_image_config(
self, boot_uuid, root_uuid, hypervisor='xen.gz', kernel='linux.vmx',
initrd='initrd.vmx', boot_options=''
self, boot_uuid, root_uuid, hypervisor='xen.gz',
kernel=None, initrd=None, boot_options=''
):
"""
Create the grub.cfg in memory from a template suitable to boot
Expand Down
17 changes: 14 additions & 3 deletions kiwi/bootloader/config/zipl.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import platform
import re
import os

# project
from kiwi.bootloader.config.base import BootLoaderConfigBase
Expand Down Expand Up @@ -103,15 +104,25 @@ def write(self):
Command.run(
[
'mv',
self.root_dir + '/boot/initrd.vmx',
self.root_dir + '/boot/linux.vmx',
os.sep.join(
[
self.root_dir, 'boot',
os.readlink(self.root_dir + '/boot/initrd')
]
),
os.sep.join(
[
self.root_dir, 'boot',
os.readlink(self.root_dir + '/boot/image')
]
),
self._get_zipl_boot_path()
]
)

def setup_disk_image_config(
self, boot_uuid=None, root_uuid=None, hypervisor=None,
kernel='linux.vmx', initrd='initrd.vmx', boot_options=''
kernel=None, initrd=None, boot_options=''
):
"""
Create the zipl config in memory from a template suitable to
Expand Down
7 changes: 4 additions & 3 deletions test/unit/bootloader_config_grub2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,13 +422,14 @@ def test_setup_disk_image_config_custom_boot_options(self):
return_value=template
)
self.bootloader.setup_disk_image_config(
boot_uuid='boot_uuid', root_uuid='root_uuid', boot_options='foo'
kernel='kernel', initrd='initrd', boot_uuid='boot_uuid',
root_uuid='root_uuid', boot_options='foo'
)
template.substitute.assert_called_once_with(
{
'title': 'Bob',
'boot_directory_name': 'grub2',
'kernel_file': 'linux.vmx',
'kernel_file': 'kernel',
'failsafe_boot_options': 'splash foo ide=nodma apm=off '
'noresume edd=off nomodeset 3 foo',
'default_boot': '0',
Expand All @@ -437,7 +438,7 @@ def test_setup_disk_image_config_custom_boot_options(self):
'gfxmode': '800x600',
'bootpath': '/',
'search_params': '--fs-uuid --set=root boot_uuid',
'initrd_file': 'initrd.vmx',
'initrd_file': 'initrd',
'theme': None
}
)
Expand Down
29 changes: 20 additions & 9 deletions test/unit/bootloader_config_zipl_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,16 @@ def test_post_init_no_target_base(self, mock_machine):

@patch_open
@patch('os.path.exists')
@patch('os.readlink')
@patch('kiwi.bootloader.config.zipl.Path.create')
@patch('kiwi.bootloader.config.zipl.Command.run')
def test_write(self, mock_command, mock_path, mock_exists, mock_open):
def test_write(
self, mock_command, mock_path, mock_readlink, mock_exists, mock_open
):
mock_readlink.side_effect = [
'initrd_readlink_name',
'kernel_readlink_name'
]
mock_exists.return_value = True
context_manager_mock = mock.Mock()
mock_open.return_value = context_manager_mock
Expand All @@ -115,8 +122,8 @@ def test_write(self, mock_command, mock_path, mock_exists, mock_open):
mock_command.assert_called_once_with(
[
'mv',
'root_dir/boot/initrd.vmx',
'root_dir/boot/linux.vmx',
'root_dir/boot/initrd_readlink_name',
'root_dir/boot/kernel_readlink_name',
'root_dir/boot/zipl'
]
)
Expand Down Expand Up @@ -205,16 +212,18 @@ def side_effect(arg):

mock_command.side_effect = side_effect

self.bootloader.setup_disk_image_config(boot_options='foo')
self.bootloader.setup_disk_image_config(
kernel='kernel', initrd='initrd', boot_options='foo'
)

self.zipl.get_template.assert_called_once_with(True)
self.template.substitute.assert_called_once_with(
{
'blocksize': '4096',
'initrd_file': 'initrd.vmx',
'initrd_file': 'initrd',
'offset': 168,
'device': '/dev/loop0',
'kernel_file': 'linux.vmx',
'kernel_file': 'kernel',
'title': 'image-name_(_OEM_)',
'geometry': '10017,15,12',
'boot_options': 'cmdline foo',
Expand Down Expand Up @@ -259,16 +268,18 @@ def side_effect(arg):

mock_command.side_effect = side_effect

self.bootloader.setup_disk_image_config()
self.bootloader.setup_disk_image_config(
kernel='kernel', initrd='initrd'
)

self.zipl.get_template.assert_called_once_with(True)
self.template.substitute.assert_called_once_with(
{
'blocksize': '4096',
'initrd_file': 'initrd.vmx',
'initrd_file': 'initrd',
'offset': 129024,
'device': '/dev/loop0',
'kernel_file': 'linux.vmx',
'kernel_file': 'kernel',
'title': 'image-name_(_OEM_)',
'geometry': '242251,256,63',
'boot_options': 'cmdline ',
Expand Down

0 comments on commit efeb727

Please sign in to comment.