Re: [PATCH virt-manager] enhance return value check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 02/02/2012 04:57 AM, ajia@xxxxxxxxxx wrote:
> From: Alex Jia <ajia@xxxxxxxxxx>
> 
> 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 <ajia@xxxxxxxxxx>
> ---
>  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


[Index of Archives]     [Linux Virtualization]     [KVM Development]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]     [Video 4 Linux]

  Powered by Linux