render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
Blob Blame History Raw
From e7b8b38fe1fe7e7d8eb9fab6cb3ded16652f60f8 Mon Sep 17 00:00:00 2001
Message-Id: <e7b8b38fe1fe7e7d8eb9fab6cb3ded16652f60f8@dist-git>
From: Jiri Denemark <jdenemar@redhat.com>
Date: Fri, 21 Jun 2019 09:24:55 +0200
Subject: [PATCH] cpu_x86: Separate signature parsing from x86ModelParse
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The code is separated into a new x86ModelParseSignature function.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit fe78d2fda9f2dd67eb9daa98e48fbffa468d271e)

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Message-Id: <616b60991bfdaa735804b839e258f6f1fa409a7b.1561068591.git.jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
---
 src/cpu/cpu_x86.c | 58 ++++++++++++++++++++++++++++-------------------
 1 file changed, 35 insertions(+), 23 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index 64788d60b3..119ece4758 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -1184,6 +1184,39 @@ x86ModelParseAncestor(virCPUx86ModelPtr model,
 }
 
 
+static int
+x86ModelParseSignature(virCPUx86ModelPtr model,
+                       xmlXPathContextPtr ctxt)
+{
+
+    if (virXPathBoolean("boolean(./signature)", ctxt)) {
+        unsigned int sigFamily = 0;
+        unsigned int sigModel = 0;
+        int rc;
+
+        rc = virXPathUInt("string(./signature/@family)", ctxt, &sigFamily);
+        if (rc < 0 || sigFamily == 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("Invalid CPU signature family in model %s"),
+                           model->name);
+            return -1;
+        }
+
+        rc = virXPathUInt("string(./signature/@model)", ctxt, &sigModel);
+        if (rc < 0 || sigModel == 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("Invalid CPU signature model in model %s"),
+                           model->name);
+            return -1;
+        }
+
+        model->signature = x86MakeSignature(sigFamily, sigModel, 0);
+    }
+
+    return 0;
+}
+
+
 static int
 x86ModelParse(xmlXPathContextPtr ctxt,
               const char *name,
@@ -1206,29 +1239,8 @@ x86ModelParse(xmlXPathContextPtr ctxt,
     if (x86ModelParseAncestor(model, ctxt, map) < 0)
         goto cleanup;
 
-    if (virXPathBoolean("boolean(./signature)", ctxt)) {
-        unsigned int sigFamily = 0;
-        unsigned int sigModel = 0;
-        int rc;
-
-        rc = virXPathUInt("string(./signature/@family)", ctxt, &sigFamily);
-        if (rc < 0 || sigFamily == 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Invalid CPU signature family in model %s"),
-                           model->name);
-            goto cleanup;
-        }
-
-        rc = virXPathUInt("string(./signature/@model)", ctxt, &sigModel);
-        if (rc < 0 || sigModel == 0) {
-            virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("Invalid CPU signature model in model %s"),
-                           model->name);
-            goto cleanup;
-        }
-
-        model->signature = x86MakeSignature(sigFamily, sigModel, 0);
-    }
+    if (x86ModelParseSignature(model, ctxt) < 0)
+        goto cleanup;
 
     if (virXPathBoolean("boolean(./vendor)", ctxt)) {
         vendor = virXPathString("string(./vendor/@name)", ctxt);
-- 
2.22.0