On Wed, Jul 11, 2012 at 5:39 AM, tangchen <tangc...@cn.fujitsu.com> wrote:
> Base_VM.add_nic() doesn't add mac to address_cache,
> so when we delete call BaseVM.del_nic(), it is like this:
>     del self.address_cache[nic_mac]
> This may lead to KeyError. But BaseVM.del_nic() only catch IndexError.
> So we should catch KeyError too.
>
> And also, we should do delete the nic in virtnet before we delete it
> from address_cache, in case we occur the KeyError.

Ok, looks good to me, applied v2 of your patch.

Thanks for fixing this bug!

Lucas

> Signed-off-by: Tang Chen <tanc...@cn.fujitsu.com>
> ---
>  client/virt/virt_vm.py |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/client/virt/virt_vm.py b/client/virt/virt_vm.py
> index 534f8e3..b5d0c4c 100644
> --- a/client/virt/virt_vm.py
> +++ b/client/virt/virt_vm.py
> @@ -537,10 +537,12 @@ class BaseVM(object):
>          nic_mac = nic.mac.lower()
>          self.free_mac_address(nic_index_or_name)
>          try:
> -            del self.address_cache[nic_mac]
>              del self.virtnet[nic_index_or_name]
> +            del self.address_cache[nic_mac]
>          except IndexError:
>              pass # continue to not exist
> +        except KeyError:
> +            pass # continue to not exist
>
>
>      def verify_kernel_crash(self):
> --
> 1.7.10.2
>
> _______________________________________________
> Autotest mailing list
> Autotest@test.kernel.org
> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest



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

Reply via email to