@@ -5054,6 +5054,44 @@ def test_get_guest_config_with_uefi(self):
50545054 self.assertEqual('/usr/share/OVMF/OVMF_CODE.fd', cfg.os_loader)
50555055 self.assertEqual('/usr/share/OVMF/OVMF_VARS.fd', cfg.os_nvram_template)
50565056
5057+ def test_get_guest_config_with_secure_boot_and_smm_required(self):
5058+ drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
5059+ # uefi only used with secure boot
5060+ drvr._host._supports_uefi = True
5061+ # smm only used with secure boot
5062+ drvr._host._supports_secure_boot = True
5063+
5064+ # NOTE(imranh2): Current way of gathering firmwares is inflexible
5065+ # nova/tests/fixtures/libvirt.py FakeLoaders has requires-smm
5066+ # defined. do the following to make sure we get this programtically
5067+ # in the future we should test firmwares that both do and don't
5068+ # require smm but the current way firmware is selected doesn't
5069+ # make it possible to do so.
5070+ loader, nvram_template, requires_smm = drvr._host.get_loader(
5071+ 'x86_64', 'q35', True)
5072+
5073+ image_meta = objects.ImageMeta.from_dict({
5074+ 'disk_format': 'raw',
5075+ # secure boot requires UEFI
5076+ 'properties': {
5077+ 'hw_firmware_type': 'uefi',
5078+ 'hw_machine_type': 'q35',
5079+ 'os_secure_boot': 'required',
5080+ },
5081+ })
5082+ instance_ref = objects.Instance(**self.test_instance)
5083+
5084+ disk_info = blockinfo.get_disk_info(
5085+ CONF.libvirt.virt_type, instance_ref, image_meta)
5086+
5087+ cfg = drvr._get_guest_config(
5088+ instance_ref, [], image_meta, disk_info)
5089+ # if we require it make sure it's there
5090+ if requires_smm:
5091+ self.assertTrue(any(isinstance(feature,
5092+ vconfig.LibvirtConfigGuestFeatureSMM)
5093+ for feature in cfg.features))
5094+
50575095 @ddt.data(True, False)
50585096 def test_get_guest_config_with_secure_boot_required(
50595097 self, host_has_support,
0 commit comments