[PATCH v1 8/9] qemu_driver: report feature policy when baselining

Collin Walling posted 9 patches 1 year, 1 month ago
[PATCH v1 8/9] qemu_driver: report feature policy when baselining
Posted by Collin Walling 1 year, 1 month ago
Some baselined models may require that certain features are disabled to
ensure compatability with all computed models. When converting the model
info to a CPU definition, check the model info feature value for false
and set the CPU def policy to disabled.

Additionally, set the CPU def type to VIR_CPU_TYPE_GUEST so that the XML
formatter will consider the feature policies.

Signed-off-by: Collin Walling <walling@linux.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
---
 src/qemu/qemu_driver.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0d4da937b0..1c61685489 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -11659,15 +11659,19 @@ qemuConnectStealCPUModelFromInfo(virCPUDef *dst,
 
     info = g_steal_pointer(src);
     dst->model = g_steal_pointer(&info->name);
+    dst->type = VIR_CPU_TYPE_GUEST;
 
     for (i = 0; i < info->nprops; i++) {
         char *name = info->props[i].name;
+        virCPUFeaturePolicy policy;
 
-        if (info->props[i].type != QEMU_MONITOR_CPU_PROPERTY_BOOLEAN ||
-            !info->props[i].value.boolean)
+        if (info->props[i].type != QEMU_MONITOR_CPU_PROPERTY_BOOLEAN)
             continue;
 
-        if (virCPUDefAddFeature(dst, name, VIR_CPU_FEATURE_REQUIRE) < 0)
+        policy = info->props[i].value.boolean ? VIR_CPU_FEATURE_REQUIRE
+                                              : VIR_CPU_FEATURE_DISABLE;
+
+        if (virCPUDefAddFeature(dst, name, policy) < 0)
             return -1;
     }
 
-- 
2.41.0