diff --git a/nova/tests/unit/virt/libvirt/test_host.py b/nova/tests/unit/virt/libvirt/test_host.py index cb86c9a851d1..fd6e621beb79 100644 --- a/nova/tests/unit/virt/libvirt/test_host.py +++ b/nova/tests/unit/virt/libvirt/test_host.py @@ -2035,6 +2035,7 @@ Active: 8381604 kB 'interface-types': ['uefi'], 'mapping': { 'device': 'flash', + 'mode': 'split', 'executable': { 'filename': '/usr/share/edk2/ovmf/OVMF_CODE.fd', 'format': 'raw', @@ -2053,6 +2054,44 @@ Active: 8381604 kB 'features': ['acpi-s3', 'amd-sev', 'verbose-dynamic'], 'tags': [], }, + # NOTE(tkajinam): The following loaders are not supported and + # should be ignored. https://bugs.launchpad.net/nova/+bug/2122288 + { + 'description': 'Sample descriptor for stateless mode', + 'interface-types': ['uefi'], + 'mapping': { + 'device': 'flash', + 'mode': 'stateless', + 'executable': { + 'filename': '/usr/share/edk2/ovmf/OVMF_CODE_SL.fd', + 'format': 'raw' + } + }, + 'targets': [ + { + 'architecture': 'x86_64', + 'machines': ['pc-q35-*'], + }, + ], + 'features': ['amd-sev', 'verbose-dynamic'], + 'tags': [], + }, + { + 'description': 'Sample descriptor for memory device', + 'interface-types': ['uefi'], + 'mapping': { + 'device': 'memory', + 'filename': '/usr/share/edk2/ovmf/OVMF_MEM.fd' + }, + 'targets': [ + { + 'architecture': 'x86_64', + 'machines': ['pc-q35-*'], + } + ], + 'features': ['amd-sev', 'verbose-dynamic'], + 'tags': [], + }, ] def fake_get_mtype(arch, machine): diff --git a/nova/virt/libvirt/host.py b/nova/virt/libvirt/host.py index 63ba17d81b8e..682065eaa289 100644 --- a/nova/virt/libvirt/host.py +++ b/nova/virt/libvirt/host.py @@ -2094,31 +2094,37 @@ class Host(object): machine = self.get_canonical_machine_type(arch, machine) for loader in self.loaders: - for target in loader['targets']: - if arch != target['architecture']: - continue + try: + for target in loader['targets']: + if arch != target['architecture']: + continue - for machine_glob in target['machines']: - # the 'machines' attribute supports glob patterns (e.g. - # 'pc-q35-*') so we need to resolve these - if fnmatch.fnmatch(machine, machine_glob): - break + for machine_glob in target['machines']: + # the 'machines' attribute supports glob patterns (e.g. + # 'pc-q35-*') so we need to resolve these + if fnmatch.fnmatch(machine, machine_glob): + break + else: + continue + + # if we've got this far, we have a match on the target + break else: continue - # if we've got this far, we have a match on the target - break - else: - continue + # if we request secure boot then we should get it and vice + # versa + if has_secure_boot != ('secure-boot' in loader['features']): + continue - # if we request secure boot then we should get it and vice versa - if has_secure_boot != ('secure-boot' in loader['features']): + return ( + loader['mapping']['executable']['filename'], + loader['mapping']['nvram-template']['filename'], + 'requires-smm' in loader['features'], + ) + except KeyError: + # This indicates that the description structure is new and nova + # does not how to handle it continue - return ( - loader['mapping']['executable']['filename'], - loader['mapping']['nvram-template']['filename'], - 'requires-smm' in loader['features'], - ) - raise exception.UEFINotSupported() diff --git a/releasenotes/notes/bug-2133416-80522b523ee74835.yaml b/releasenotes/notes/bug-2133416-80522b523ee74835.yaml new file mode 100644 index 000000000000..69cf73340e48 --- /dev/null +++ b/releasenotes/notes/bug-2133416-80522b523ee74835.yaml @@ -0,0 +1,10 @@ +--- +fixes: + - | + [`bug 2133416 `_] Libvirt + virt driver now ignores the OVMF firmware files of the following types. + Previously nova failed to start instances with UEFI boot when it attempts + to check such firmware files. + + - stateless mode + - memory device