]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
conf: numa: Don't fetch XML node count in virDomainNumatuneParseXML
authorPeter Krempa <pkrempa@redhat.com>
Wed, 5 Oct 2022 10:33:19 +0000 (12:33 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 2 Nov 2022 08:20:57 +0000 (09:20 +0100)
The code only wants to refuse cases where more than one 'numatune'
element is present which can be achieved by using 'virXPathBoolean'.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/numa_conf.c

index 390ef49b8412eee6bf1edc52a1a76b564a84cbc2..688aa7b40914e9be1cdafbce580195ff6e53424f 100644 (file)
@@ -226,18 +226,13 @@ virDomainNumatuneParseXML(virDomainNuma *numa,
 {
     g_autofree char *modestr = NULL;
     int mode = -1;
-    int n = 0;
     g_autofree char *placementstr = NULL;
     int placement = -1;
     g_autofree char *nodesetstr = NULL;
     g_autoptr(virBitmap) nodeset = NULL;
     xmlNodePtr node = NULL;
 
-    if (virXPathInt("count(./numatune)", ctxt, &n) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("cannot extract numatune nodes"));
-        return -1;
-    } else if (n > 1) {
+    if (virXPathBoolean("count(./numatune) > 1", ctxt) == 1) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("only one numatune is supported"));
         return -1;