[virt-tools-list] [PATCH v3 2/2] virtinst: compare host and domain cpu models

Charles Arnold carnold at suse.com
Wed Mar 28 19:45:30 UTC 2018


Lookup the domain capabilities CPU model and compare with
the host capabilities CPU model and if they are not equal
set the guest's CPU model to None.

---
 virtinst/guest.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/virtinst/guest.py b/virtinst/guest.py
index 5e7d807..c47d42a 100644
--- a/virtinst/guest.py
+++ b/virtinst/guest.py
@@ -869,6 +869,15 @@ class Guest(XMLBuilder):
                 return
 
             self.cpu.set_special_mode(self.x86_cpu_default)
+            domcaps = DomainCapabilities.build_from_guest(self)
+            domcaps_model = domcaps.cpu.get_mode("host-model").get_models()
+            if (isinstance(domcaps_model, list) and len(domcaps_model) and
+                domcaps_model[0] != self.conn.caps.host.cpu.model):
+                logging.debug("Host capabilities CPU '%s' does not match "
+                      "domain capabilities CPU '%s'. Leaving CPU model unset.",
+                      self.conn.caps.host.cpu.model, domcaps_model[0])
+                self.cpu.model = None
+
             if self._os_object.broken_x2apic():
                 self.cpu.add_feature("x2apic", policy="disable")
 
-- 
1.8.5.6




More information about the virt-tools-list mailing list