[PATCH 37/43] qemu: capabilities: Convert virQEMUCapsLoadCache to virXMLParse

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/qemu/qemu_capabilities.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index e84310c79a..146c3daa39 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -4359,22 +4359,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"));
-- 
2.37.3




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux