render / rpms / libvirt

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