DomainCpu: check CPU model name only if model exists

For CPU modes other then "custom" there is no model so we should not
check the suffix of model name.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
Pavel Hrdina 2019-04-10 20:36:31 +02:00
parent 291f2ef214
commit c1ebd6730c
2 changed files with 11 additions and 4 deletions

View File

@ -342,10 +342,16 @@ class XMLParseTest(unittest.TestCase):
check = self._make_checker(guest.cpu)
check("mode", "host-passthrough")
guest.cpu.check_security_features(guest)
check("secure", False)
guest.cpu.set_special_mode(guest, "host-model")
check("mode", "host-model")
guest.cpu.check_security_features(guest)
check("secure", False)
guest.cpu.set_model(guest, "qemu64")
check("model", "qemu64")
guest.cpu.check_security_features(guest)
check("secure", False)
self._alter_compare(guest.get_xml(), outfile)

View File

@ -135,10 +135,11 @@ class DomainCpu(XMLBuilder):
return
guestFeatures = [f.name for f in self.features if f.policy == "require"]
if self.model.endswith("IBRS"):
guestFeatures.append("spec-ctrl")
if self.model.endswith("IBPB"):
guestFeatures.append("ibpb")
if self.model:
if self.model.endswith("IBRS"):
guestFeatures.append("spec-ctrl")
if self.model.endswith("IBPB"):
guestFeatures.append("ibpb")
self.secure = set(features) <= set(guestFeatures)