[PATCH 01/32] cpu_x86: Copy added and removed features from ancestor

Jiri Denemark posted 32 patches 2 weeks ago
There is a newer version of this series
[PATCH 01/32] cpu_x86: Copy added and removed features from ancestor
Posted by Jiri Denemark 2 weeks ago
When a CPU model is defined based on another model, we need to copy the
lists of removed and added features from it.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/cpu/cpu_x86.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 97d6e00007..7cfab8278d 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1555,6 +1555,8 @@ x86ModelParseAncestor(virCPUx86Model *model,
     model->vendor = ancestor->vendor;
     model->signatures = virCPUx86SignaturesCopy(ancestor->signatures);
     x86DataCopy(&model->data, &ancestor->data);
+    model->removedFeatures = g_strdupv(ancestor->removedFeatures);
+    model->addedFeatures = g_strdupv(ancestor->addedFeatures);
 
     return 0;
 }
@@ -1654,8 +1656,19 @@ x86ModelParseFeatures(virCPUx86Model *model,
     if ((n = virXPathNodeSet("./feature", ctxt, &nodes)) <= 0)
         return n;
 
-    model->removedFeatures = g_new0(char *, n + 1);
-    model->addedFeatures = g_new0(char *, n + 1);
+    if (model->removedFeatures) {
+        nremoved = g_strv_length(model->removedFeatures);
+        model->removedFeatures = g_renew(char *, model->removedFeatures, nremoved + n + 1);
+    } else {
+        model->removedFeatures = g_new0(char *, n + 1);
+    }
+
+    if (model->addedFeatures) {
+        nadded = g_strv_length(model->addedFeatures);
+        model->addedFeatures = g_renew(char *, model->addedFeatures, nadded + n + 1);
+    } else {
+        model->addedFeatures = g_new0(char *, n + 1);
+    }
 
     for (i = 0; i < n; i++) {
         g_autofree char *ftname = NULL;
-- 
2.47.0