cli: Break out function to disable libvirt error printing

We need it early in the test suite
This commit is contained in:
Cole Robinson 2014-09-20 11:37:23 -04:00
parent 439e5ad0fe
commit 8cd4958a19
3 changed files with 12 additions and 6 deletions

View File

@ -71,6 +71,7 @@ def openconn(uri):
generally every test uses a fresh virConnect, or undoes the
persistent changes it makes.
"""
virtinst.util.register_libvirt_error_handler()
conn = virtinst.cli.getConnection(uri)
if uri not in _conn_cache:

View File

@ -200,12 +200,7 @@ def setupLogging(appname, debug_stdout, do_quiet, cli_app=True):
if streamHandler:
rootLogger.addHandler(streamHandler)
# Register libvirt handler
def libvirt_callback(ignore, err):
if err[3] != libvirt.VIR_ERR_ERROR:
# Don't log libvirt errors: global error handler will do that
logging.warn("Non-error from libvirt: '%s'", err[2])
libvirt.registerErrorHandler(f=libvirt_callback, ctx=None)
util.register_libvirt_error_handler()
# Log uncaught exceptions
def exception_log(typ, val, tb):

View File

@ -517,3 +517,13 @@ def convert_units(value, old_unit, new_unit):
power = get_power(new_unit)
return in_bytes / pow(factor, power)
def register_libvirt_error_handler():
"""
Ignore libvirt error reporting, we just use exceptions
"""
def libvirt_callback(userdata, err):
ignore = userdata
ignore = err
libvirt.registerErrorHandler(f=libvirt_callback, ctx=None)