mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 11:22:23 +00:00
qemu: capabilities: Convert virQEMUCapsLoadCache to virXMLParse
Use virXMLParse so that the code doesn't have to explicitly allocate an XPath context and validate the root element. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
5d2f69aa68
commit
9b3828e263
@ -4351,22 +4351,9 @@ virQEMUCapsLoadCache(virArch hostArch,
|
||||
long long int l;
|
||||
unsigned long lu;
|
||||
|
||||
if (!(doc = virXMLParseFile(filename)))
|
||||
if (!(doc = virXMLParse(filename, NULL, NULL, "qemuCaps", &ctxt, NULL, false)))
|
||||
return -1;
|
||||
|
||||
if (!(ctxt = virXMLXPathContextNew(doc)))
|
||||
return -1;
|
||||
|
||||
ctxt->node = xmlDocGetRootElement(doc);
|
||||
|
||||
if (STRNEQ((const char *)ctxt->node->name, "qemuCaps")) {
|
||||
virReportError(VIR_ERR_XML_ERROR,
|
||||
_("unexpected root element <%s>, "
|
||||
"expecting <qemuCaps>"),
|
||||
ctxt->node->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virXPathLongLong("string(./selfctime)", ctxt, &l) < 0) {
|
||||
virReportError(VIR_ERR_XML_ERROR, "%s",
|
||||
_("missing selfctime in QEMU capabilities XML"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user