render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From 84ee95b9504d89236078952a44c1a8b7dba148ca Mon Sep 17 00:00:00 2001
Message-Id: <84ee95b9504d89236078952a44c1a8b7dba148ca@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:24:58 +0200
Subject: [PATCH] cpu_x86: Make sure CPU model names are unique in cpu_map
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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>
(cherry picked from commit 8d7245441a473bc1f73005fd378d4a925870cce6)

https://bugzilla.redhat.com/show_bug.cgi?id=1686895

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <c5dcc42f39009e8a659acb56b89cc18da1c3b7b8.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 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 91362198ab..51cb9b7143 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1291,9 +1291,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.22.0