]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainControllerDefParseXML: Reject '-1' for PCI controller target properties
authorPeter Krempa <pkrempa@redhat.com>
Fri, 26 Aug 2022 12:02:52 +0000 (14:02 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 1 Sep 2022 11:11:10 +0000 (13:11 +0200)
All of the properties use '-1' as default and the code omits formatting
them when the property is '-1'. Additionally subsequent validation code
rejects all other negative values anyways.

Since we've never formatted '-1' into an XML formatted by libvirt we can
make the parser more strict, as we will never fail to parse existing
on-disk libvirt-owned XMLs.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2121627
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/domain_conf.c

index 6db608431ab137c1c9cf64f24463f7bc1c871bb8..237f1d683573f346cfd7a16a159e22f06578e376 100644 (file)
@@ -8205,22 +8205,22 @@ virDomainControllerDefParseXML(virDomainXMLOption *xmlopt,
 
     if (ntargetNodes == 1) {
         if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI) {
-            if (virXMLPropInt(targetNodes[0], "chassisNr", 0, VIR_XML_PROP_NONE,
+            if (virXMLPropInt(targetNodes[0], "chassisNr", 0, VIR_XML_PROP_NONNEGATIVE,
                               &def->opts.pciopts.chassisNr,
                               def->opts.pciopts.chassisNr) < 0)
                 return NULL;
 
-            if (virXMLPropInt(targetNodes[0], "chassis", 0, VIR_XML_PROP_NONE,
+            if (virXMLPropInt(targetNodes[0], "chassis", 0, VIR_XML_PROP_NONNEGATIVE,
                               &def->opts.pciopts.chassis,
                               def->opts.pciopts.chassis) < 0)
                 return NULL;
 
-            if (virXMLPropInt(targetNodes[0], "port", 0, VIR_XML_PROP_NONE,
+            if (virXMLPropInt(targetNodes[0], "port", 0, VIR_XML_PROP_NONNEGATIVE,
                               &def->opts.pciopts.port,
                               def->opts.pciopts.port) < 0)
                 return NULL;
 
-            if (virXMLPropInt(targetNodes[0], "busNr", 0, VIR_XML_PROP_NONE,
+            if (virXMLPropInt(targetNodes[0], "busNr", 0, VIR_XML_PROP_NONNEGATIVE,
                               &def->opts.pciopts.busNr,
                               def->opts.pciopts.busNr) < 0)
                 return NULL;