File 046-virtinst-suppress-lookup_capsinfo-exception-in-machine-type-alias-check.patch of Package virt-manager

Subject: virtinst: suppress "lookup_capsinfo" exception in machine type alias check
From: Laszlo Ersek lersek@redhat.com Sat Aug 26 13:38:42 2023 +0200
Date: Tue Aug 29 13:24:52 2023 +0200:
Git: 7dbe973b3f3a4311094f772bca72bef58cfdf4d7

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
ae7ebc220b15 ("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: 05fcc7410eee ("virtinst: fix caching of domain capabilities", 2022-07-27)
Signed-off-by: Laszlo Ersek <lersek@redhat.com>

diff --git a/virtinst/guest.py b/virtinst/guest.py
index 9232405b..c61c65e7 100644
--- a/virtinst/guest.py
+++ b/virtinst/guest.py
@@ -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
openSUSE Build Service is sponsored by