[virt-tools-list] [virt-manager PATCH] host: catch KeyError in interface_selected

Chen Hanxiao chen_han_xiao at 126.com
Tue Mar 11 15:29:57 UTC 2014


On 03/11/2014 08:26 PM, Cole Robinson wrote:
> On 03/11/2014 03:12 AM, Chen Hanxiao wrote:
>> We should catch KeyError in interface_selected,
>> for that error could happen when
>> singal on_interface_list_changed comes.
>>
>> How to reproduce:
>> 1. create 3 bridge by Edit->Connection Details->Network Interface
>> 2. delete them
>> 3. We would get a KeyError
>>
>> Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
>> ---
>>   virtManager/host.py | 9 +++++++++
>>   1 file changed, 9 insertions(+)
>>
>> diff --git a/virtManager/host.py b/virtManager/host.py
>> index c8d7ee0..97a4f74 100644
>> --- a/virtManager/host.py
>> +++ b/virtManager/host.py
>> @@ -1098,6 +1098,15 @@ class vmmHost(vmmGObjectUI):
>>           name = model[treeiter][0]
>>
>>           try:
>> +            self.conn.get_interface(name)
>> +        except KeyError:
>> +            self.widget("interface-apply").set_sensitive(False)
>> +            return
>> +        except Exception, e:
>> +            logging.exception(e)
>> +            self.set_interface_error_page(_("Error selecting interface: %s") %
>> +                    e)
>> +        try:
>>               self.populate_interface_state(name)
>>           except Exception, e:
>>               logging.exception(e)
>>
> If an interface is removed, vmmConnection should emit interface-removed, which
> calls host.py:repopulate_interfaces and should remove the missing interface
> from the list before the user has a chance to select anything. If that's not
> working we should figure out why that is.
>
> - Cole
When we delete interface by UI, interface list will be changed,
signal "on_interface_list_changed" will be raised and it will also
invoke interface_selected.
I think that caused this issue.

- Chen
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
>





More information about the virt-tools-list mailing list