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

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