]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: capabilities: Convert virQEMUCapsLoadCache to virXMLParse
authorPeter Krempa <pkrempa@redhat.com>
Fri, 23 Sep 2022 12:47:12 +0000 (14:47 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 6 Oct 2022 08:54:25 +0000 (10:54 +0200)
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>
src/qemu/qemu_capabilities.c

index 50bde370e8e077a3ca2e6fd96425efb51c152ce3..68aefe1d86cc389496e170c47b654af584c8717e 100644 (file)
@@ -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"));