From e7e9369989ea6405d38d6971f7c9d1d7197959a7 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Mon, 6 Mar 2017 22:00:23 -0500 Subject: [PATCH] util: Catch libxml2 stderr messages Similar to what we do with libvirt. Was never really relevant before, but some of the namespace XML stuff can be a bit noisy even though it doesn't have any functional impact that I can tell --- tests/utils.py | 8 -------- virtinst/util.py | 5 +++++ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/utils.py b/tests/utils.py index 64dfee483..bab9612e4 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -17,9 +17,6 @@ import difflib import os -import logging - -import libvirt import virtinst import virtinst.cli @@ -143,11 +140,6 @@ def open_test_remote(): return openconn(uri_test_remote) -def _libvirt_callback(ignore, err): - logging.warn("libvirt errmsg: %s", err[2]) -libvirt.registerErrorHandler(f=_libvirt_callback, ctx=None) - - def test_create(testconn, xml, define_func="defineXML"): xml = virtinst.uri.sanitize_xml_for_test_define(xml) diff --git a/virtinst/util.py b/virtinst/util.py index 10f6eb5dd..c84b8ed76 100644 --- a/virtinst/util.py +++ b/virtinst/util.py @@ -324,7 +324,12 @@ def register_libvirt_error_handler(): def libvirt_callback(userdata, err): ignore = userdata ignore = err + def libxml2_callback(userdata, err): + ignore = userdata + logging.debug("libxml2 callback error: %s", err) libvirt.registerErrorHandler(f=libvirt_callback, ctx=None) + import libxml2 + libxml2.registerErrorHandler(f=libxml2_callback, ctx=None) def ensure_meter(meter):