guest: break out disable_hyperv_for_uefi

Having this at set_uefi time complicates the domain XML building
machinery, where we don't want things to have osinfo access.
Rearrange it so that editing cases call this explicitly, and
the XML builder just deals with it at the set_defaults time
This commit is contained in:
Cole Robinson 2019-06-13 17:50:01 -04:00
parent 8c8fec6cb1
commit d9729855ee
3 changed files with 20 additions and 9 deletions

View File

@ -540,6 +540,7 @@ class vmmDomain(vmmLibvirtObject):
else: else:
# Implies UEFI # Implies UEFI
guest.set_uefi_path(loader) guest.set_uefi_path(loader)
guest.disable_hyperv_for_uefi()
if nvram != _SENTINEL: if nvram != _SENTINEL:
guest.os.nvram = nvram guest.os.nvram = nvram

View File

@ -2223,6 +2223,8 @@ class ParserBoot(VirtCLIParser):
def set_uefi_cb(self, inst, val, virtarg): def set_uefi_cb(self, inst, val, virtarg):
self.guest.set_uefi_path(self.guest.get_uefi_path()) self.guest.set_uefi_path(self.guest.get_uefi_path())
if self.editing:
self.guest.disable_hyperv_for_uefi()
def set_initargs_cb(self, inst, val, virtarg): def set_initargs_cb(self, inst, val, virtarg):
inst.set_initargs_string(val) inst.set_initargs_string(val)

View File

@ -560,6 +560,10 @@ class Guest(XMLBuilder):
return path return path
def is_uefi(self):
return bool(self.os.loader and
self.os.loader_type == "pflash")
def set_uefi_path(self, path): def set_uefi_path(self, path):
""" """
Configure UEFI for the VM, but only if libvirt is advertising Configure UEFI for the VM, but only if libvirt is advertising
@ -582,15 +586,19 @@ class Guest(XMLBuilder):
self.os.loader_secure = True self.os.loader_secure = True
self.os.machine = "q35" self.os.machine = "q35"
def disable_hyperv_for_uefi(self):
# UEFI doesn't work with hyperv bits for some OS # UEFI doesn't work with hyperv bits for some OS
if self.osinfo.broken_uefi_with_hyperv(): if not self.is_uefi():
self.features.hyperv_relaxed = None return # pragma: no cover
self.features.hyperv_vapic = None if not self.osinfo.broken_uefi_with_hyperv():
self.features.hyperv_spinlocks = None return # pragma: no cover
self.features.hyperv_spinlocks_retries = None self.features.hyperv_relaxed = None
for i in self.clock.timers: self.features.hyperv_vapic = None
if i.name == "hypervclock": self.features.hyperv_spinlocks = None
self.clock.timers.remove(i) self.features.hyperv_spinlocks_retries = None
for i in self.clock.timers:
if i.name == "hypervclock":
self.clock.timers.remove(i)
def has_spice(self): def has_spice(self):
for gfx in self.devices.graphics: for gfx in self.devices.graphics:
@ -620,7 +628,7 @@ class Guest(XMLBuilder):
def hyperv_supported(self): def hyperv_supported(self):
if not self.osinfo.is_windows(): if not self.osinfo.is_windows():
return False return False
if (self.os.loader_type == "pflash" and if (self.is_uefi() and
self.osinfo.broken_uefi_with_hyperv()): self.osinfo.broken_uefi_with_hyperv()):
return False return False
return True return True