mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-10-27 01:55:20 +03:00
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>
This commit is contained in:
parent
4a8b6363c0
commit
6423f653fd
@ -184,7 +184,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)
|
||||
@ -275,7 +276,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")
|
||||
@ -341,8 +344,8 @@ class XMLParseTest(unittest.TestCase):
|
||||
check("mode", "host-passthrough")
|
||||
guest.cpu.set_special_mode(guest, "host-model")
|
||||
check("mode", "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)
|
||||
|
||||
|
@ -460,7 +460,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):
|
||||
|
@ -1734,7 +1734,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
|
||||
|
@ -61,7 +61,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
|
||||
@ -102,13 +102,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
|
||||
@ -138,7 +146,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
|
||||
@ -200,17 +208,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")
|
||||
@ -272,7 +270,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)
|
||||
|
Loading…
Reference in New Issue
Block a user