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

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