[PATCH v2 11/30] cpu_x86: Make sure CPU model names are unique in cpu_map

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

 



Having multiple CPU model definitions with the same name could result in
unexpected behavior.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>
---

Notes:
    Version 2:
    - no change

 src/cpu/cpu_x86.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index c54b09396f..4dd10fb561 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1293,9 +1293,15 @@ x86ModelParse(xmlXPathContextPtr ctxt,
               void *data)
 {
     virCPUx86MapPtr map = data;
-    virCPUx86ModelPtr model;
+    virCPUx86ModelPtr model = NULL;
     int ret = -1;
 
+    if (x86ModelFind(map, name)) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       _("Multiple definitions of CPU model '%s'"), name);
+        goto cleanup;
+    }
+
     if (!(model = x86ModelNew()))
         goto cleanup;
 
-- 
2.21.0

--
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]

  Powered by Linux