On 02/02/2012 04:57 AM, [email protected] wrote:
> From: Alex Jia <[email protected]>
> 
> Recently, libvirt add some new APIs to modify guest titles and description, 
> but
> old guest hasn't any description information, in other words, the function 
> vm.get_description() will return None not a string, however, the current 
> virt-manager changes previous codes to use util.xml_escap() method to covert 
> return value, the result is "AttributeError: 'NoneType' object has no 
> attribute 
> 'replace" is hit. The patch will enhance return value check and backwards 
> compatibility for old libvirt guests.
> 
> RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=786672
> 

Whoops! This is already fixed upstream by having virtinst xml_escape accept 
None:

http://git.fedorahosted.org/git/?p=python-virtinst.git;a=commit;h=8f803765367dce3c9fe6da0d35d66fbbf6760c64

But I didn't think to pull that patch in for RHEL :)

> 
> Signed-off-by: Alex Jia <[email protected]>
> ---
>  src/virtManager/manager.py |    6 +++++-
>  1 files changed, 5 insertions(+), 1 deletions(-)
> 
> diff --git a/src/virtManager/manager.py b/src/virtManager/manager.py
> index 9d2be6e..e3383ce 100644
> --- a/src/virtManager/manager.py
> +++ b/src/virtManager/manager.py
> @@ -749,6 +749,7 @@ class vmmManager(vmmGObjectUI):
>  
>      def _build_vm_row(self, vm):
>          row = []
> +        desc = vm.get_description()
>  
>          row.insert(ROW_HANDLE, vm)
>          row.insert(ROW_NAME, vm.get_name())
> @@ -756,7 +757,10 @@ class vmmManager(vmmGObjectUI):
>          row.insert(ROW_STATUS, vm.run_status())
>          row.insert(ROW_STATUS_ICON, vm.run_status_icon_name())
>          row.insert(ROW_KEY, vm.get_uuid())
> -        row.insert(ROW_HINT, util.xml_escape(vm.get_description()))
> +        if desc:
> +            row.insert(ROW_HINT, util.xml_escape(desc))
> +        else:
> +            row.insert(ROW_HINT, desc)
>          row.insert(ROW_IS_CONN, False)
>          row.insert(ROW_IS_CONN_CONNECTED, True)
>          row.insert(ROW_IS_VM, True)

This change actually isn't exhaustive: we also do a simple description
escaping for elsewhere in the file, when the VM XML configuration changes.
That would need to be handled as well.

Thanks for the patch, but it's probably easier if we just stick with the
virtinst change. I'll address that bz.

Thanks,
Cole

_______________________________________________
virt-tools-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/virt-tools-list

Reply via email to