Blame SOURCES/virt-manager-domain-cpu-introduce-set_model-function.patch

3d61c0
From 661b3ed3bef6c35094399264f0c1a736ac7ddf04 Mon Sep 17 00:00:00 2001
3d61c0
Message-Id: <661b3ed3bef6c35094399264f0c1a736ac7ddf04@dist-git>
3d61c0
From: Pavel Hrdina <phrdina@redhat.com>
3d61c0
Date: Thu, 14 Mar 2019 10:46:02 +0100
3d61c0
Subject: [PATCH] domain: cpu: introduce set_model function
3d61c0
3d61c0
We will need to pass another variable into the setter so we cannot use
3d61c0
the property setter.
3d61c0
3d61c0
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
3d61c0
Reviewed-by: Cole Robinson <crobinso@redhat.com>
3d61c0
(cherry picked from commit 6423f653fd2d895d5addf37a6d504dbc9a4a0d6f)
3d61c0
3d61c0
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1582667
3d61c0
3d61c0
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
3d61c0
Reviewed-by: Cole Robinson <crobinso@redhat.com>
3d61c0
---
3d61c0
 tests/xmlparse.py     | 11 +++++++----
3d61c0
 virtManager/domain.py |  2 +-
3d61c0
 virtinst/cli.py       |  2 +-
3d61c0
 virtinst/cpu.py       | 22 ++++++++++++----------
3d61c0
 4 files changed, 21 insertions(+), 16 deletions(-)
3d61c0
3d61c0
diff --git a/tests/xmlparse.py b/tests/xmlparse.py
3d61c0
index e7d291f3..279b1dc1 100644
3d61c0
--- a/tests/xmlparse.py
3d61c0
+++ b/tests/xmlparse.py
3d61c0
@@ -169,7 +169,8 @@ class XMLParseTest(unittest.TestCase):
3d61c0
 
3d61c0
         check = self._make_checker(guest.cpu)
3d61c0
         check("match", "exact", "strict")
3d61c0
-        check("model", "footest", "qemu64")
3d61c0
+        guest.cpu.set_model("qemu64")
3d61c0
+        check("model", "qemu64")
3d61c0
         check("vendor", "Intel", "qemuvendor")
3d61c0
         check("threads", 2, 1)
3d61c0
         check("cores", 5, 3)
3d61c0
@@ -262,7 +263,9 @@ class XMLParseTest(unittest.TestCase):
3d61c0
             guest.seclabels[0].get_xml_config().startswith("
3d61c0
 
3d61c0
         check = self._make_checker(guest.cpu)
3d61c0
-        check("model", None, "foobar")
3d61c0
+        check("model", None)
3d61c0
+        guest.cpu.set_model("foobar")
3d61c0
+        check("model", "foobar")
3d61c0
         check("model_fallback", None, "allow")
3d61c0
         check("cores", None, 4)
3d61c0
         guest.cpu.add_feature("x2apic", "forbid")
3d61c0
@@ -323,8 +326,8 @@ class XMLParseTest(unittest.TestCase):
3d61c0
         check = self._make_checker(guest.cpu)
3d61c0
         check("mode", "host-passthrough", "custom")
3d61c0
         check("mode", "custom", "host-model")
3d61c0
-        # mode will be "custom"
3d61c0
-        check("model", None, "qemu64")
3d61c0
+        guest.cpu.set_model("qemu64")
3d61c0
+        check("model", "qemu64")
3d61c0
 
3d61c0
         self._alter_compare(guest.get_xml_config(), outfile)
3d61c0
 
3d61c0
diff --git a/virtManager/domain.py b/virtManager/domain.py
3d61c0
index a60e054f..2426383a 100644
3d61c0
--- a/virtManager/domain.py
3d61c0
+++ b/virtManager/domain.py
3d61c0
@@ -665,7 +665,7 @@ class vmmDomain(vmmLibvirtObject):
3d61c0
             if model in guest.cpu.SPECIAL_MODES:
3d61c0
                 guest.cpu.set_special_mode(guest, model)
3d61c0
             else:
3d61c0
-                guest.cpu.model = model
3d61c0
+                guest.cpu.set_model(model)
3d61c0
         self._redefine_xmlobj(guest)
3d61c0
 
3d61c0
     def define_memory(self, memory=_SENTINEL, maxmem=_SENTINEL):
3d61c0
diff --git a/virtinst/cli.py b/virtinst/cli.py
3d61c0
index 99d952ec..1a3df401 100644
3d61c0
--- a/virtinst/cli.py
3d61c0
+++ b/virtinst/cli.py
3d61c0
@@ -1477,7 +1477,7 @@ class ParserCPU(VirtCLIParser):
3d61c0
         if val in inst.SPECIAL_MODES:
3d61c0
             inst.set_special_mode(self.guest, val)
3d61c0
         else:
3d61c0
-            inst.model = val
3d61c0
+            inst.set_model(val)
3d61c0
 
3d61c0
     def set_feature_cb(self, inst, val, virtarg):
3d61c0
         policy = virtarg.cliname
3d61c0
diff --git a/virtinst/cpu.py b/virtinst/cpu.py
3d61c0
index f109445c..85cedb31 100644
3d61c0
--- a/virtinst/cpu.py
3d61c0
+++ b/virtinst/cpu.py
3d61c0
@@ -125,13 +125,21 @@ class CPU(XMLBuilder):
3d61c0
         elif val == self.SPECIAL_MODE_HOST_MODEL_ONLY:
3d61c0
             if self.conn.caps.host.cpu.model:
3d61c0
                 self.clear()
3d61c0
-                self.model = self.conn.caps.host.cpu.model
3d61c0
+                self.set_model(self.conn.caps.host.cpu.model)
3d61c0
         else:
3d61c0
             raise RuntimeError("programming error: unknown "
3d61c0
                 "special cpu mode '%s'" % val)
3d61c0
 
3d61c0
         self.special_mode_was_set = True
3d61c0
 
3d61c0
+    def set_model(self, val):
3d61c0
+        logging.debug("setting cpu model %s", val)
3d61c0
+        if val:
3d61c0
+            self.mode = "custom"
3d61c0
+            if not self.match:
3d61c0
+                self.match = "exact"
3d61c0
+        self.model = val
3d61c0
+
3d61c0
     def add_feature(self, name, policy="require"):
3d61c0
         feature = CPUFeature(self.conn)
3d61c0
         feature.name = name
3d61c0
@@ -174,7 +182,7 @@ class CPU(XMLBuilder):
3d61c0
 
3d61c0
         self.mode = "custom"
3d61c0
         self.match = "exact"
3d61c0
-        self.model = model
3d61c0
+        self.set_model(model)
3d61c0
         if fallback:
3d61c0
             self.model_fallback = fallback
3d61c0
         self.vendor = cpu.vendor
3d61c0
@@ -236,13 +244,7 @@ class CPU(XMLBuilder):
3d61c0
     # XML properties #
3d61c0
     ##################
3d61c0
 
3d61c0
-    def _set_model(self, val):
3d61c0
-        if val:
3d61c0
-            self.mode = "custom"
3d61c0
-            if not self.match:
3d61c0
-                self.match = "exact"
3d61c0
-        return val
3d61c0
-    model = XMLProperty("./model", set_converter=_set_model)
3d61c0
+    model = XMLProperty("./model")
3d61c0
     model_fallback = XMLProperty("./model/@fallback")
3d61c0
 
3d61c0
     match = XMLProperty("./@match")
3d61c0
@@ -304,7 +306,7 @@ class CPU(XMLBuilder):
3d61c0
 
3d61c0
         elif guest.os.is_arm64() and guest.os.is_arm_machvirt():
3d61c0
             # -M virt defaults to a 32bit CPU, even if using aarch64
3d61c0
-            self.model = "cortex-a57"
3d61c0
+            self.set_model("cortex-a57")
3d61c0
 
3d61c0
         elif guest.os.is_x86() and guest.type == "kvm":
3d61c0
             self._set_cpu_x86_kvm_default(guest)
3d61c0
-- 
3d61c0
2.20.1
3d61c0