mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
cpu_x86: Simplify x86ParseMSR
... by using virXMLProp*() helpers. These only require a xmlNodePtr and do not need a xmlXPathContextPtr. Reflect that in the function signature. Signed-off-by: Tim Wiederhake <twiederh@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
3092ee9e9e
commit
cab9be89b9
@ -1046,26 +1046,22 @@ x86ParseCPUID(xmlNodePtr node,
|
|||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
x86ParseMSR(xmlXPathContextPtr ctxt,
|
x86ParseMSR(xmlNodePtr node,
|
||||||
virCPUx86DataItem *item)
|
virCPUx86DataItem *item)
|
||||||
{
|
{
|
||||||
virCPUx86MSR *msr;
|
virCPUx86MSR msr;
|
||||||
unsigned long index;
|
|
||||||
unsigned long eax;
|
|
||||||
unsigned long edx;
|
|
||||||
|
|
||||||
memset(item, 0, sizeof(*item));
|
memset(&msr, 0, sizeof(msr));
|
||||||
|
|
||||||
if (virXPathULongHex("string(@index)", ctxt, &index) < 0 ||
|
if (virXMLPropUInt(node, "index", 0, VIR_XML_PROP_REQUIRED, &msr.index) < 0)
|
||||||
virXPathULongHex("string(@eax)", ctxt, &eax) < 0 ||
|
return -1;
|
||||||
virXPathULongHex("string(@edx)", ctxt, &edx) < 0)
|
if (virXMLPropUInt(node, "eax", 0, VIR_XML_PROP_REQUIRED, &msr.eax) < 0)
|
||||||
|
return -1;
|
||||||
|
if (virXMLPropUInt(node, "edx", 0, VIR_XML_PROP_REQUIRED, &msr.edx) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
item->type = VIR_CPU_X86_DATA_MSR;
|
item->type = VIR_CPU_X86_DATA_MSR;
|
||||||
msr = &item->data.msr;
|
item->data.msr = msr;
|
||||||
msr->index = index;
|
|
||||||
msr->eax = eax;
|
|
||||||
msr->edx = edx;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1118,7 +1114,7 @@ x86FeatureParse(xmlXPathContextPtr ctxt,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (x86ParseMSR(ctxt, &item) < 0) {
|
if (x86ParseMSR(ctxt->node, &item) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("Invalid msr[%zu] in %s feature"),
|
_("Invalid msr[%zu] in %s feature"),
|
||||||
i, feature->name);
|
i, feature->name);
|
||||||
@ -1807,7 +1803,7 @@ virCPUx86DataParse(xmlXPathContextPtr ctxt)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (x86ParseMSR(ctxt, &item) < 0) {
|
if (x86ParseMSR(ctxt->node, &item) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("failed to parse msr[%zu]"), i);
|
_("failed to parse msr[%zu]"), i);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user