[Kimchi-devel] [PATCH] Fix issue #621: Catch libvirt exception when network does not have bridge name

Aline Manera alinefm at linux.vnet.ibm.com
Wed Mar 18 15:19:47 UTC 2015


The bridged network does not have a bridge name (<bridge> on XML)

<network>
  <name>bridged</name>
  <uuid>70441e61-2f87-44c4-836b-5cc817fcf025</uuid>
  <forward dev='eth0' mode='bridge'>
    <interface dev='eth0'/>
  </forward>
</network>

and then libvirt raises an exception when we try to get the bridge name.

File "/usr/lib64/python2.7/site-packages/libvirt.py", line 2780, in bridgeName
if ret is None: raise libvirtError ('virNetworkGetBridgeName() failed', net=self)
libvirtError: internal error: network 'bridged-eth0' does not have a bridge name.

Signed-off-by: Aline Manera <alinefm at linux.vnet.ibm.com>
---
 src/kimchi/model/networks.py | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/kimchi/model/networks.py b/src/kimchi/model/networks.py
index 7265c64..92aed92 100644
--- a/src/kimchi/model/networks.py
+++ b/src/kimchi/model/networks.py
@@ -210,7 +210,17 @@ class NetworksModel(object):
         br_xml = create_vlan_tagged_bridge_xml(br_name, interface, vlan_id)
         conn = self.conn.get()
 
-        if br_name in [net.bridgeName() for net in conn.listAllNetworks()]:
+        bridges = []
+        for net in conn.listAllNetworks():
+            # Bridged networks do not have a bridge name
+            # So in those cases, libvirt raises an error when trying to get
+            # the bridge name
+            try:
+                bridges.append(net.bridgeName())
+            except libvirt.libvirtError, e:
+                kimchi_log.error(e.message)
+
+        if br_name in bridges:
             raise InvalidOperation("KCHNET0010E", {'iface': br_name})
 
         with RollbackContext() as rollback:
-- 
2.1.0




More information about the Kimchi-devel mailing list