cpu: Drop vendor and features if setting host-model (bz 1190851)

Otherwise via virt-manager we can try to set a <cpu> with a <vendor>
but no <model>, and libvirt complains.
This commit is contained in:
Cole Robinson 2015-03-26 17:08:15 -04:00
parent 2c9d2a2360
commit dc1737e623
3 changed files with 7 additions and 1 deletions

View File

@ -23,7 +23,7 @@
<label>frob</label>
</seclabel>
<cpu mode="custom" match="exact">
<model>foobar</model>
<model fallback="allow">foobar</model>
<topology sockets="1" cores="4" threads="1"/>
<feature policy="forbid" name="x2apic"/>
</cpu>

View File

@ -251,6 +251,7 @@ class XMLParseTest(unittest.TestCase):
check = self._make_checker(guest.cpu)
check("model", None, "foobar")
check("model_fallback", None, "allow")
check("cores", None, 4)
guest.cpu.add_feature("x2apic", "forbid")
guest.cpu.set_topology_defaults(guest.vcpus)

View File

@ -59,6 +59,10 @@ class CPU(XMLBuilder):
if (val == self.SPECIAL_MODE_HOST_MODEL or
val == self.SPECIAL_MODE_HOST_PASSTHROUGH):
self.model = None
self.vendor = None
self.model_fallback = None
for f in self.features:
self.remove_feature(f)
self.mode = val
elif val == self.SPECIAL_MODE_HOST_COPY:
self.copy_host_cpu()
@ -161,6 +165,7 @@ class CPU(XMLBuilder):
self.match = "exact"
return val
model = XMLProperty("./model", set_converter=_set_model)
model_fallback = XMLProperty("./model/@fallback")
match = XMLProperty("./@match")
vendor = XMLProperty("./vendor")