[PATCH V3] Avoid useless libvirt error log produced by featuretest

From: Aline Manera <alinefm@br.ibm.com> I am sending the next version for the apporc patch as he may be out for the Chinese holidays. v2 -> v3: 1. Any error on feature tests will be log into kimchi error log file For that, silent cherrypy screen log to avoid displyaing the message on screen. v1 -> -v2: 1. Just hide the portocol type error, leave other error messages as it is. (Thanks Cristian) 2. Unregister the error handler when necessary. (Thanks Cristian) 3. Keep back kimchi log "*** Running feature tests ***", etc. (Thanks Cristian) 4. Move libvirt error handler function inside of Featuretest. (Thanks Aline) v1: Avoid useless libvirt error log produced by featuretest apporc (1): Avoid useless libvirt error log produced by featuretests src/kimchi/featuretests.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) -- 1.7.10.4

From: apporc <appleorchard2000@gmail.com> When running feature tests, we get bunch of error messages as below: *** Running feature tests *** libvirt: Domain Config error : internal error unknown protocol type 'http' libvirt: Domain Config error : internal error unknown protocol type 'https' libvirt: Domain Config error : internal error unknown protocol type 'ftp' libvirt: Domain Config error : internal error unknown protocol type 'ftps' libvirt: Domain Config error : internal error unknown protocol type 'tftp' Cannot find '' in path: No such file or directory *** Feature tests completed *** By replacing default error handler of libvirt, this patch succeeded to avoid the errors. After Featuretest, the default error handler will be restored. The default error handler (in libvirtmod.so) just do one thing, it prints the error message to stderr before we catch the exception in python. Independent of the error, it will be logged into kimchi error log file. That way we can easily debug the system. Signed-off-by: apporc <appleorchard2000@gmail.com> Signed-off-by: Aline Manera <alinefm@br.ibm.com> --- src/kimchi/featuretests.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/kimchi/featuretests.py b/src/kimchi/featuretests.py index 1557dd9..d924050 100644 --- a/src/kimchi/featuretests.py +++ b/src/kimchi/featuretests.py @@ -32,6 +32,7 @@ from lxml.builder import E from kimchi import config +from kimchi.utils import kimchi_log ISO_STREAM_XML = """ @@ -60,17 +61,39 @@ ISO_STREAM_XML = """ class FeatureTests(object): @staticmethod + def disable_screen_error_logging(): + def libvirt_errorhandler(userdata, error): + # A libvirt error handler to ignore annoying messages in stderr + pass + + # Register the error handler to hide libvirt error in stderr + libvirt.registerErrorHandler(f=libvirt_errorhandler, ctx=None) + # Disable cherrypy screen logging, in order to log errors on kimchi + # file without displaying them on screen + cherrypy.log.screen = False + + @staticmethod + def enable_screen_error_logging(): + # Unregister the error handler + libvirt.registerErrorHandler(f=None, ctx=None) + # Enable cherrypy screen logging + cherrypy.log.screen = True + + @staticmethod def libvirt_supports_iso_stream(protocol): xml = ISO_STREAM_XML % {'protocol': protocol} conn = None try: + FeatureTests.disable_screen_error_logging() conn = libvirt.open('qemu:///system') dom = conn.defineXML(xml) dom.undefine() return True - except libvirt.libvirtError: + except libvirt.libvirtError, e: + kimchi_log.error(e.message) return False finally: + FeatureTests.enable_screen_error_logging() conn is None or conn.close() @staticmethod @@ -81,14 +104,18 @@ class FeatureTests(object): return xml try: conn = libvirt.open('qemu:///system') - ret = conn.findStoragePoolSources('netfs', _get_xml(), 0) + FeatureTests.disable_screen_error_logging() + conn.findStoragePoolSources('netfs', _get_xml(), 0) except libvirt.libvirtError as e: + kimchi_log.error(e.message) if e.get_error_code() == 38: # if libvirt cannot find showmount, # it returns 38--general system call failure return False finally: + FeatureTests.enable_screen_error_logging() conn is None or conn.close() + return True @staticmethod -- 1.7.10.4

Reviewed-by: Daniel Barboza <danielhb@linux.vnet.ibm.com> On 01/30/2014 06:01 PM, Aline Manera wrote:
From: apporc <appleorchard2000@gmail.com>
When running feature tests, we get bunch of error messages as below:
*** Running feature tests *** libvirt: Domain Config error : internal error unknown protocol type 'http' libvirt: Domain Config error : internal error unknown protocol type 'https' libvirt: Domain Config error : internal error unknown protocol type 'ftp' libvirt: Domain Config error : internal error unknown protocol type 'ftps' libvirt: Domain Config error : internal error unknown protocol type 'tftp' Cannot find '' in path: No such file or directory *** Feature tests completed ***
By replacing default error handler of libvirt, this patch succeeded to avoid the errors. After Featuretest, the default error handler will be restored. The default error handler (in libvirtmod.so) just do one thing, it prints the error message to stderr before we catch the exception in python.
Independent of the error, it will be logged into kimchi error log file. That way we can easily debug the system.
Signed-off-by: apporc <appleorchard2000@gmail.com> Signed-off-by: Aline Manera <alinefm@br.ibm.com> --- src/kimchi/featuretests.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/featuretests.py b/src/kimchi/featuretests.py index 1557dd9..d924050 100644 --- a/src/kimchi/featuretests.py +++ b/src/kimchi/featuretests.py @@ -32,6 +32,7 @@ from lxml.builder import E
from kimchi import config +from kimchi.utils import kimchi_log
ISO_STREAM_XML = """ @@ -60,17 +61,39 @@ ISO_STREAM_XML = """ class FeatureTests(object):
@staticmethod + def disable_screen_error_logging(): + def libvirt_errorhandler(userdata, error): + # A libvirt error handler to ignore annoying messages in stderr + pass + + # Register the error handler to hide libvirt error in stderr + libvirt.registerErrorHandler(f=libvirt_errorhandler, ctx=None) + # Disable cherrypy screen logging, in order to log errors on kimchi + # file without displaying them on screen + cherrypy.log.screen = False + + @staticmethod + def enable_screen_error_logging(): + # Unregister the error handler + libvirt.registerErrorHandler(f=None, ctx=None) + # Enable cherrypy screen logging + cherrypy.log.screen = True + + @staticmethod def libvirt_supports_iso_stream(protocol): xml = ISO_STREAM_XML % {'protocol': protocol} conn = None try: + FeatureTests.disable_screen_error_logging() conn = libvirt.open('qemu:///system') dom = conn.defineXML(xml) dom.undefine() return True - except libvirt.libvirtError: + except libvirt.libvirtError, e: + kimchi_log.error(e.message) return False finally: + FeatureTests.enable_screen_error_logging() conn is None or conn.close()
@staticmethod @@ -81,14 +104,18 @@ class FeatureTests(object): return xml try: conn = libvirt.open('qemu:///system') - ret = conn.findStoragePoolSources('netfs', _get_xml(), 0) + FeatureTests.disable_screen_error_logging() + conn.findStoragePoolSources('netfs', _get_xml(), 0) except libvirt.libvirtError as e: + kimchi_log.error(e.message) if e.get_error_code() == 38: # if libvirt cannot find showmount, # it returns 38--general system call failure return False finally: + FeatureTests.enable_screen_error_logging() conn is None or conn.close() + return True
@staticmethod

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

Reviewed-by: Christy Perez <christy@linux.vnet.ibm.com> On Thu, 2014-01-30 at 18:01 -0200, Aline Manera wrote:
From: apporc <appleorchard2000@gmail.com>
When running feature tests, we get bunch of error messages as below:
*** Running feature tests *** libvirt: Domain Config error : internal error unknown protocol type 'http' libvirt: Domain Config error : internal error unknown protocol type 'https' libvirt: Domain Config error : internal error unknown protocol type 'ftp' libvirt: Domain Config error : internal error unknown protocol type 'ftps' libvirt: Domain Config error : internal error unknown protocol type 'tftp' Cannot find '' in path: No such file or directory *** Feature tests completed ***
By replacing default error handler of libvirt, this patch succeeded to avoid the errors. After Featuretest, the default error handler will be restored. The default error handler (in libvirtmod.so) just do one thing, it prints the error message to stderr before we catch the exception in python.
Independent of the error, it will be logged into kimchi error log file. That way we can easily debug the system.
Signed-off-by: apporc <appleorchard2000@gmail.com> Signed-off-by: Aline Manera <alinefm@br.ibm.com> --- src/kimchi/featuretests.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/featuretests.py b/src/kimchi/featuretests.py index 1557dd9..d924050 100644 --- a/src/kimchi/featuretests.py +++ b/src/kimchi/featuretests.py @@ -32,6 +32,7 @@ from lxml.builder import E
from kimchi import config +from kimchi.utils import kimchi_log
ISO_STREAM_XML = """ @@ -60,17 +61,39 @@ ISO_STREAM_XML = """ class FeatureTests(object):
@staticmethod + def disable_screen_error_logging(): + def libvirt_errorhandler(userdata, error): + # A libvirt error handler to ignore annoying messages in stderr + pass + + # Register the error handler to hide libvirt error in stderr + libvirt.registerErrorHandler(f=libvirt_errorhandler, ctx=None) + # Disable cherrypy screen logging, in order to log errors on kimchi + # file without displaying them on screen + cherrypy.log.screen = False + + @staticmethod + def enable_screen_error_logging(): + # Unregister the error handler + libvirt.registerErrorHandler(f=None, ctx=None) + # Enable cherrypy screen logging + cherrypy.log.screen = True + + @staticmethod def libvirt_supports_iso_stream(protocol): xml = ISO_STREAM_XML % {'protocol': protocol} conn = None try: + FeatureTests.disable_screen_error_logging() conn = libvirt.open('qemu:///system') dom = conn.defineXML(xml) dom.undefine() return True - except libvirt.libvirtError: + except libvirt.libvirtError, e: + kimchi_log.error(e.message) return False finally: + FeatureTests.enable_screen_error_logging() conn is None or conn.close()
@staticmethod @@ -81,14 +104,18 @@ class FeatureTests(object): return xml try: conn = libvirt.open('qemu:///system') - ret = conn.findStoragePoolSources('netfs', _get_xml(), 0) + FeatureTests.disable_screen_error_logging() + conn.findStoragePoolSources('netfs', _get_xml(), 0) except libvirt.libvirtError as e: + kimchi_log.error(e.message) if e.get_error_code() == 38: # if libvirt cannot find showmount, # it returns 38--general system call failure return False finally: + FeatureTests.enable_screen_error_logging() conn is None or conn.close() + return True
@staticmethod

Applied. Thanks. Regards, Aline Manera
participants (4)
-
Aline Manera
-
Christy Perez
-
Daniel H Barboza
-
me,apporc