]> xenbits.xensource.com Git - libvirt.git/commitdiff
virDomainDeviceInfoParseXML: Reject '0' value for ACPI index
authorPeter Krempa <pkrempa@redhat.com>
Tue, 18 Jan 2022 14:43:42 +0000 (15:43 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 19 Jan 2022 15:54:32 +0000 (16:54 +0100)
Value of '0' is treated equivalently to when it's not provided by the
user. Reject an explicit '0' provided by the user as it would get
ignored.

In this rare case we can make the XML parser more strict, as libvirt
would never format the '<acpi/>' element if the index is '0' thus there
are no libvirt-generated XMLs we'd not load back, as of such this is
identical to rejecting it in the validation phase.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2037146
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/domain_conf.c

index a805f7f6a3412f779281853a72fb0af1f8b8b074..393f9d94784826fef90c0a4ec016a91d3c10463e 100644 (file)
@@ -6786,7 +6786,7 @@ virDomainDeviceInfoParseXML(virDomainXMLOption *xmlopt,
     }
 
     if ((acpi = virXPathNode("./acpi", ctxt))) {
-        if (virXMLPropUInt(acpi, "index", 10, VIR_XML_PROP_NONE,
+        if (virXMLPropUInt(acpi, "index", 10, VIR_XML_PROP_NONZERO,
                            &info->acpiIndex) < 0)
             goto cleanup;
     }