[virt-tools-list] [PATCH virt-manager] enhance return value check

ajia at redhat.com ajia at redhat.com
Thu Feb 2 09:57:02 UTC 2012


From: Alex Jia <ajia at redhat.com>

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


Signed-off-by: Alex Jia <ajia at redhat.com>
---
 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)
-- 
1.7.1




More information about the virt-tools-list mailing list