[PATCH] Avoid useless libvirt error log produced by featuretests

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' *** Feature tests completed *** By replacing default error handler of libvirt, this patch succeeded to avoid the error. Signed-off-by: apporc <appleorchard2000@gmail.com> --- src/kimchi/featuretests.py | 7 +++++++ src/kimchi/model.py | 2 -- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/kimchi/featuretests.py b/src/kimchi/featuretests.py index a5755a2..641ec5b 100644 --- a/src/kimchi/featuretests.py +++ b/src/kimchi/featuretests.py @@ -30,6 +30,11 @@ import threading from kimchi import config +def libvirt_errorhandler(userdata, error): + # A libvirt error handler to ignore annoying messages in stderr + pass + + ISO_STREAM_XML = """ <domain type='kvm'> <name>ISO_STREAMING</name> @@ -60,6 +65,8 @@ class FeatureTests(object): xml = ISO_STREAM_XML % {'protocol': protocol} conn = None try: + # Register the error handler to hide libvirt error in stderr + libvirt.registerErrorHandler(f=libvirt_errorhandler, ctx=None) conn = libvirt.open('qemu:///system') dom = conn.defineXML(xml) dom.undefine() diff --git a/src/kimchi/model.py b/src/kimchi/model.py index 2c6d3a1..fe1ae5b 100644 --- a/src/kimchi/model.py +++ b/src/kimchi/model.py @@ -222,7 +222,6 @@ class Model(object): sys.exit(1) def _set_capabilities(self): - kimchi_log.info("*** Running feature tests ***") self.qemu_stream = FeatureTests.qemu_supports_iso_stream() self.qemu_stream_dns = FeatureTests.qemu_iso_stream_dns() @@ -231,7 +230,6 @@ class Model(object): if FeatureTests.libvirt_supports_iso_stream(p): self.libvirt_stream_protocols.append(p) - kimchi_log.info("*** Feature tests completed ***") _set_capabilities.priority = 90 def get_capabilities(self): -- 1.7.9.5

@@ -60,6 +65,8 @@ class FeatureTests(object): xml = ISO_STREAM_XML % {'protocol': protocol} conn = None try: + # Register the error handler to hide libvirt error in stderr + libvirt.registerErrorHandler(f=libvirt_errorhandler, ctx=None) conn = libvirt.open('qemu:///system') dom = conn.defineXML(xml) dom.undefine() Does that suppress *all* future libvirt error messages? If it does, I don't think that's a good idea, it's very important to see error messages when they happen. If there's some way to suppress only those messages you mentioned in
@@ -222,7 +222,6 @@ class Model(object): sys.exit(1)
def _set_capabilities(self): - kimchi_log.info("*** Running feature tests ***") self.qemu_stream = FeatureTests.qemu_supports_iso_stream() self.qemu_stream_dns = FeatureTests.qemu_iso_stream_dns()
@@ -231,7 +230,6 @@ class Model(object): if FeatureTests.libvirt_supports_iso_stream(p): self.libvirt_stream_protocols.append(p)
- kimchi_log.info("*** Feature tests completed ***") _set_capabilities.priority = 90
def get_capabilities(self): I think those two messages are useful, they're reporting something
Am 21-01-2014 05:23, schrieb apporc: this patch's description, it would be better. I believe you can unregister a handler when you don't need it anymore. that's happening in background. There was once a bug that occurred when the feature tests started but never finished, and we could tell that by looking at those exact two messages (the second message never showed up, in that case).

Thanks for the review, Cristian. On Tue, Jan 21, 2014 at 10:37 PM, Crístian Viana <vianac@linux.vnet.ibm.com>wrote:
Am 21-01-2014 05:23, schrieb apporc:
@@ -60,6 +65,8 @@ class FeatureTests(object):
xml = ISO_STREAM_XML % {'protocol': protocol} conn = None try: + # Register the error handler to hide libvirt error in stderr + libvirt.registerErrorHandler(f=libvirt_errorhandler, ctx=None) conn = libvirt.open('qemu:///system') dom = conn.defineXML(xml) dom.undefine()
Does that suppress *all* future libvirt error messages? If it does, I don't think that's a good idea, it's very important to see error messages when they happen. If there's some way to suppress only those messages you mentioned in this patch's description, it would be better. I believe you can unregister a handler when you don't need it anymore.
In fact the libvirt error messages are always there, when we use
try...except, we will get that exception with the error message. The default libvirt error handler just do one thing, that is before we get the exception it prints errors to stderr. ACK, yes it's good to unregister the handler when this feature test is done.
@@ -222,7 +222,6 @@ class Model(object):
sys.exit(1)
def _set_capabilities(self): - kimchi_log.info("*** Running feature tests ***") self.qemu_stream = FeatureTests.qemu_supports_iso_stream() self.qemu_stream_dns = FeatureTests.qemu_iso_stream_dns()
@@ -231,7 +230,6 @@ class Model(object): if FeatureTests.libvirt_supports_iso_stream(p): self.libvirt_stream_protocols.append(p)
- kimchi_log.info("*** Feature tests completed ***") _set_capabilities.priority = 90
def get_capabilities(self):
I think those two messages are useful, they're reporting something that's happening in background. There was once a bug that occurred when the feature tests started but never finished, and we could tell that by looking at those exact two messages (the second message never showed up, in that case).
Sorry, i thought this two messages were just used to wrap the mess of
libvirt error. I will resubmit this patch later. -- Regards, apporc

On 01/21/2014 05:23 AM, apporc wrote:
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' *** Feature tests completed ***
By replacing default error handler of libvirt, this patch succeeded to avoid the error.
Signed-off-by: apporc <appleorchard2000@gmail.com> --- src/kimchi/featuretests.py | 7 +++++++ src/kimchi/model.py | 2 -- 2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/featuretests.py b/src/kimchi/featuretests.py index a5755a2..641ec5b 100644 --- a/src/kimchi/featuretests.py +++ b/src/kimchi/featuretests.py @@ -30,6 +30,11 @@ import threading from kimchi import config
+def libvirt_errorhandler(userdata, error): + # A libvirt error handler to ignore annoying messages in stderr + pass + +
In addition to Cristian's comments, I'd suggest to also move this wrapper method inside the function used to register it
ISO_STREAM_XML = """ <domain type='kvm'> <name>ISO_STREAMING</name> @@ -60,6 +65,8 @@ class FeatureTests(object): xml = ISO_STREAM_XML % {'protocol': protocol} conn = None try: + # Register the error handler to hide libvirt error in stderr + libvirt.registerErrorHandler(f=libvirt_errorhandler, ctx=None) conn = libvirt.open('qemu:///system') dom = conn.defineXML(xml) dom.undefine() diff --git a/src/kimchi/model.py b/src/kimchi/model.py index 2c6d3a1..fe1ae5b 100644 --- a/src/kimchi/model.py +++ b/src/kimchi/model.py @@ -222,7 +222,6 @@ class Model(object): sys.exit(1)
def _set_capabilities(self): - kimchi_log.info("*** Running feature tests ***") self.qemu_stream = FeatureTests.qemu_supports_iso_stream() self.qemu_stream_dns = FeatureTests.qemu_iso_stream_dns()
@@ -231,7 +230,6 @@ class Model(object): if FeatureTests.libvirt_supports_iso_stream(p): self.libvirt_stream_protocols.append(p)
- kimchi_log.info("*** Feature tests completed ***") _set_capabilities.priority = 90
def get_capabilities(self):
participants (4)
-
Aline Manera
-
apporc
-
Crístian Viana
-
me,apporc