[virt-tools-list] [virt-manager PATCH] create: fix a TypeError issue when detecting OS info

Cole Robinson crobinso at redhat.com
Wed Apr 30 19:49:05 UTC 2014


On 04/29/2014 10:53 PM, chenhanxiao at cn.fujitsu.com wrote:
> 
> 
>> -----Original Message-----
>> From: Cole Robinson [mailto:crobinso at redhat.com]
>> Sent: Tuesday, April 29, 2014 10:52 PM
>> To: Chen, Hanxiao/陈 晗霄; virt-tools-list at redhat.com
>> Subject: Re: [virt-tools-list] [virt-manager PATCH] create: fix a TypeError issue
>> when detecting OS info
>>
>> On 04/26/2014 02:49 AM, Chen Hanxiao wrote:
>>> How to reproduce:
>>> 1) New VM -> Use ISO image
>>> 2) Choose a WINDOWS IMG
>>>
>>> Then debug log shows:
>>> Traceback (most recent call last):
>>> File "/home/virt-manager/virtManager/create.py", line 1218, in
>> change_os_version
>>>       if os_type_model[idx][0] == type_row[0]:
>>> File "/usr/lib64/python2.7/site-packages/gi/overrides/Gtk.py", line 1064, in
>> __getitem__
>>>       return self.model.get_value(self.iter, key)
>>> TypeError: unknown type (null)
>>>
>>> Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
>>
>> Hmm, I can't reproduce, but maybe I'm doing something differently. Are you
>> selecting a windows ISO?
>>
> Yes , WinXP ISO, a little old though :)
> 
> And I did more tests:
> Other Windows ISO(win98, win2000), we can’t get its OS and version,
> but no TypeError thrown.
> Win7 works fine.
> 
> Fedora 20, RHEL 7, Ubuntu 13 works fine too.
> 
>> What is the list selection in the UI when this triggers?
> 
> OS: Windows
> Version: Unknown
> 
>>
>> If this isn't a bug we can fix elsewhere, then we should at least move the
>> TypeError check to _selected_os_row so other users benefit as well.
>>
>> - Cole
> 
> I did a test with code like:
>      def _selected_os_row(self):
> -        return uiutil.get_list_selection(
> +        row = uiutil.get_list_selection(
>              self.widget("install-os-type"), None)
> +        if row:
> +            try:
> +                row[0]
> +            except TypeError:
> +                return None
> +            return row
> +        else:
> +            return None
> 
> 
> We still got error message:
> [Wed, 30 Apr 2014 10:41:37 virt-manager 876] DEBUG (cli:182) Uncaught exception:
> Traceback (most recent call last):
>   File "/home/virt-manager/virtManager/create.py", line 1225, in change_os_version
>     if os_type_model[idx][0] == type_row[0]:
>   File "/usr/lib64/python2.7/site-packages/gi/overrides/Gtk.py", line 1064, in __getitem__
>     return self.model.get_value(self.iter, key)
> TypeError: unknown type (null)
> 
> Traceback (most recent call last):
>   File "/home/virt-manager/virtManager/create.py", line 1225, in change_os_version
>     if os_type_model[idx][0] == type_row[0]:
>   File "/usr/lib64/python2.7/site-packages/gi/overrides/Gtk.py", line 1064, in __getitem__
>     return self.model.get_value(self.iter, key)
> TypeError: unknown type (null)
> 
> With my patch, it works fine though.....
> Currently, only change_os_version need check self._selected_os_row()[0].
> 

Here's the fix:

diff --git a/virtManager/create.py b/virtManager/create.py
index 1e359f9..c2e0ee7 100644
--- a/virtManager/create.py
+++ b/virtManager/create.py
@@ -1206,6 +1206,7 @@ class vmmCreate(vmmGObjectUI):
         type_row = self._selected_os_row()
         if not type_row:
             return
+        old_type = type_row[0]

         self.show_all_os = True
         self.populate_os_type_model()
@@ -1213,7 +1214,7 @@ class vmmCreate(vmmGObjectUI):
         os_type_list = self.widget("install-os-type")
         os_type_model = os_type_list.get_model()
         for idx in range(len(os_type_model)):
-            if os_type_model[idx][0] == type_row[0]:
+            if os_type_model[idx][0] == old_type:
                 os_type_list.set_active(idx)
                 break

populate_os_type_model will free type_row, so pull out the data ahead of time.

I've pushed that now

- Cole




More information about the virt-tools-list mailing list