render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
99cbc7
From 223e57b0ed8b285bc38d51252dc3ded63f8f3e11 Mon Sep 17 00:00:00 2001
99cbc7
Message-Id: <223e57b0ed8b285bc38d51252dc3ded63f8f3e11@dist-git>
99cbc7
From: Jiri Denemark <jdenemar@redhat.com>
99cbc7
Date: Wed, 20 Mar 2019 14:55:20 +0100
99cbc7
Subject: [PATCH] cpu_x86: Separate signature parsing from x86ModelParse
99cbc7
MIME-Version: 1.0
99cbc7
Content-Type: text/plain; charset=UTF-8
99cbc7
Content-Transfer-Encoding: 8bit
99cbc7
99cbc7
The code is separated into a new x86ModelParseSignature function.
99cbc7
99cbc7
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
(cherry picked from commit fe78d2fda9f2dd67eb9daa98e48fbffa468d271e)
99cbc7
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1558558
99cbc7
https://bugzilla.redhat.com/show_bug.cgi?id=1687515
99cbc7
99cbc7
Conflicts:
99cbc7
	src/cpu/cpu_x86.c
99cbc7
            - other patches separating parts of x86ModelParse into
99cbc7
              smaller functions were not backported due to conflicts
99cbc7
              with older refactoring which is missing in RHEL-7
99cbc7
            - commit 118fcdd480ad38a3e8477f466f6a876dce7e9fa6 changing
99cbc7
              goto labels from "cleanup" to "error" was not backported
99cbc7
              because the goto statement is removed in this patch anyway
99cbc7
99cbc7
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
99cbc7
Reviewed-by: Ján Tomko <jtomko@redhat.com>
99cbc7
---
99cbc7
 src/cpu/cpu_x86.c | 58 ++++++++++++++++++++++++++++-------------------
99cbc7
 1 file changed, 35 insertions(+), 23 deletions(-)
99cbc7
99cbc7
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
99cbc7
index 809da94117..668e8aa3f0 100644
99cbc7
--- a/src/cpu/cpu_x86.c
99cbc7
+++ b/src/cpu/cpu_x86.c
99cbc7
@@ -1184,6 +1184,39 @@ x86ModelCompare(virCPUx86ModelPtr model1,
99cbc7
 }
99cbc7
 
99cbc7
 
99cbc7
+static int
99cbc7
+x86ModelParseSignature(virCPUx86ModelPtr model,
99cbc7
+                       xmlXPathContextPtr ctxt)
99cbc7
+{
99cbc7
+
99cbc7
+    if (virXPathBoolean("boolean(./signature)", ctxt)) {
99cbc7
+        unsigned int sigFamily = 0;
99cbc7
+        unsigned int sigModel = 0;
99cbc7
+        int rc;
99cbc7
+
99cbc7
+        rc = virXPathUInt("string(./signature/@family)", ctxt, &sigFamily);
99cbc7
+        if (rc < 0 || sigFamily == 0) {
99cbc7
+            virReportError(VIR_ERR_INTERNAL_ERROR,
99cbc7
+                           _("Invalid CPU signature family in model %s"),
99cbc7
+                           model->name);
99cbc7
+            return -1;
99cbc7
+        }
99cbc7
+
99cbc7
+        rc = virXPathUInt("string(./signature/@model)", ctxt, &sigModel);
99cbc7
+        if (rc < 0 || sigModel == 0) {
99cbc7
+            virReportError(VIR_ERR_INTERNAL_ERROR,
99cbc7
+                           _("Invalid CPU signature model in model %s"),
99cbc7
+                           model->name);
99cbc7
+            return -1;
99cbc7
+        }
99cbc7
+
99cbc7
+        model->signature = x86MakeSignature(sigFamily, sigModel, 0);
99cbc7
+    }
99cbc7
+
99cbc7
+    return 0;
99cbc7
+}
99cbc7
+
99cbc7
+
99cbc7
 static virCPUx86ModelPtr
99cbc7
 x86ModelParse(xmlXPathContextPtr ctxt,
99cbc7
               virCPUx86MapPtr map)
99cbc7
@@ -1232,29 +1265,8 @@ x86ModelParse(xmlXPathContextPtr ctxt,
99cbc7
             goto error;
99cbc7
     }
99cbc7
 
99cbc7
-    if (virXPathBoolean("boolean(./signature)", ctxt)) {
99cbc7
-        unsigned int sigFamily = 0;
99cbc7
-        unsigned int sigModel = 0;
99cbc7
-        int rc;
99cbc7
-
99cbc7
-        rc = virXPathUInt("string(./signature/@family)", ctxt, &sigFamily);
99cbc7
-        if (rc < 0 || sigFamily == 0) {
99cbc7
-            virReportError(VIR_ERR_INTERNAL_ERROR,
99cbc7
-                           _("Invalid CPU signature family in model %s"),
99cbc7
-                           model->name);
99cbc7
-            goto cleanup;
99cbc7
-        }
99cbc7
-
99cbc7
-        rc = virXPathUInt("string(./signature/@model)", ctxt, &sigModel);
99cbc7
-        if (rc < 0 || sigModel == 0) {
99cbc7
-            virReportError(VIR_ERR_INTERNAL_ERROR,
99cbc7
-                           _("Invalid CPU signature model in model %s"),
99cbc7
-                           model->name);
99cbc7
-            goto cleanup;
99cbc7
-        }
99cbc7
-
99cbc7
-        model->signature = x86MakeSignature(sigFamily, sigModel, 0);
99cbc7
-    }
99cbc7
+    if (x86ModelParseSignature(model, ctxt) < 0)
99cbc7
+        goto error;
99cbc7
 
99cbc7
     if (virXPathBoolean("boolean(./vendor)", ctxt)) {
99cbc7
         vendor = virXPathString("string(./vendor/@name)", ctxt);
99cbc7
-- 
99cbc7
2.21.0
99cbc7