From: Peter Krempa Date: Thu, 22 Sep 2022 13:58:16 +0000 (+0200) Subject: tests: qemuxml2argv: Use virXMLParse properly X-Git-Tag: v8.9.0-rc1~125 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1cd64b7326c6c7c4d4880a4645527ee89e4e528d;p=thirdparty%2Flibvirt.git tests: qemuxml2argv: Use virXMLParse properly Don't validate the root node and don't allocate a private XPath context when virXMLParse can do that internally. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 825273c8c6..4722c79a4f 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -626,7 +626,6 @@ testCompareXMLToArgv(const void *data) qemuDomainObjPrivate *priv = NULL; g_autoptr(xmlDoc) xml = NULL; g_autoptr(xmlXPathContext) ctxt = NULL; - xmlNodePtr root; g_autofree char *archstr = NULL; virArch arch = VIR_ARCH_NONE; g_autoptr(virIdentity) sysident = virIdentityGetSystem(); @@ -673,21 +672,9 @@ testCompareXMLToArgv(const void *data) goto cleanup; if (!(xml = virXMLParse(info->infile, NULL, "(domain_definition)", - NULL, NULL, NULL, false))) + "domain", &ctxt, NULL, false))) goto cleanup; - root = xmlDocGetRootElement(xml); - if (!virXMLNodeNameEqual(root, "domain")) { - VIR_TEST_VERBOSE("unexpected root element <%s>, expecting ", - root->name); - goto cleanup; - } - - if (!(ctxt = virXMLXPathContextNew(xml))) - goto cleanup; - - ctxt->node = root; - if ((archstr = virXPathString("string(./os/type[1]/@arch)", ctxt))) arch = virArchFromString(archstr); @@ -722,7 +709,7 @@ testCompareXMLToArgv(const void *data) parseFlags |= VIR_DOMAIN_DEF_PARSE_INACTIVE; - if (!(vm->def = virDomainDefParseNode(xml, root, driver.xmlopt, NULL, + if (!(vm->def = virDomainDefParseNode(xml, ctxt->node, driver.xmlopt, NULL, parseFlags))) { err = virGetLastError(); if (!err) {