When a CPU model is defined based on another model, we were completely
ignoring features marked as added to or removed from the original model
after it was released. For added features this is the right thing to do
as it will promote them to become normal features included in the new
model. But features marked as removed would become included in the new
model as well. We need to explicitly remove them as if they were never
included in the model.
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
Notes:
Version 2:
- new patch
- replaces "cpu_x86: Copy added and removed features from ancestor"
src/cpu/cpu_x86.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 37f3b6e3ce..285b272ce8 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -161,7 +161,10 @@ struct _virCPUx86Model {
virCPUx86Signatures *signatures;
/* Inherited from ancestor */
virCPUx86Data data;
- /* Not inherited from ancestor */
+
+ /* Not inherited from ancestor.
+ * The corresponding features are removed from the new model data.
+ */
GStrv removedFeatures;
/* Features added to the CPU model after its original version was released.
@@ -172,7 +175,9 @@ struct _virCPUx86Model {
* included in the CPU model by the hypervisor, but libvirt didn't support
* them when introducing the CPU model. In other words, they were enabled,
* but we ignored them.
+ *
* Not inherited from ancestor.
+ * The corresponding features are a genuine part of the new model.
*/
GStrv addedFeatures;
};
@@ -1542,6 +1547,7 @@ x86ModelParseAncestor(virCPUx86Model *model,
g_autofree char *name = NULL;
virCPUx86Model *ancestor;
int rc;
+ char **removed;
if ((rc = virXPathBoolean("boolean(./model)", ctxt)) <= 0)
return rc;
@@ -1565,6 +1571,13 @@ x86ModelParseAncestor(virCPUx86Model *model,
model->signatures = virCPUx86SignaturesCopy(ancestor->signatures);
x86DataCopy(&model->data, &ancestor->data);
+ for (removed = ancestor->removedFeatures; removed && *removed; removed++) {
+ virCPUx86Feature *feat;
+
+ if ((feat = x86FeatureFind(map, *removed)))
+ x86DataSubtract(&model->data, &feat->data);
+ }
+
return 0;
}
--
2.47.0