osdict: firmware handling tweaks
* Check it for test:/// URI too * Move the whole logic into osdict.requires_firmware_efi * Wrap it all in an exception handler the final API breaks us * Add some coverage exclusions since this is currently untestable Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
5d74ca7621
commit
5640e9be5b
|
@ -522,16 +522,13 @@ class Guest(XMLBuilder):
|
|||
arm+machvirt prefers UEFI since it's required for traditional
|
||||
install methods
|
||||
"""
|
||||
if self.os.is_x86() and self.conn.is_qemu():
|
||||
if (self.os.is_x86() and
|
||||
(self.conn.is_qemu() or self.conn.is_test())):
|
||||
# If OS has dropped support for 'bios', we have no
|
||||
# choice but to use EFI.
|
||||
# For other OS still prefer BIOS since it is faster
|
||||
# and doesn't break QEMU internal snapshots
|
||||
has_efi = self.osinfo.supports_firmware_efi(self.os.arch)
|
||||
has_bios = self.osinfo.supports_firmware_bios(self.os.arch)
|
||||
log.debug("Guest osinfo firmware has_efi=%d has_bios=%d",
|
||||
has_efi, has_bios)
|
||||
prefer_efi = has_efi and not has_bios
|
||||
prefer_efi = self.osinfo.requires_firmware_efi(self.os.arch)
|
||||
else:
|
||||
prefer_efi = self.os.is_arm_machvirt() or self.conn.is_bhyve()
|
||||
|
||||
|
|
|
@ -440,14 +440,14 @@ class _OsVariant(object):
|
|||
return bool(self._device_filter(devids=devids, extra_devs=extra_devs))
|
||||
|
||||
def _get_firmware_list(self):
|
||||
if hasattr(self._os, "get_complete_firmware_list"):
|
||||
if hasattr(self._os, "get_complete_firmware_list"): # pragma: no cover
|
||||
return self._os.get_complete_firmware_list().get_elements()
|
||||
return []
|
||||
|
||||
def _supports_firmware_type(self, name, arch, default):
|
||||
firmwares = self._get_firmware_list()
|
||||
|
||||
for firmware in firmwares:
|
||||
for firmware in firmwares: # pragma: no cover
|
||||
if firmware.get_architecture() != arch:
|
||||
continue
|
||||
if firmware.get_firmware_type() == name:
|
||||
|
@ -455,11 +455,16 @@ class _OsVariant(object):
|
|||
|
||||
return default
|
||||
|
||||
def supports_firmware_efi(self, arch):
|
||||
return self._supports_firmware_type("efi", arch, False)
|
||||
def requires_firmware_efi(self, arch):
|
||||
ret = False
|
||||
try:
|
||||
supports_efi = self._supports_firmware_type("efi", arch, False)
|
||||
supports_bios = self._supports_firmware_type("bios", arch, True)
|
||||
ret = supports_efi and not supports_bios
|
||||
except Exception: # pragma: no cover
|
||||
log.debug("Error checking osinfo firmware support", exc_info=True)
|
||||
|
||||
def supports_firmware_bios(self, arch):
|
||||
return self._supports_firmware_type("bios", arch, True)
|
||||
return ret
|
||||
|
||||
def get_recommended_resources(self):
|
||||
minimum = self._os.get_minimum_resources()
|
||||
|
|
Loading…
Reference in New Issue