render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
c480ed
From 84ee95b9504d89236078952a44c1a8b7dba148ca Mon Sep 17 00:00:00 2001
c480ed
Message-Id: <84ee95b9504d89236078952a44c1a8b7dba148ca@dist-git>
c480ed
From: Jiri Denemark <jdenemar@redhat.com>
c480ed
Date: Fri, 21 Jun 2019 09:24:58 +0200
c480ed
Subject: [PATCH] cpu_x86: Make sure CPU model names are unique in cpu_map
c480ed
MIME-Version: 1.0
c480ed
Content-Type: text/plain; charset=UTF-8
c480ed
Content-Transfer-Encoding: 8bit
c480ed
c480ed
Having multiple CPU model definitions with the same name could result in
c480ed
unexpected behavior.
c480ed
c480ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
(cherry picked from commit 8d7245441a473bc1f73005fd378d4a925870cce6)
c480ed
c480ed
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
c480ed
c480ed
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c480ed
Message-Id: <c5dcc42f39009e8a659acb56b89cc18da1c3b7b8.1561068591.git.jdenemar@redhat.com>
c480ed
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c480ed
---
c480ed
 src/cpu/cpu_x86.c | 8 +++++++-
c480ed
 1 file changed, 7 insertions(+), 1 deletion(-)
c480ed
c480ed
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
c480ed
index 91362198ab..51cb9b7143 100644
c480ed
--- a/src/cpu/cpu_x86.c
c480ed
+++ b/src/cpu/cpu_x86.c
c480ed
@@ -1291,9 +1291,15 @@ x86ModelParse(xmlXPathContextPtr ctxt,
c480ed
               void *data)
c480ed
 {
c480ed
     virCPUx86MapPtr map = data;
c480ed
-    virCPUx86ModelPtr model;
c480ed
+    virCPUx86ModelPtr model = NULL;
c480ed
     int ret = -1;
c480ed
 
c480ed
+    if (x86ModelFind(map, name)) {
c480ed
+        virReportError(VIR_ERR_INTERNAL_ERROR,
c480ed
+                       _("Multiple definitions of CPU model '%s'"), name);
c480ed
+        goto cleanup;
c480ed
+    }
c480ed
+
c480ed
     if (!(model = x86ModelNew()))
c480ed
         goto cleanup;
c480ed
 
c480ed
-- 
c480ed
2.22.0
c480ed