162 lines
5.6 KiB
Diff
162 lines
5.6 KiB
Diff
From 220390ebd48b33d1d1fae747dc41f1aedd7646e0 Mon Sep 17 00:00:00 2001
|
|
Message-Id: <220390ebd48b33d1d1fae747dc41f1aedd7646e0@dist-git>
|
|
From: Pavel Hrdina <phrdina@redhat.com>
|
|
Date: Wed, 15 May 2019 10:37:47 +0200
|
|
Subject: [PATCH] domain: cpu: introduce set_model function
|
|
|
|
We will need to pass another variable into the setter so we cannot use
|
|
the property setter.
|
|
|
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
Reviewed-by: Cole Robinson <crobinso@redhat.com>
|
|
(cherry picked from commit 6423f653fd2d895d5addf37a6d504dbc9a4a0d6f)
|
|
|
|
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1716402
|
|
|
|
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
---
|
|
tests/xmlparse.py | 11 +++++++----
|
|
virtManager/domain.py | 2 +-
|
|
virtinst/cli.py | 2 +-
|
|
virtinst/domain/cpu.py | 28 +++++++++++++---------------
|
|
4 files changed, 22 insertions(+), 21 deletions(-)
|
|
|
|
diff --git a/tests/xmlparse.py b/tests/xmlparse.py
|
|
index 709bc48f..61552720 100644
|
|
--- a/tests/xmlparse.py
|
|
+++ b/tests/xmlparse.py
|
|
@@ -176,7 +176,8 @@ class XMLParseTest(unittest.TestCase):
|
|
|
|
check = self._make_checker(guest.cpu)
|
|
check("match", "exact", "strict")
|
|
- check("model", "footest", "qemu64")
|
|
+ guest.cpu.set_model("qemu64")
|
|
+ check("model", "qemu64")
|
|
check("vendor", "Intel", "qemuvendor")
|
|
check("threads", 2, 1)
|
|
check("cores", 5, 3)
|
|
@@ -267,7 +268,9 @@ class XMLParseTest(unittest.TestCase):
|
|
guest.seclabels[0].get_xml().startswith("<seclabel"))
|
|
|
|
check = self._make_checker(guest.cpu)
|
|
- check("model", None, "foobar")
|
|
+ check("model", None)
|
|
+ guest.cpu.set_model("foobar")
|
|
+ check("model", "foobar")
|
|
check("model_fallback", None, "allow")
|
|
check("cores", None, 4)
|
|
guest.cpu.add_feature("x2apic", "forbid")
|
|
@@ -332,8 +335,8 @@ class XMLParseTest(unittest.TestCase):
|
|
check = self._make_checker(guest.cpu)
|
|
check("mode", "host-passthrough", "custom")
|
|
check("mode", "custom", "host-model")
|
|
- # mode will be "custom"
|
|
- check("model", None, "qemu64")
|
|
+ guest.cpu.set_model("qemu64")
|
|
+ check("model", "qemu64")
|
|
|
|
self._alter_compare(guest.get_xml(), outfile)
|
|
|
|
diff --git a/virtManager/domain.py b/virtManager/domain.py
|
|
index 4fcc716e..96469969 100644
|
|
--- a/virtManager/domain.py
|
|
+++ b/virtManager/domain.py
|
|
@@ -513,7 +513,7 @@ class vmmDomain(vmmLibvirtObject):
|
|
if model in guest.cpu.SPECIAL_MODES:
|
|
guest.cpu.set_special_mode(guest, model)
|
|
else:
|
|
- guest.cpu.model = model
|
|
+ guest.cpu.set_model(model)
|
|
self._redefine_xmlobj(guest)
|
|
|
|
def define_memory(self, memory=_SENTINEL, maxmem=_SENTINEL):
|
|
diff --git a/virtinst/cli.py b/virtinst/cli.py
|
|
index 63acb642..e384b03a 100644
|
|
--- a/virtinst/cli.py
|
|
+++ b/virtinst/cli.py
|
|
@@ -1442,7 +1442,7 @@ class ParserCPU(VirtCLIParser):
|
|
if val in inst.SPECIAL_MODES:
|
|
inst.set_special_mode(self.guest, val)
|
|
else:
|
|
- inst.model = val
|
|
+ inst.set_model(val)
|
|
|
|
def set_feature_cb(self, inst, val, virtarg):
|
|
policy = virtarg.cliname
|
|
diff --git a/virtinst/domain/cpu.py b/virtinst/domain/cpu.py
|
|
index d66704c1..0673324c 100644
|
|
--- a/virtinst/domain/cpu.py
|
|
+++ b/virtinst/domain/cpu.py
|
|
@@ -62,7 +62,7 @@ class DomainCpu(XMLBuilder):
|
|
Class for generating <cpu> XML
|
|
"""
|
|
XML_NAME = "cpu"
|
|
- _XML_PROP_ORDER = ["mode", "match", "_model", "vendor",
|
|
+ _XML_PROP_ORDER = ["mode", "match", "model", "vendor",
|
|
"sockets", "cores", "threads", "features"]
|
|
|
|
special_mode_was_set = False
|
|
@@ -103,13 +103,21 @@ class DomainCpu(XMLBuilder):
|
|
elif val == self.SPECIAL_MODE_HOST_MODEL_ONLY:
|
|
if self.conn.caps.host.cpu.model:
|
|
self.clear()
|
|
- self.model = self.conn.caps.host.cpu.model
|
|
+ self.set_model(self.conn.caps.host.cpu.model)
|
|
else:
|
|
raise RuntimeError("programming error: unknown "
|
|
"special cpu mode '%s'" % val)
|
|
|
|
self.special_mode_was_set = True
|
|
|
|
+ def set_model(self, val):
|
|
+ logging.debug("setting cpu model %s", val)
|
|
+ if val:
|
|
+ self.mode = "custom"
|
|
+ if not self.match:
|
|
+ self.match = "exact"
|
|
+ self.model = val
|
|
+
|
|
def add_feature(self, name, policy="require"):
|
|
feature = self.features.add_new()
|
|
feature.name = name
|
|
@@ -139,7 +147,7 @@ class DomainCpu(XMLBuilder):
|
|
|
|
self.mode = "custom"
|
|
self.match = "exact"
|
|
- self.model = model
|
|
+ self.set_model(model)
|
|
if fallback:
|
|
self.model_fallback = fallback
|
|
self.vendor = cpu.vendor
|
|
@@ -201,17 +209,7 @@ class DomainCpu(XMLBuilder):
|
|
# XML properties #
|
|
##################
|
|
|
|
- def _set_model(self, val):
|
|
- if val:
|
|
- self.mode = "custom"
|
|
- if not self.match:
|
|
- self.match = "exact"
|
|
- self._model = val
|
|
- def _get_model(self):
|
|
- return self._model
|
|
- _model = XMLProperty("./model")
|
|
- model = property(_get_model, _set_model)
|
|
-
|
|
+ model = XMLProperty("./model")
|
|
model_fallback = XMLProperty("./model/@fallback")
|
|
|
|
match = XMLProperty("./@match")
|
|
@@ -273,7 +271,7 @@ class DomainCpu(XMLBuilder):
|
|
|
|
elif guest.os.is_arm64() and guest.os.is_arm_machvirt():
|
|
# -M virt defaults to a 32bit CPU, even if using aarch64
|
|
- self.model = "cortex-a57"
|
|
+ self.set_model("cortex-a57")
|
|
|
|
elif guest.os.is_x86() and guest.type == "kvm":
|
|
self._set_cpu_x86_kvm_default(guest)
|
|
--
|
|
2.21.0
|
|
|