Add ldlinux.c32 to boot ISO for virtual media
To create a boot ISO for netboot with virtual media boot, ldlinux.c32 is required for syslinux 5.00 or later. This patch copies ldlinux.c32 in building ISO from general paths by default. A new configuration parameter [DEFAULT]/ldlinux_c32 is added for another distribution or feature changes. Change-Id: I55229f0ab37e657b7668dd4fe402fe6b5a6cda40 Closes-Bug: #1694645
This commit is contained in:
parent
edd0b16ac7
commit
dd264ac909
@ -314,6 +314,12 @@
|
||||
# Template file for grub configuration file. (string value)
|
||||
#grub_config_template = $pybasedir/common/grub_conf.template
|
||||
|
||||
# Path to ldlinux.c32 file. This file is required for syslinux
|
||||
# 5.0 or later. If not specified, the file is searched in
|
||||
# general paths, "/usr/lib/syslinux/modules/bios/ldlinux.c32"
|
||||
# and "/usr/share/syslinux/ldlinux.c32". (string value)
|
||||
#ldlinux_c32 = <None>
|
||||
|
||||
# Run image downloads and raw format conversions in parallel.
|
||||
# (boolean value)
|
||||
#parallel_image_downloads = false
|
||||
|
@ -184,6 +184,9 @@ def create_isolinux_image_for_bios(output_file, kernel, ramdisk,
|
||||
"""
|
||||
ISOLINUX_BIN = 'isolinux/isolinux.bin'
|
||||
ISOLINUX_CFG = 'isolinux/isolinux.cfg'
|
||||
LDLINUX_SRC_DIRS = ['/usr/lib/syslinux/modules/bios',
|
||||
'/usr/share/syslinux']
|
||||
LDLINUX_BIN = 'isolinux/ldlinux.c32'
|
||||
|
||||
options = {'kernel': '/vmlinuz', 'ramdisk': '/initrd'}
|
||||
|
||||
@ -193,6 +196,20 @@ def create_isolinux_image_for_bios(output_file, kernel, ramdisk,
|
||||
ramdisk: 'initrd',
|
||||
CONF.isolinux_bin: ISOLINUX_BIN,
|
||||
}
|
||||
|
||||
# ldlinux.c32 is required for syslinux 5.0 or later.
|
||||
if CONF.ldlinux_c32:
|
||||
ldlinux_src = CONF.ldlinux_c32
|
||||
else:
|
||||
for directory in LDLINUX_SRC_DIRS:
|
||||
ldlinux_src = os.path.join(directory, 'ldlinux.c32')
|
||||
if os.path.isfile(ldlinux_src):
|
||||
break
|
||||
else:
|
||||
ldlinux_src = None
|
||||
if ldlinux_src:
|
||||
files_info[ldlinux_src] = LDLINUX_BIN
|
||||
|
||||
try:
|
||||
_create_root_fs(tmpdir, files_info)
|
||||
except (OSError, IOError) as e:
|
||||
|
@ -199,6 +199,12 @@ image_opts = [
|
||||
default=os.path.join('$pybasedir',
|
||||
'common/grub_conf.template'),
|
||||
help=_('Template file for grub configuration file.')),
|
||||
cfg.StrOpt('ldlinux_c32',
|
||||
help=_('Path to ldlinux.c32 file. This file is required for '
|
||||
'syslinux 5.0 or later. If not specified, the file is '
|
||||
'searched in general paths, '
|
||||
'"/usr/lib/syslinux/modules/bios/ldlinux.c32" and '
|
||||
'"/usr/share/syslinux/ldlinux.c32".')),
|
||||
]
|
||||
|
||||
img_cache_opts = [
|
||||
|
@ -549,9 +549,9 @@ class FsImageTestCase(base.TestCase):
|
||||
@mock.patch.object(utils, 'tempdir', autospec=True)
|
||||
@mock.patch.object(utils, 'execute', autospec=True)
|
||||
@mock.patch.object(images, '_generate_cfg', autospec=True)
|
||||
def test_create_isolinux_image_for_bios(
|
||||
def _test_create_isolinux_image_for_bios(
|
||||
self, gen_cfg_mock, execute_mock, tempdir_mock,
|
||||
write_to_file_mock, create_root_fs_mock):
|
||||
write_to_file_mock, create_root_fs_mock, ldlinux_path=None):
|
||||
|
||||
mock_file_handle = mock.MagicMock(spec=file)
|
||||
mock_file_handle.__enter__.return_value = 'tmpdir'
|
||||
@ -575,6 +575,8 @@ class FsImageTestCase(base.TestCase):
|
||||
'path/to/ramdisk': 'initrd',
|
||||
CONF.isolinux_bin: 'isolinux/isolinux.bin'
|
||||
}
|
||||
if ldlinux_path:
|
||||
files_info[ldlinux_path] = 'isolinux/ldlinux.c32'
|
||||
create_root_fs_mock.assert_called_once_with('tmpdir', files_info)
|
||||
gen_cfg_mock.assert_called_once_with(params,
|
||||
CONF.isolinux_config_template,
|
||||
@ -587,6 +589,22 @@ class FsImageTestCase(base.TestCase):
|
||||
'4', '-boot-info-table', '-b', 'isolinux/isolinux.bin',
|
||||
'-o', 'tgt_file', 'tmpdir')
|
||||
|
||||
@mock.patch.object(os.path, 'isfile', autspec=True)
|
||||
def test_create_isolinux_image_for_bios(self, mock_isfile):
|
||||
mock_isfile.return_value = False
|
||||
self._test_create_isolinux_image_for_bios()
|
||||
|
||||
def test_create_isolinux_image_for_bios_conf_ldlinux(self):
|
||||
CONF.set_override('ldlinux_c32', 'path/to/ldlinux.c32')
|
||||
self._test_create_isolinux_image_for_bios(
|
||||
ldlinux_path='path/to/ldlinux.c32')
|
||||
|
||||
@mock.patch.object(os.path, 'isfile', autspec=True)
|
||||
def test_create_isolinux_image_for_bios_default_ldlinux(self, mock_isfile):
|
||||
mock_isfile.side_effect = [False, True]
|
||||
self._test_create_isolinux_image_for_bios(
|
||||
ldlinux_path='/usr/share/syslinux/ldlinux.c32')
|
||||
|
||||
@mock.patch.object(images, '_umount_without_raise', autospec=True)
|
||||
@mock.patch.object(images, '_create_root_fs', autospec=True)
|
||||
@mock.patch.object(utils, 'tempdir', autospec=True)
|
||||
|
14
releasenotes/notes/bug-1694645-57289200e35bd883.yaml
Normal file
14
releasenotes/notes/bug-1694645-57289200e35bd883.yaml
Normal file
@ -0,0 +1,14 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fix a bug that netboot is unavailable with virtual media boot in an
|
||||
environment using syslinux 5.00 or later such as Ubuntu 16.04. This is
|
||||
caused by a change in syslinux that ldlinux.c32 is required for creating
|
||||
boot ISO. This file is searched in the following general paths:
|
||||
|
||||
* /usr/lib/syslinux/modules/bios/ldlinux.c32
|
||||
* /usr/share/syslinux/ldlinux.c32
|
||||
|
||||
This path can be set with the configuration parameter
|
||||
``[DEFAULT]/ldlinux_c32`` for another distribution or for a case where the
|
||||
path is changed with future update.
|
Loading…
Reference in New Issue
Block a user