guest: Move uefi check into _add_default_tpm

This is closer to the same pattern used by _add_default_*

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2022-01-26 13:21:23 -05:00
parent 5003f0432e
commit b7e86d2fcc

View File

@ -700,11 +700,7 @@ class Guest(XMLBuilder):
self._add_default_channels()
self._add_default_rng()
self._add_default_memballoon()
if self.is_uefi():
# If the guest is using UEFI, we take that as a
# flag that the VM is targeting a modern platform
# and thus we should also provide an emulated TPM.
self._add_default_tpm()
self._add_default_tpm()
self.clock.set_defaults(self)
self.cpu.set_defaults(self)
@ -954,6 +950,12 @@ class Guest(XMLBuilder):
if self.devices.tpm:
return
# If the guest is using UEFI, we take that as a
# flag that the VM is targeting a modern platform
# and thus we should also provide an emulated TPM.
if not self.is_uefi():
return
if not self.lookup_domcaps().supports_tpm_emulator():
log.debug("Domain caps doesn't report TPM support")
return