virtinst: suppress "lookup_capsinfo" exception in machine type alias check

Just to be sure, this patch implements the second approach (described in
the previous patch) as well.

Note that there is precedent for suppressing "guest_lookup" exceptions:
refer to the "Error determining machine list" branch from commit
ae7ebc220b ("details: Properly limit machine type list by guests
arch/type", 2013-09-01).

(

In fact, that branch gets activated when opening the details window for a
domain that uses a non-default emulator; the "virt-manager --debug" log
contains:

> ERROR (details:613) Error determining machine list
> Traceback (most recent call last):
>   File "virtManager/details/details.py", line 605, in _init_details
>     capsinfo = caps.guest_lookup(
>   File "virtinst/capabilities.py", line 319, in guest_lookup
>     raise ValueError(msg)
> ValueError: Host does not support domain type kvm with machine
> 'pc-q35-8.1' for virtualization type 'hvm' with architecture 'x86_64'

)

Fixes: #539
Fixes: 05fcc7410e ("virtinst: fix caching of domain capabilities", 2022-07-27)
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
Laszlo Ersek 2023-08-26 13:38:42 +02:00 committed by Pavel Hrdina
parent 4ead4acb44
commit 7dbe973b3f

View File

@ -632,7 +632,12 @@ class Guest(XMLBuilder):
def _compare_machine(domcaps):
if self.os.machine == domcaps.machine:
return True
capsinfo = self.lookup_capsinfo()
try:
capsinfo = self.lookup_capsinfo()
except Exception:
log.exception("Error fetching machine list for alias "
"resolution, assuming mismatch");
return False
if capsinfo.is_machine_alias(self.os.machine, domcaps.machine):
return True
return False