[PATCH 41/43] security: aa-helper: Use virXMLParse instead of virXMLParseString

Peter Krempa pkrempa at redhat.com
Tue Oct 4 08:33:15 UTC 2022


Use the helper with more features to validate the root XML element name
instead of open-coding it.

Signed-off-by: Peter Krempa <pkrempa at redhat.com>
---
 src/security/virt-aa-helper.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index f338488da3..33d600c00b 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -571,13 +571,8 @@ caps_mockup(vahControl * ctl, const char *xmlStr)
     g_autoptr(xmlXPathContext) ctxt = NULL;
     char *arch;

-    if (!(xml = virXMLParseStringCtxt(xmlStr, _("(domain_definition)"),
-                                      &ctxt))) {
-        return -1;
-    }
-
-    if (!virXMLNodeNameEqual(ctxt->node, "domain")) {
-        vah_error(NULL, 0, _("unexpected root element, expecting <domain>"));
+    if (!(xml = virXMLParse(NULL, xmlStr, _("(domain_definition)"),
+                            "domain", &ctxt, NULL, false))) {
         return -1;
     }

-- 
2.37.3



More information about the libvir-list mailing list