[libvirt] [PATCH] qemuDomainDeviceDefValidateNetwork: Check for range only if IP prefix set

Michal Privoznik posted 1 patch 5 years, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/df70a168f93689ded6fccad01019f63207731b16.1530284172.git.mprivozn@redhat.com
Test syntax-check passed
src/qemu/qemu_domain.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[libvirt] [PATCH] qemuDomainDeviceDefValidateNetwork: Check for range only if IP prefix set
Posted by Michal Privoznik 5 years, 10 months ago
The @prefix attribute to <ip/> element for interface type user is
optional. Therefore, if left out it has value of zero in which
case we should not check whether it falls into <4, 27> range.
Otherwise we fail parsing domain XML for no good reason.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/qemu/qemu_domain.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index afd572fc5e..c1798edf41 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -4373,7 +4373,8 @@ qemuDomainDeviceDefValidateNetwork(const virDomainNetDef *net)
                 }
                 hasIPv4 = true;
 
-                if (ip->prefix < 4 || ip->prefix > 27) {
+                if (ip->prefix > 0 &&
+                    (ip->prefix < 4 || ip->prefix > 27)) {
                     virReportError(VIR_ERR_XML_ERROR, "%s",
                                    _("invalid prefix, must be in range of 4-27"));
                     return -1;
-- 
2.16.4

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] qemuDomainDeviceDefValidateNetwork: Check for range only if IP prefix set
Posted by Peter Krempa 5 years, 9 months ago
On Fri, Jun 29, 2018 at 16:56:12 +0200, Michal Privoznik wrote:
> The @prefix attribute to <ip/> element for interface type user is
> optional. Therefore, if left out it has value of zero in which
> case we should not check whether it falls into <4, 27> range.
> Otherwise we fail parsing domain XML for no good reason.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>

Broken in commit b62b8090b2ad4524a5bf9d40d0d1c17a9d57f5a0

also since this patch originates from the bugzilla mentioned in the
above commit you should add it here as well.

> ---
>  src/qemu/qemu_domain.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index afd572fc5e..c1798edf41 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -4373,7 +4373,8 @@ qemuDomainDeviceDefValidateNetwork(const virDomainNetDef *net)
>                  }
>                  hasIPv4 = true;
>  
> -                if (ip->prefix < 4 || ip->prefix > 27) {
> +                if (ip->prefix > 0 &&
> +                    (ip->prefix < 4 || ip->prefix > 27)) {
>                      virReportError(VIR_ERR_XML_ERROR, "%s",
>                                     _("invalid prefix, must be in range of 4-27"));
>                      return -1;

ACK with the commit message ammended.
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list