mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-02 09:55:18 +00:00
cpu_x86: Separate vendor parsing from x86ModelParse
The code is separated into a new x86ModelParseVendor function. Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
fe78d2fda9
commit
232266839c
@ -1219,6 +1219,36 @@ x86ModelParseSignature(virCPUx86ModelPtr model,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int
|
||||||
|
x86ModelParseVendor(virCPUx86ModelPtr model,
|
||||||
|
xmlXPathContextPtr ctxt,
|
||||||
|
virCPUx86MapPtr map)
|
||||||
|
{
|
||||||
|
VIR_AUTOFREE(char *) vendor = NULL;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
if ((rc = virXPathBoolean("boolean(./vendor)", ctxt)) <= 0)
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
vendor = virXPathString("string(./vendor/@name)", ctxt);
|
||||||
|
if (!vendor) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Invalid vendor element in CPU model %s"),
|
||||||
|
model->name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(model->vendor = x86VendorFind(map, vendor))) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Unknown vendor %s referenced by CPU model %s"),
|
||||||
|
vendor, model->name);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
x86ModelParse(xmlXPathContextPtr ctxt,
|
x86ModelParse(xmlXPathContextPtr ctxt,
|
||||||
const char *name,
|
const char *name,
|
||||||
@ -1227,7 +1257,6 @@ x86ModelParse(xmlXPathContextPtr ctxt,
|
|||||||
virCPUx86MapPtr map = data;
|
virCPUx86MapPtr map = data;
|
||||||
xmlNodePtr *nodes = NULL;
|
xmlNodePtr *nodes = NULL;
|
||||||
virCPUx86ModelPtr model;
|
virCPUx86ModelPtr model;
|
||||||
char *vendor = NULL;
|
|
||||||
size_t i;
|
size_t i;
|
||||||
int n;
|
int n;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
@ -1244,22 +1273,8 @@ x86ModelParse(xmlXPathContextPtr ctxt,
|
|||||||
if (x86ModelParseSignature(model, ctxt) < 0)
|
if (x86ModelParseSignature(model, ctxt) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virXPathBoolean("boolean(./vendor)", ctxt)) {
|
if (x86ModelParseVendor(model, ctxt, map) < 0)
|
||||||
vendor = virXPathString("string(./vendor/@name)", ctxt);
|
goto cleanup;
|
||||||
if (!vendor) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Invalid vendor element in CPU model %s"),
|
|
||||||
model->name);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(model->vendor = x86VendorFind(map, vendor))) {
|
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Unknown vendor %s referenced by CPU model %s"),
|
|
||||||
vendor, model->name);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
n = virXPathNodeSet("./feature", ctxt, &nodes);
|
n = virXPathNodeSet("./feature", ctxt, &nodes);
|
||||||
if (n < 0)
|
if (n < 0)
|
||||||
@ -1295,7 +1310,6 @@ x86ModelParse(xmlXPathContextPtr ctxt,
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
x86ModelFree(model);
|
x86ModelFree(model);
|
||||||
VIR_FREE(vendor);
|
|
||||||
VIR_FREE(nodes);
|
VIR_FREE(nodes);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user