Currently we just call libvirt API which will return all CPU models for specific architecture known to libvirt and we offer all of them to users in GUI. Let's switch to domain capabilities where we have more details about these CPUs such as whether each model is usable with current QEMU binary. If libvirt can detect the usability we will offer only CPU models that QEMU can actually run. Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx> --- virtManager/connection.py | 3 --- virtManager/details.py | 2 +- virtinst/capabilities.py | 25 ------------------------- virtinst/domcapabilities.py | 11 +++++++++++ virtinst/support.py | 2 -- 5 files changed, 12 insertions(+), 31 deletions(-) diff --git a/virtManager/connection.py b/virtManager/connection.py index fa2125e9..1d8ef292 100644 --- a/virtManager/connection.py +++ b/virtManager/connection.py @@ -1055,9 +1055,6 @@ class vmmConnection(vmmGObject): self._add_conn_events() - # Prime CPU cache - self.caps.get_cpu_values(self.caps.host.cpu.arch) - try: self._backend.setKeepAlive(20, 1) except Exception as e: diff --git a/virtManager/details.py b/virtManager/details.py index 920eea94..27a21892 100644 --- a/virtManager/details.py +++ b/virtManager/details.py @@ -1036,7 +1036,7 @@ class vmmDetails(vmmGObjectUI): model.append([_("Clear CPU configuration"), "3", virtinst.DomainCpu.SPECIAL_MODE_CLEAR, False]) model.append([None, None, None, True]) - for name in caps.get_cpu_values(self.vm.get_arch()): + for name in domcaps.get_cpu_models(): model.append([name, name, name, False]) # Disk cache combo diff --git a/virtinst/capabilities.py b/virtinst/capabilities.py index f9869dcf..91eb8541 100644 --- a/virtinst/capabilities.py +++ b/virtinst/capabilities.py @@ -236,31 +236,6 @@ class Capabilities(XMLBuilder): return False - ############## - # Public API # - ############## - - def get_cpu_values(self, arch): - if not arch: - return [] - if not self.conn.check_support(self.conn.SUPPORT_CONN_CPU_MODEL_NAMES): - return [] - if arch in self._cpu_models_cache: - return self._cpu_models_cache[arch] - - try: - names = self.conn.getCPUModelNames(arch, 0) - if names == -1: - names = [] - except Exception as e: - logging.debug("Error fetching CPU model names for arch=%s: %s", - arch, e) - names = [] - - self._cpu_models_cache[arch] = names - return names - - ############################ # Public XML building APIs # ############################ diff --git a/virtinst/domcapabilities.py b/virtinst/domcapabilities.py index bab6d694..deef9e6a 100644 --- a/virtinst/domcapabilities.py +++ b/virtinst/domcapabilities.py @@ -232,6 +232,17 @@ class DomainCapabilities(XMLBuilder): return [(m.name == "host-model" and m.models[0].fallback == "forbid") for m in self.cpu.modes] + def get_cpu_models(self): + models = [] + + for m in self.cpu.modes: + if m.name == "custom": + for model in m.models: + if model.usable != "no": + models.append(model.model) + + return models + XML_NAME = "domainCapabilities" os = XMLChildProperty(_OS, is_single=True) diff --git a/virtinst/support.py b/virtinst/support.py index 315da99f..7ace3ef6 100644 --- a/virtinst/support.py +++ b/virtinst/support.py @@ -237,8 +237,6 @@ SUPPORT_CONN_AUTOSOCKET = _make(hv_libvirt_version={"qemu": "1.0.6"}) SUPPORT_CONN_PM_DISABLE = _make(hv_version={"qemu": "1.2.0", "test": 0}) SUPPORT_CONN_QCOW2_LAZY_REFCOUNTS = _make( version="1.1.0", hv_version={"qemu": "1.2.0", "test": 0}) -SUPPORT_CONN_CPU_MODEL_NAMES = _make(function="virConnect.getCPUModelNames", - run_args=("x86_64", 0)) SUPPORT_CONN_HYPERV_VAPIC = _make( version="1.1.0", hv_version={"qemu": "1.1.0", "test": 0}) SUPPORT_CONN_HYPERV_CLOCK = _make( -- 2.20.1 _______________________________________________ virt-tools-list mailing list virt-tools-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/virt-tools-list