mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-23 17:34:21 +03:00
cli: Break out function to disable libvirt error printing
We need it early in the test suite
This commit is contained in:
parent
439e5ad0fe
commit
8cd4958a19
@ -71,6 +71,7 @@ def openconn(uri):
|
|||||||
generally every test uses a fresh virConnect, or undoes the
|
generally every test uses a fresh virConnect, or undoes the
|
||||||
persistent changes it makes.
|
persistent changes it makes.
|
||||||
"""
|
"""
|
||||||
|
virtinst.util.register_libvirt_error_handler()
|
||||||
conn = virtinst.cli.getConnection(uri)
|
conn = virtinst.cli.getConnection(uri)
|
||||||
|
|
||||||
if uri not in _conn_cache:
|
if uri not in _conn_cache:
|
||||||
|
@ -200,12 +200,7 @@ def setupLogging(appname, debug_stdout, do_quiet, cli_app=True):
|
|||||||
if streamHandler:
|
if streamHandler:
|
||||||
rootLogger.addHandler(streamHandler)
|
rootLogger.addHandler(streamHandler)
|
||||||
|
|
||||||
# Register libvirt handler
|
util.register_libvirt_error_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)
|
|
||||||
|
|
||||||
# Log uncaught exceptions
|
# Log uncaught exceptions
|
||||||
def exception_log(typ, val, tb):
|
def exception_log(typ, val, tb):
|
||||||
|
@ -517,3 +517,13 @@ def convert_units(value, old_unit, new_unit):
|
|||||||
power = get_power(new_unit)
|
power = get_power(new_unit)
|
||||||
|
|
||||||
return in_bytes / pow(factor, power)
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user