[Kimchi-devel] [PATCH v2][Kimchi] Avoid break Wok when register events, if Libvirt is down

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Thu Jun 23 13:50:43 UTC 2016


When Wok starts up it loads Kimcho model, which tries to register
Libvirt events. A problem happens if Libvirt service is down when Wok
starts (usually manually/command line start up), because the connection
is None, raising an error that breaks Wok.
This patch fixes this problem and return a proper log message.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
 model/libvirtevents.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/model/libvirtevents.py b/model/libvirtevents.py
index 632d399..dfd22c6 100644
--- a/model/libvirtevents.py
+++ b/model/libvirtevents.py
@@ -83,5 +83,9 @@ class LibvirtEvents(object):
                 self.event_enospc_cb,
                 libvirt.VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
             )
-        except libvirt.libvirtError as e:
-            wok_log.error("Register of ENOSPC event failed: %s" % e.message)
+        except (libvirt.libvirtError, AttributeError) as e:
+            if type(e) == AttributeError:
+                reason = 'Libvirt service is not running'
+            else:
+                reason = e.message
+            wok_log.error("Register of ENOSPC event failed: %s" % reason)
-- 
2.1.0




More information about the Kimchi-devel mailing list