From 6ba190915ed0be80b67423003dfdf183c47a2fb8 Mon Sep 17 00:00:00 2001
Message-Id: <6ba190915ed0be80b67423003dfdf183c47a2fb8@dist-git>
From: Pavel Hrdina <phrdina@redhat.com>
Date: Wed, 15 May 2019 10:37:55 +0200
Subject: [PATCH] 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>
(cherry picked from commit c1ebd6730cb25b57124fad6c4030345356703320)
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1716402
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
---
tests/xmlparse.py | 4 ++++
virtinst/domain/cpu.py | 9 +++++----
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/tests/xmlparse.py b/tests/xmlparse.py
index c9828fc8..58d3c1a6 100644
--- a/tests/xmlparse.py
+++ b/tests/xmlparse.py
@@ -335,8 +335,12 @@ class XMLParseTest(unittest.TestCase):
check = self._make_checker(guest.cpu)
check("mode", "host-passthrough", "custom")
check("mode", "custom", "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)
diff --git a/virtinst/domain/cpu.py b/virtinst/domain/cpu.py
index 1d468468..66fa649b 100644
--- a/virtinst/domain/cpu.py
+++ b/virtinst/domain/cpu.py
@@ -136,10 +136,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)
--
2.21.0