diff options
author | Daniel P. Berrangé <berrange@redhat.com> | 2022-06-28 21:54:07 +0100 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2022-07-27 17:53:14 -0400 |
commit | 05fcc7410eee0dc90331b49d0a7e7727f362c2e4 (patch) | |
tree | d738701b0c48e65d01807aa127bc21e0b798038c /virtinst | |
parent | a4a5c1529a81c5bd5636b4847b03643d97fa3dd3 (diff) | |
download | virt-manager-05fcc7410eee0dc90331b49d0a7e7727f362c2e4.tar.gz |
virtinst: fix caching of domain capabilities
The domain capabilities XML always contains the canonical machine name.
When the selected machine type for a guest is an alias, the check
comparing it to the domain capabilities machine will always fail. This
prevents the domain capabilities result from being cached.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'virtinst')
-rw-r--r-- | virtinst/capabilities.py | 16 | ||||
-rw-r--r-- | virtinst/guest.py | 10 |
2 files changed, 25 insertions, 1 deletions
diff --git a/virtinst/capabilities.py b/virtinst/capabilities.py index f1a0acfd..aa8fbfda 100644 --- a/virtinst/capabilities.py +++ b/virtinst/capabilities.py @@ -129,6 +129,19 @@ class _CapsGuest(XMLBuilder): ret.append(m.canonical) return ret + def is_machine_alias(self, domain, src, tgt): + """ + Determine if machine @src is an alias for machine @tgt + """ + mobjs = (domain and domain.machines) or self.machines + for m in mobjs: + log.debug("Check %s == %s %s == %s", m.name, src, m.canonical, tgt) + if m.name == src and m.canonical == tgt: + log.debug("ok") + return True + log.debug("not ok") + return False + def is_kvm_available(self): """ Return True if kvm guests can be installed @@ -179,6 +192,9 @@ class _CapsInfo(object): self.emulator = self.domain.emulator or self.guest.emulator self.machines = self.guest.all_machine_names(self.domain) + def is_machine_alias(self, src, tgt): + return self.guest.is_machine_alias(self.domain, src, tgt) + class Capabilities(XMLBuilder): def __init__(self, *args, **kwargs): diff --git a/virtinst/guest.py b/virtinst/guest.py index 3fb9a956..2d8edbe2 100644 --- a/virtinst/guest.py +++ b/virtinst/guest.py @@ -618,13 +618,21 @@ class Guest(XMLBuilder): return True def lookup_domcaps(self): + def _compare_machine(domcaps): + capsinfo = self.lookup_capsinfo() + if self.os.machine == domcaps.machine: + return True + if capsinfo.is_machine_alias(self.os.machine, domcaps.machine): + return True + return False + # We need to regenerate domcaps cache if any of these values change def _compare(domcaps): # pragma: no cover if self.type == "test": # Test driver doesn't support domcaps. We kinda fake it in # some cases, but it screws up the checking here for parsed XML return True - if self.os.machine and self.os.machine != domcaps.machine: + if self.os.machine and not _compare_machine(domcaps): return False if self.type and self.type != domcaps.domain: return False |