guest: Drop update_defaults

Fold its one purpose into the UEFI setting bits, fix it and test it
This commit is contained in:
Cole Robinson 2018-09-13 15:51:03 -04:00
parent d7ff46f7f5
commit a741f595ea
5 changed files with 55 additions and 16 deletions

View File

@ -0,0 +1,2 @@
Domain 'test-hyperv-uefi' defined successfully.
Changes will take effect after the domain is fully powered off.

View File

@ -846,6 +846,7 @@ c.add_compare("--build-xml --idmap uid_start=0,uid_target=1000,uid_count=10,gid_
c.add_compare("test --edit --boot network,cdrom", "edit-bootorder")
c.add_compare("--confirm test --edit --cpu host-passthrough", "prompt-response")
c.add_compare("--edit --print-diff --qemu-commandline clearxml=yes", "edit-clearxml-qemu-commandline", input_file=(XMLDIR + "/virtxml-qemu-commandline-clear.xml"))
c.add_compare("--connect %(URI-KVM)s test-hyperv-uefi --edit --boot uefi", "hyperv-uefi-collision")
c = vixml.add_category("simple edit diff", "test-for-virtxml --edit --print-diff --define")

View File

@ -804,6 +804,46 @@ test-many-devices, like an alternate RNG.
</devices>
</domain>
<domain type='test'>
<name>test-hyperv-uefi</name>
<uuid>4a64cc71-19c4-2fd0-2323-f050941ea3c3</uuid>
<metadata>
<libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
<libosinfo:os id="http://microsoft.com/win/7"/>
</libosinfo:libosinfo>
</metadata>
<memory>8388608</memory>
<currentMemory>2097152</currentMemory>
<vcpu>2</vcpu>
<os>
<type arch='i686'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
<hyperv>
<relaxed state="on"/>
<vapic state="on"/>
<spinlocks state="on" retries="8191"/>
</hyperv>
<vmport state="off"/>
</features>
<clock offset="localtime">
<timer name="rtc" tickpolicy="catchup"/>
<timer name="pit" tickpolicy="delay"/>
<timer name="hpet" present="no"/>
<timer name="hypervclock" present="yes"/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<devices>
</devices>
</domain>
<domain type='test' xmlns:test='http://libvirt.org/schemas/domain/test/1.0'>
<name>test-state-shutoff</name>
<memory>1048576</memory>

View File

@ -2159,7 +2159,6 @@ class vmmCreate(vmmGObjectUI):
return
logging.debug("User finished customize dialog, starting install")
self._failed_guest = None
guest.update_defaults()
self._start_install(guest)
def config_canceled(ignore):

View File

@ -316,7 +316,8 @@ class Guest(XMLBuilder):
"""
If UEFI firmware path is found, return it, otherwise raise an error
"""
self.set_capabilities_defaults()
if not self.os.arch:
self.set_capabilities_defaults()
domcaps = DomainCapabilities.build_from_guest(self)
if not domcaps.supports_uefi_xml():
@ -356,6 +357,16 @@ class Guest(XMLBuilder):
self.os.loader_secure = True
self.os.machine = "q35"
# UEFI doesn't work with hyperv bits for some OS
if self.osinfo.broken_uefi_with_hyperv():
self.features.hyperv_relaxed = None
self.features.hyperv_vapic = None
self.features.hyperv_spinlocks = None
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):
for gfx in self.devices.graphics:
if gfx.type == gfx.TYPE_SPICE:
@ -411,20 +422,6 @@ class Guest(XMLBuilder):
machine=self.os.machine)
return self._capsinfo
def update_defaults(self):
# This is used only by virt-manager to reset any defaults that may have
# changed through manual intervention via the customize wizard.
# UEFI doesn't work with hyperv bits
if not self.hyperv_supported():
self.features.hyperv_relaxed = None
self.features.hyperv_vapic = None
self.features.hyperv_spinlocks = None
self.features.hyperv_spinlocks_retries = None
for i in self.clock.timers:
if i.name == "hypervclock":
self.clock.remove_timer(i)
def set_capabilities_defaults(self, capsinfo=None):
if capsinfo:
self._capsinfo = capsinfo