]> xenbits.xensource.com Git - libvirt.git/commitdiff
cpu_x86: Separate signature parsing from x86ModelParse
authorJiri Denemark <jdenemar@redhat.com>
Fri, 22 Feb 2019 14:32:44 +0000 (15:32 +0100)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 5 Mar 2019 13:38:50 +0000 (14:38 +0100)
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>
src/cpu/cpu_x86.c

index 8a0ff50afe20f610649b11411827b9d8574193b2..b254c58b087b3ff0b16c1a2d6d9e53ff094105cd 100644 (file)
@@ -1187,26 +1187,9 @@ x86ModelParseAncestor(virCPUx86ModelPtr model,
 
 
 static int
-x86ModelParse(xmlXPathContextPtr ctxt,
-              const char *name,
-              void *data)
+x86ModelParseSignature(virCPUx86ModelPtr model,
+                       xmlXPathContextPtr ctxt)
 {
-    virCPUx86MapPtr map = data;
-    xmlNodePtr *nodes = NULL;
-    virCPUx86ModelPtr model;
-    char *vendor = NULL;
-    size_t i;
-    int n;
-    int ret = -1;
-
-    if (!(model = x86ModelNew()))
-        goto cleanup;
-
-    if (VIR_STRDUP(model->name, name) < 0)
-        goto cleanup;
-
-    if (x86ModelParseAncestor(model, ctxt, map) < 0)
-        goto cleanup;
 
     if (virXPathBoolean("boolean(./signature)", ctxt)) {
         unsigned int sigFamily = 0;
@@ -1218,7 +1201,7 @@ x86ModelParse(xmlXPathContextPtr ctxt,
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Invalid CPU signature family in model %s"),
                            model->name);
-            goto cleanup;
+            return -1;
         }
 
         rc = virXPathUInt("string(./signature/@model)", ctxt, &sigModel);
@@ -1226,12 +1209,41 @@ x86ModelParse(xmlXPathContextPtr ctxt,
             virReportError(VIR_ERR_INTERNAL_ERROR,
                            _("Invalid CPU signature model in model %s"),
                            model->name);
-            goto cleanup;
+            return -1;
         }
 
         model->signature = x86MakeSignature(sigFamily, sigModel, 0);
     }
 
+    return 0;
+}
+
+
+static int
+x86ModelParse(xmlXPathContextPtr ctxt,
+              const char *name,
+              void *data)
+{
+    virCPUx86MapPtr map = data;
+    xmlNodePtr *nodes = NULL;
+    virCPUx86ModelPtr model;
+    char *vendor = NULL;
+    size_t i;
+    int n;
+    int ret = -1;
+
+    if (!(model = x86ModelNew()))
+        goto cleanup;
+
+    if (VIR_STRDUP(model->name, name) < 0)
+        goto cleanup;
+
+    if (x86ModelParseAncestor(model, ctxt, map) < 0)
+        goto cleanup;
+
+    if (x86ModelParseSignature(model, ctxt) < 0)
+        goto cleanup;
+
     if (virXPathBoolean("boolean(./vendor)", ctxt)) {
         vendor = virXPathString("string(./vendor/@name)", ctxt);
         if (!vendor) {