[PATCH 36/41] cpu: Set nfeatures_max correctly in x86Decode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Keeping nfeatures_max set to 0 while nfeatures > 0 and some features are
already stored in features array is just asking for problems once we
want to add a new feature into the array.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/cpu/cpu_x86.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 746c804..c867f83 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1870,10 +1870,12 @@ x86Decode(virCPUDefPtr cpu,
     if (vendor && VIR_STRDUP(cpu->vendor, vendor->name) < 0)
         goto cleanup;
 
-    cpu->model = cpuModel->model;
+    VIR_STEAL_PTR(cpu->model, cpuModel->model);
+    VIR_STEAL_PTR(cpu->features, cpuModel->features);
     cpu->nfeatures = cpuModel->nfeatures;
-    cpu->features = cpuModel->features;
-    VIR_FREE(cpuModel);
+    cpuModel->nfeatures = 0;
+    cpu->nfeatures_max = cpuModel->nfeatures_max;
+    cpuModel->nfeatures_max = 0;
 
     ret = 0;
 
-- 
2.9.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]