virt-manager/0010-network-Fix-parsing-ip-blocks-with-prefix.patch
Cole Robinson 2184a94698 Use correct KVM package names on first run (bz #873878)
network: fix parsing ip blocks with prefix= (bz #872814)
Don't recommend all of libvirt, just the kvm bits (bz #872246)
2012-12-17 14:55:20 -05:00

50 lines
1.8 KiB
Diff

From 820f78af13b564600d600a199d6ef30aecde620e Mon Sep 17 00:00:00 2001
Message-Id: <820f78af13b564600d600a199d6ef30aecde620e.1355773837.git.crobinso@redhat.com>
In-Reply-To: <8bfad3a2cc1c83e8d0f04f232b0ebe0847fd6bca.1355773837.git.crobinso@redhat.com>
References: <8bfad3a2cc1c83e8d0f04f232b0ebe0847fd6bca.1355773837.git.crobinso@redhat.com>
From: Cole Robinson <crobinso@redhat.com>
Date: Mon, 17 Dec 2012 14:48:42 -0500
Subject: [PATCH 10/10] network: Fix parsing <ip> blocks with prefix=
https://bugzilla.redhat.com/show_bug.cgi?id=872814
(cherry picked from commit 32f74219b024ddbd6fac5301c58e27540541d569)
---
src/virtManager/network.py | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/virtManager/network.py b/src/virtManager/network.py
index ae89955..fa3e6ea 100644
--- a/src/virtManager/network.py
+++ b/src/virtManager/network.py
@@ -101,12 +101,22 @@ class vmmNetwork(vmmLibvirtObject):
return None
addrStr = util.xpath(xml, "/network/ip/@address")
netmaskStr = util.xpath(xml, "/network/ip/@netmask")
+ prefix = util.xpath(xml, "/network/ip/@prefix")
+
+ if prefix:
+ prefix = int(prefix)
+ binstr = ((prefix * "1") + ((32 - prefix) * "0"))
+ netmaskStr = str(IP(int(binstr, base=2)))
+
+ if netmaskStr:
+ netmask = IP(netmaskStr)
+ gateway = IP(addrStr)
+ network = IP(gateway.int() & netmask.int())
+ ret = IP(str(network) + "/" + netmaskStr)
+ else:
+ ret = IP(str(addrStr))
- netmask = IP(netmaskStr)
- gateway = IP(addrStr)
-
- network = IP(gateway.int() & netmask.int())
- return IP(str(network) + "/" + netmaskStr)
+ return ret
def get_ipv4_forward(self):
xml = self.get_xml()
--
1.8.0.2