From: Jiri Denemark Date: Fri, 22 Feb 2019 14:32:44 +0000 (+0100) Subject: cpu_x86: Separate signature parsing from x86ModelParse X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=fe78d2fda9f2dd67eb9daa98e48fbffa468d271e;p=libvirt.git cpu_x86: Separate signature parsing from x86ModelParse The code is separated into a new x86ModelParseSignature function. Signed-off-by: Jiri Denemark Reviewed-by: Ján Tomko --- diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 8a0ff50afe..b254c58b08 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -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) {