This is a solution for issue #441.

In kvm_vm.create(), the process of attaching each one
of the nics on kvm_vm.virtnet currently happens only
if the nic doesn't have a tapfd key. However, on test
failure (and consequent vm destruction), this field
will continue to be filled up, therefore a new connection
to the bridge will never be stablished, making all
subsequent tests to fail.

However, the old networking code used to stablish the
network interface-bridge connection regardless of the
state of the nic, when create() is called. Applying the
same logic proved to be an effective solution for the
problem, therefore it's implemented on this patch.

CC: Chris Evich <cev...@redhat.com>
CC: Lukas Doktor <ldok...@redhat.com>
Signed-off-by: Lucas Meneghel Rodrigues <l...@redhat.com>
---
 client/virt/kvm_vm.py |   19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/client/virt/kvm_vm.py b/client/virt/kvm_vm.py
index 8d9c737..c2f803a 100644
--- a/client/virt/kvm_vm.py
+++ b/client/virt/kvm_vm.py
@@ -1457,16 +1457,15 @@ class VM(virt_vm.BaseVM):
                                     % (nic.nic_name, mac_source.name))
                     nic.mac = mac_source.get_mac_address(nic.nic_name)
                 if nic.nettype == 'bridge' or nic.nettype == 'network':
-                    if not nic.get('tapfd'):
-                        nic.tapfd = str(virt_utils.open_tap("/dev/net/tun",
-                                                            nic.ifname,
-                                                            vnet_hdr=False))
-                        logging.debug("Adding VM %s NIC ifname %s"
-                                      " to bridge %s" % (self.name,
-                                            nic.ifname, nic.netdst))
-                        if nic.nettype == 'bridge':
-                            virt_utils.add_to_bridge(nic.ifname, nic.netdst)
-                        virt_utils.bring_up_ifname(nic.ifname)
+                    nic.tapfd = str(virt_utils.open_tap("/dev/net/tun",
+                                                        nic.ifname,
+                                                        vnet_hdr=False))
+                    logging.debug("Adding VM %s NIC ifname %s"
+                                  " to bridge %s" % (self.name,
+                                        nic.ifname, nic.netdst))
+                    if nic.nettype == 'bridge':
+                        virt_utils.add_to_bridge(nic.ifname, nic.netdst)
+                    virt_utils.bring_up_ifname(nic.ifname)
                 elif nic.nettype == 'user':
                     logging.info("Assuming dependencies met for "
                                  "user mode nic %s, and ready to go"
-- 
1.7.10.4

_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to