[virt-tools-list] [virt-manager PATCH] DomainCpu: check CPU model name only if model exists

Pavel Hrdina phrdina at redhat.com
Wed Apr 10 18:44:52 UTC 2019


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 at redhat.com>
---
 tests/xmlparse.py      | 6 ++++++
 virtinst/domain/cpu.py | 9 +++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/tests/xmlparse.py b/tests/xmlparse.py
index 43acdcd9..2a9dd347 100644
--- a/tests/xmlparse.py
+++ b/tests/xmlparse.py
@@ -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)
 
diff --git a/virtinst/domain/cpu.py b/virtinst/domain/cpu.py
index fa2df6de..e78d6167 100644
--- a/virtinst/domain/cpu.py
+++ b/virtinst/domain/cpu.py
@@ -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)
 
-- 
2.20.1




More information about the virt-tools-list mailing list