virtinst: fix detection if baselineHypervisorCPU API is available

With libvirt-python >= 4.4.0 and libvirt < 4.4.0 we would receive
libvirt.libvirtError exception because the python binding knows about
the function but it's not supported by libvirt.  However, in case that
the python binding is older then 4.4.0 it will raise AttributeError
because the function is not implemented in python binding as well.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Pavel Hrdina 2019-10-22 13:33:12 +02:00
parent d9736db9d9
commit df48a77e6a
1 changed files with 1 additions and 1 deletions

View File

@ -278,7 +278,7 @@ class DomainCapabilities(XMLBuilder):
expandedXML = self.conn.baselineHypervisorCPU(
self.path, self.arch, self.machine, self.domain, [cpuXML],
libvirt.VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES)
except libvirt.libvirtError:
except (libvirt.libvirtError, AttributeError):
expandedXML = self.conn.baselineCPU([cpuXML],
libvirt.VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES)