c313de
From e7b8b38fe1fe7e7d8eb9fab6cb3ded16652f60f8 Mon Sep 17 00:00:00 2001
c313de
Message-Id: <e7b8b38fe1fe7e7d8eb9fab6cb3ded16652f60f8@dist-git>
c313de
From: Jiri Denemark <jdenemar@redhat.com>
c313de
Date: Fri, 21 Jun 2019 09:24:55 +0200
c313de
Subject: [PATCH] cpu_x86: Separate signature parsing from x86ModelParse
c313de
MIME-Version: 1.0
c313de
Content-Type: text/plain; charset=UTF-8
c313de
Content-Transfer-Encoding: 8bit
c313de
c313de
The code is separated into a new x86ModelParseSignature function.
c313de
c313de
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c313de
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c313de
(cherry picked from commit fe78d2fda9f2dd67eb9daa98e48fbffa468d271e)
c313de
c313de
https://bugzilla.redhat.com/show_bug.cgi?id=1686895
c313de
c313de
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
c313de
Message-Id: <616b60991bfdaa735804b839e258f6f1fa409a7b.1561068591.git.jdenemar@redhat.com>
c313de
Reviewed-by: Ján Tomko <jtomko@redhat.com>
c313de
---
c313de
 src/cpu/cpu_x86.c | 58 ++++++++++++++++++++++++++++-------------------
c313de
 1 file changed, 35 insertions(+), 23 deletions(-)
c313de
c313de
diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
c313de
index 64788d60b3..119ece4758 100644
c313de
--- a/src/cpu/cpu_x86.c
c313de
+++ b/src/cpu/cpu_x86.c
c313de
@@ -1184,6 +1184,39 @@ x86ModelParseAncestor(virCPUx86ModelPtr model,
c313de
 }
c313de
 
c313de
 
c313de
+static int
c313de
+x86ModelParseSignature(virCPUx86ModelPtr model,
c313de
+                       xmlXPathContextPtr ctxt)
c313de
+{
c313de
+
c313de
+    if (virXPathBoolean("boolean(./signature)", ctxt)) {
c313de
+        unsigned int sigFamily = 0;
c313de
+        unsigned int sigModel = 0;
c313de
+        int rc;
c313de
+
c313de
+        rc = virXPathUInt("string(./signature/@family)", ctxt, &sigFamily);
c313de
+        if (rc < 0 || sigFamily == 0) {
c313de
+            virReportError(VIR_ERR_INTERNAL_ERROR,
c313de
+                           _("Invalid CPU signature family in model %s"),
c313de
+                           model->name);
c313de
+            return -1;
c313de
+        }
c313de
+
c313de
+        rc = virXPathUInt("string(./signature/@model)", ctxt, &sigModel);
c313de
+        if (rc < 0 || sigModel == 0) {
c313de
+            virReportError(VIR_ERR_INTERNAL_ERROR,
c313de
+                           _("Invalid CPU signature model in model %s"),
c313de
+                           model->name);
c313de
+            return -1;
c313de
+        }
c313de
+
c313de
+        model->signature = x86MakeSignature(sigFamily, sigModel, 0);
c313de
+    }
c313de
+
c313de
+    return 0;
c313de
+}
c313de
+
c313de
+
c313de
 static int
c313de
 x86ModelParse(xmlXPathContextPtr ctxt,
c313de
               const char *name,
c313de
@@ -1206,29 +1239,8 @@ x86ModelParse(xmlXPathContextPtr ctxt,
c313de
     if (x86ModelParseAncestor(model, ctxt, map) < 0)
c313de
         goto cleanup;
c313de
 
c313de
-    if (virXPathBoolean("boolean(./signature)", ctxt)) {
c313de
-        unsigned int sigFamily = 0;
c313de
-        unsigned int sigModel = 0;
c313de
-        int rc;
c313de
-
c313de
-        rc = virXPathUInt("string(./signature/@family)", ctxt, &sigFamily);
c313de
-        if (rc < 0 || sigFamily == 0) {
c313de
-            virReportError(VIR_ERR_INTERNAL_ERROR,
c313de
-                           _("Invalid CPU signature family in model %s"),
c313de
-                           model->name);
c313de
-            goto cleanup;
c313de
-        }
c313de
-
c313de
-        rc = virXPathUInt("string(./signature/@model)", ctxt, &sigModel);
c313de
-        if (rc < 0 || sigModel == 0) {
c313de
-            virReportError(VIR_ERR_INTERNAL_ERROR,
c313de
-                           _("Invalid CPU signature model in model %s"),
c313de
-                           model->name);
c313de
-            goto cleanup;
c313de
-        }
c313de
-
c313de
-        model->signature = x86MakeSignature(sigFamily, sigModel, 0);
c313de
-    }
c313de
+    if (x86ModelParseSignature(model, ctxt) < 0)
c313de
+        goto cleanup;
c313de
 
c313de
     if (virXPathBoolean("boolean(./vendor)", ctxt)) {
c313de
         vendor = virXPathString("string(./vendor/@name)", ctxt);
c313de
-- 
c313de
2.22.0
c313de