domain: tweak q35 <-> pc editing

* add_q35_pcie_controllers already skips adding controllers if
  any type=pci already exist, so delete the extra checking
* be more paranoid and only run the live edits when the machine
  type actually changed from an expected config

Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Cole Robinson 2024-09-10 15:41:00 -04:00
parent 78064728e6
commit 258df88eab
2 changed files with 15 additions and 10 deletions

View File

@ -480,10 +480,16 @@ def testNewKVMQ35Tweaks(app):
details.combo_check_default("Chipset:", "Q35") details.combo_check_default("Chipset:", "Q35")
details.combo_check_default("Firmware:", "BIOS") details.combo_check_default("Firmware:", "BIOS")
# Switch i440FX and back # Unchanged machine
details.combo_select("Chipset:", "i440FX")
details.combo_select("Chipset:", "Q35")
appl.click()
lib.utils.check(lambda: not appl.sensitive)
# Switch i440FX
details.combo_select("Chipset:", "i440FX") details.combo_select("Chipset:", "i440FX")
appl.click() appl.click()
lib.utils.check(lambda: not appl.sensitive) lib.utils.check(lambda: not appl.sensitive)
# Switch back to Q35
details.combo_select("Chipset:", "Q35") details.combo_select("Chipset:", "Q35")
appl.click() appl.click()
lib.utils.check(lambda: not appl.sensitive) lib.utils.check(lambda: not appl.sensitive)

View File

@ -694,7 +694,10 @@ class vmmDomain(vmmLibvirtObject):
title=_SENTINEL, loader=_SENTINEL, title=_SENTINEL, loader=_SENTINEL,
nvram=_SENTINEL, firmware=_SENTINEL): nvram=_SENTINEL, firmware=_SENTINEL):
guest = self._make_xmlobj_to_define() guest = self._make_xmlobj_to_define()
old_machine = None
if machine != _SENTINEL: if machine != _SENTINEL:
old_machine = guest.os.machine
guest.os.machine = machine guest.os.machine = machine
self._domain_caps = None self._domain_caps = None
if description != _SENTINEL: if description != _SENTINEL:
@ -723,18 +726,14 @@ class vmmDomain(vmmLibvirtObject):
if nvram != _SENTINEL: if nvram != _SENTINEL:
guest.os.nvram = nvram guest.os.nvram = nvram
if guest.os.machine == "q35": if old_machine == "pc" and guest.os.machine == "q35":
pcie_controllers_already_created = False guest.add_q35_pcie_controllers()
for dev in guest.devices.controller:
if dev.model in ["pcie-root", "pcie-root-port"]: elif old_machine == "q35" and guest.os.machine == "pc":
pcie_controllers_already_created = True
break
if not pcie_controllers_already_created:
guest.add_q35_pcie_controllers()
elif guest.os.machine == "pc":
for dev in guest.devices.controller: for dev in guest.devices.controller:
if dev.model in ["pcie-root", "pcie-root-port"]: if dev.model in ["pcie-root", "pcie-root-port"]:
guest.remove_device(dev) guest.remove_device(dev)
self._redefine_xmlobj(guest) self._redefine_xmlobj(guest)
def define_os(self, os_name=_SENTINEL): def define_os(self, os_name=_SENTINEL):