[virt-tools-list] [virt-manager PATCH 4/4] domcapabilities: actually fix detection if host-model is safe to use

Pavel Hrdina phrdina at redhat.com
Thu Apr 11 13:36:52 UTC 2019


The original code created a new list which had True/False items.  The
only case where the returned value would be False is for empty list
which never happens in real environment.

Signed-off-by: Pavel Hrdina <phrdina at redhat.com>
---
 .../compare/virt-install-cpu-rhel7-default.xml       | 12 ++++++++++--
 virtinst/domcapabilities.py                          |  8 +++++---
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/tests/cli-test-xml/compare/virt-install-cpu-rhel7-default.xml b/tests/cli-test-xml/compare/virt-install-cpu-rhel7-default.xml
index 04a49f41..c471233c 100644
--- a/tests/cli-test-xml/compare/virt-install-cpu-rhel7-default.xml
+++ b/tests/cli-test-xml/compare/virt-install-cpu-rhel7-default.xml
@@ -12,7 +12,11 @@
     <acpi/>
     <apic/>
   </features>
-  <cpu mode="host-model"/>
+  <cpu mode="custom" match="exact">
+    <model>Skylake-Client-IBRS</model>
+    <feature policy="require" name="spec-ctrl"/>
+    <feature policy="require" name="ssbd"/>
+  </cpu>
   <clock offset="utc">
     <timer name="rtc" tickpolicy="catchup"/>
     <timer name="pit" tickpolicy="delay"/>
@@ -57,7 +61,11 @@
     <acpi/>
     <apic/>
   </features>
-  <cpu mode="host-model"/>
+  <cpu mode="custom" match="exact">
+    <model>Skylake-Client-IBRS</model>
+    <feature policy="require" name="spec-ctrl"/>
+    <feature policy="require" name="ssbd"/>
+  </cpu>
   <clock offset="utc">
     <timer name="rtc" tickpolicy="catchup"/>
     <timer name="pit" tickpolicy="delay"/>
diff --git a/virtinst/domcapabilities.py b/virtinst/domcapabilities.py
index 922a4c21..8993822e 100644
--- a/virtinst/domcapabilities.py
+++ b/virtinst/domcapabilities.py
@@ -233,9 +233,11 @@ class DomainCapabilities(XMLBuilder):
         host-model infact predates this support, however it wasn't
         general purpose safe prior to domcaps advertisement.
         """
-        return [(m.name == "host-model" and m.supported and
-                 m.models[0].fallback == "forbid")
-                for m in self.cpu.modes]
+        for m in self.cpu.modes:
+            if (m.name == "host-model" and m.supported and
+                    m.models[0].fallback == "forbid"):
+                return True
+        return False
 
     def get_cpu_models(self):
         models = []
-- 
2.20.1




More information about the virt-tools-list mailing list