<div dir="ltr"><span style="font-family:arial,sans-serif;font-size:13px">Reviewed-by: apporc <<a href="mailto:appleorchard2000@gmail.com">appleorchard2000@gmail.com</a>></span><br></div><div class="gmail_extra"><br>
<br><div class="gmail_quote">On Tue, Feb 4, 2014 at 12:50 AM, Daniel H Barboza <span dir="ltr"><<a href="mailto:danielhb@linux.vnet.ibm.com" target="_blank">danielhb@linux.vnet.ibm.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Reviewed-by: Daniel Barboza <<a href="mailto:danielhb@linux.vnet.ibm.com" target="_blank">danielhb@linux.vnet.ibm.com</a>><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
On 01/30/2014 06:01 PM, Aline Manera wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
From: apporc <<a href="mailto:appleorchard2000@gmail.com" target="_blank">appleorchard2000@gmail.com</a>><br>
<br>
When running feature tests, we get bunch of error messages as below:<br>
<br>
*** Running feature tests ***<br>
libvirt: Domain Config error : internal error unknown protocol type 'http'<br>
libvirt: Domain Config error : internal error unknown protocol type 'https'<br>
libvirt: Domain Config error : internal error unknown protocol type 'ftp'<br>
libvirt: Domain Config error : internal error unknown protocol type 'ftps'<br>
libvirt: Domain Config error : internal error unknown protocol type 'tftp'<br>
Cannot find '' in path: No such file or directory<br>
*** Feature tests completed ***<br>
<br>
By replacing default error handler of libvirt, this patch succeeded to<br>
avoid the errors. After Featuretest, the default error handler will be restored.<br>
The default error handler (in libvirtmod.so) just do one thing, it prints the<br>
error message to stderr before we catch the exception in python.<br>
<br>
Independent of the error, it will be logged into kimchi error log file.<br>
That way we can easily debug the system.<br>
<br>
Signed-off-by: apporc <<a href="mailto:appleorchard2000@gmail.com" target="_blank">appleorchard2000@gmail.com</a>><br>
Signed-off-by: Aline Manera <<a href="mailto:alinefm@br.ibm.com" target="_blank">alinefm@br.ibm.com</a>><br>
---<br>
src/kimchi/featuretests.py | 31 +++++++++++++++++++++++++++++-<u></u>-<br>
1 file changed, 29 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/kimchi/featuretests.py b/src/kimchi/featuretests.py<br>
index 1557dd9..d924050 100644<br>
--- a/src/kimchi/featuretests.py<br>
+++ b/src/kimchi/featuretests.py<br>
@@ -32,6 +32,7 @@ from lxml.builder import E<br>
<br>
<br>
from kimchi import config<br>
+from kimchi.utils import kimchi_log<br>
<br>
<br>
ISO_STREAM_XML = """<br>
@@ -60,17 +61,39 @@ ISO_STREAM_XML = """<br>
class FeatureTests(object):<br>
<br>
@staticmethod<br>
+ def disable_screen_error_logging()<u></u>:<br>
+ def libvirt_errorhandler(userdata, error):<br>
+ # A libvirt error handler to ignore annoying messages in stderr<br>
+ pass<br>
+<br>
+ # Register the error handler to hide libvirt error in stderr<br>
+ libvirt.registerErrorHandler(<u></u>f=libvirt_errorhandler, ctx=None)<br>
+ # Disable cherrypy screen logging, in order to log errors on kimchi<br>
+ # file without displaying them on screen<br>
+ cherrypy.log.screen = False<br>
+<br>
+ @staticmethod<br>
+ def enable_screen_error_logging():<br>
+ # Unregister the error handler<br>
+ libvirt.registerErrorHandler(<u></u>f=None, ctx=None)<br>
+ # Enable cherrypy screen logging<br>
+ cherrypy.log.screen = True<br>
+<br>
+ @staticmethod<br>
def libvirt_supports_iso_stream(<u></u>protocol):<br>
xml = ISO_STREAM_XML % {'protocol': protocol}<br>
conn = None<br>
try:<br>
+ FeatureTests.disable_screen_<u></u>error_logging()<br>
conn = libvirt.open('qemu:///system')<br>
dom = conn.defineXML(xml)<br>
dom.undefine()<br>
return True<br>
- except libvirt.libvirtError:<br>
+ except libvirt.libvirtError, e:<br>
+ kimchi_log.error(e.message)<br>
return False<br>
finally:<br>
+ FeatureTests.enable_screen_<u></u>error_logging()<br>
conn is None or conn.close()<br>
<br>
@staticmethod<br>
@@ -81,14 +104,18 @@ class FeatureTests(object):<br>
return xml<br>
try:<br>
conn = libvirt.open('qemu:///system')<br>
- ret = conn.findStoragePoolSources('<u></u>netfs', _get_xml(), 0)<br>
+ FeatureTests.disable_screen_<u></u>error_logging()<br>
+ conn.findStoragePoolSources('<u></u>netfs', _get_xml(), 0)<br>
except libvirt.libvirtError as e:<br>
+ kimchi_log.error(e.message)<br>
if e.get_error_code() == 38:<br>
# if libvirt cannot find showmount,<br>
# it returns 38--general system call failure<br>
return False<br>
finally:<br>
+ FeatureTests.enable_screen_<u></u>error_logging()<br>
conn is None or conn.close()<br>
+<br>
return True<br>
<br>
@staticmethod<br>
</blockquote>
<br></div></div><div class="HOEnZb"><div class="h5">
______________________________<u></u>_________________<br>
Kimchi-devel mailing list<br>
<a href="mailto:Kimchi-devel@ovirt.org" target="_blank">Kimchi-devel@ovirt.org</a><br>
<a href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel" target="_blank">http://lists.ovirt.org/<u></u>mailman/listinfo/kimchi-devel</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div dir="ltr">Regards,<div>apporc</div></div>
</div>