render / rpms / libvirt

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