Good job!  I think I wrote it originally with the thought vm.create 
could potentially be called to setup a VM with an existing underlying 
qemu process and open tapfd.  Is it correct assumption then vm.create() 
will only ever be called to start a new qemu process?

There's already a lock being used to prevent simultanious vm.create() 
usage.  However perhaps a check for multiple vm.create() calls would 
help too?  Just a thought.

Also, just a small thing - it's "establish" not "stablish" :)

On 07/23/2012 06:40 PM, Lucas Meneghel Rodrigues wrote:
> 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"


-- 
Chris Evich, RHCA, RHCE, RHCDS, RHCSS
Quality Assurance Engineer
e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214
_______________________________________________
Autotest mailing list
Autotest@test.kernel.org
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to