render / rpms / libvirt

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