Blame SOURCES/libvirt-qemuDomainDeviceDefValidateNetwork-Check-for-range-only-if-IP-prefix-set.patch

edecca
From 46deb7c0c9e483ba57e9f9638e31482a9af026c9 Mon Sep 17 00:00:00 2001
edecca
Message-Id: <46deb7c0c9e483ba57e9f9638e31482a9af026c9@dist-git>
edecca
From: Michal Privoznik <mprivozn@redhat.com>
edecca
Date: Mon, 9 Jul 2018 12:07:39 +0200
edecca
Subject: [PATCH] qemuDomainDeviceDefValidateNetwork: Check for range only if
edecca
 IP prefix set
edecca
edecca
https://bugzilla.redhat.com/show_bug.cgi?id=1515533
edecca
edecca
The @prefix attribute to <ip/> element for interface type user is
edecca
optional. Therefore, if left out it has value of zero in which
edecca
case we should not check whether it falls into <4, 27> range.
edecca
Otherwise we fail parsing domain XML for no good reason.
edecca
edecca
Broken by commit b62b8090b2ad4524a5bf9d40d0d1c17a9d57f5a0.
edecca
edecca
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
edecca
(cherry picked from commit a6fbbce73e2965edde45ece7c034e4b39bb8405d)
edecca
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
edecca
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
edecca
---
edecca
 src/qemu/qemu_domain.c | 3 ++-
edecca
 1 file changed, 2 insertions(+), 1 deletion(-)
edecca
edecca
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
edecca
index fa952f8306..f9bcf76f44 100644
edecca
--- a/src/qemu/qemu_domain.c
edecca
+++ b/src/qemu/qemu_domain.c
edecca
@@ -4386,7 +4386,8 @@ qemuDomainDeviceDefValidateNetwork(const virDomainNetDef *net)
edecca
                 }
edecca
                 hasIPv4 = true;
edecca
 
edecca
-                if (ip->prefix < 4 || ip->prefix > 27) {
edecca
+                if (ip->prefix > 0 &&
edecca
+                    (ip->prefix < 4 || ip->prefix > 27)) {
edecca
                     virReportError(VIR_ERR_XML_ERROR, "%s",
edecca
                                    _("invalid prefix, must be in range of 4-27"));
edecca
                     return -1;
edecca
-- 
edecca
2.18.0
edecca