Merge pull request #1326 from dbungert/boot-plan-no-pgs

boot: handle small disk case
This commit is contained in:
Dan Bungert 2022-06-22 07:58:54 -06:00 committed by GitHub
commit 1bf5ddcf0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -154,6 +154,7 @@ def get_boot_device_plan_bios(device) -> Optional[MakeBootDevicePlan]:
if device.ptable == 'msdos':
return attr_plan
pgs = gaps.parts_and_gaps(device)
if len(pgs) > 0:
if isinstance(pgs[0], Partition) and pgs[0].flag == "bios_grub":
return attr_plan

View File

@ -457,6 +457,14 @@ class TestFilesystemManipulator(unittest.TestCase):
preserve=True)
self.assertFalse(boot.can_be_boot_device(disk))
@parameterized.expand([(1,), (2,)])
def test_no_add_boot_BIOS_gpt_teeny_disk(self, version):
# Showed up in VM testing - the ISO created cloud-localds shows up as a
# potential install target, and weird things happen.
manipulator = make_manipulator(Bootloader.BIOS, version)
disk = make_disk(manipulator.model, ptable='gpt', size=1 << 20)
self.assertFalse(boot.can_be_boot_device(disk))
@parameterized.expand([(1,), (2,)])
def test_add_boot_BIOS_msdos(self, version):
manipulator = make_manipulator(Bootloader.BIOS, version)