]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainControllerDefParseXML: Fix broken error reporting when parsing 'index'
authorPeter Krempa <pkrempa@redhat.com>
Fri, 26 Aug 2022 11:28:47 +0000 (13:28 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 1 Sep 2022 11:11:10 +0000 (13:11 +0200)
The code attempted to report an error if the user added the 'index'
attribute to the 'target' element, but neglected to actually return an
error code.

Fix it by using the VIR_XML_PROP_NONNEGATIVE flag for virXMLPropInt
which refuses user passed negative numbers.

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

index 14fad39078a95378642588c710bb0ea53a5a8e59..219951f305875b6b138dd228d7206150ab836988 100644 (file)
@@ -8233,15 +8233,10 @@ virDomainControllerDefParseXML(virDomainXMLOption *xmlopt,
                                          &def->opts.pciopts.hotplug) < 0)
                 return NULL;
 
-            if ((rc = virXMLPropInt(targetNodes[0], "index", 0, VIR_XML_PROP_NONE,
-                                    &def->opts.pciopts.targetIndex,
-                                    def->opts.pciopts.targetIndex)) < 0)
+            if (virXMLPropInt(targetNodes[0], "index", 0, VIR_XML_PROP_NONNEGATIVE,
+                              &def->opts.pciopts.targetIndex,
+                              def->opts.pciopts.targetIndex) < 0)
                 return NULL;
-
-            if ((rc == 1) && def->opts.pciopts.targetIndex == -1)
-                virReportError(VIR_ERR_XML_ERROR,
-                               _("Invalid target index '%i' in PCI controller"),
-                               def->opts.pciopts.targetIndex);
         }
     } else if (ntargetNodes > 1) {
         virReportError(VIR_ERR_XML_ERROR, "%s",