]> xenbits.xensource.com Git - libvirt.git/commitdiff
cpu_x86: Make sure CPU model names are unique in cpu_map
authorJiri Denemark <jdenemar@redhat.com>
Tue, 26 Feb 2019 07:33:08 +0000 (08:33 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 5 Mar 2019 13:38:50 +0000 (14:38 +0100)
Having multiple CPU model definitions with the same name could result in
unexpected behavior.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/cpu/cpu_x86.c

index c54b09396f99b5fbb38f0bba2106184e467b5051..4dd10fb5615758a3904a21501548bf77c4675427 100644 (file)
@@ -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;