mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
module_trace: Support --trace_libvirt=all|mainloop
'all' means log even API calls that are invoked from threads
This commit is contained in:
parent
155ddcfc17
commit
390adc4e58
@ -122,8 +122,8 @@ def parse_commandline():
|
||||
parser.set_defaults(domain=None)
|
||||
|
||||
# Trace every libvirt API call to debug output
|
||||
parser.add_argument("--trace-libvirt",
|
||||
help=argparse.SUPPRESS, action="store_true")
|
||||
parser.add_argument("--trace-libvirt", choices=["all", "mainloop"],
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
# Don't load any connections on startup to test first run
|
||||
# PackageKit integration
|
||||
@ -180,7 +180,9 @@ def main():
|
||||
logging.debug("Libvirt tracing requested")
|
||||
import virtManager.module_trace
|
||||
import libvirt
|
||||
virtManager.module_trace.wrap_module(libvirt, regex=None)
|
||||
virtManager.module_trace.wrap_module(libvirt,
|
||||
mainloop=(options.trace_libvirt == "mainloop"),
|
||||
regex=None)
|
||||
|
||||
# With F27 gnome+wayland we need to set these before GTK import
|
||||
os.environ["GSETTINGS_SCHEMA_DIR"] = CLIConfig.gsettings_dir
|
||||
|
@ -15,7 +15,9 @@ import time
|
||||
import traceback
|
||||
|
||||
from types import FunctionType
|
||||
from types import MethodType
|
||||
|
||||
|
||||
CHECK_MAINLOOP = False
|
||||
|
||||
|
||||
def generate_wrapper(origfunc, name):
|
||||
@ -35,7 +37,8 @@ def generate_wrapper(origfunc, name):
|
||||
name.endswith(".connect") or
|
||||
name.startswith("libvirtError"))
|
||||
|
||||
if not is_non_network_libvirt_call and is_main_thread:
|
||||
if (not is_non_network_libvirt_call and
|
||||
(is_main_thread or not CHECK_MAINLOOP)):
|
||||
tb = ""
|
||||
if is_main_thread:
|
||||
tb = "\n%s" % "".join(traceback.format_stack())
|
||||
@ -68,11 +71,13 @@ def wrap_class(classobj):
|
||||
|
||||
for name in dir(classobj):
|
||||
obj = getattr(classobj, name)
|
||||
if isinstance(obj, MethodType):
|
||||
if isinstance(obj, FunctionType):
|
||||
wrap_method(classobj, obj)
|
||||
|
||||
|
||||
def wrap_module(module, regex=None):
|
||||
def wrap_module(module, mainloop, regex):
|
||||
global CHECK_MAINLOOP
|
||||
CHECK_MAINLOOP = mainloop
|
||||
for name in dir(module):
|
||||
if regex and not re.match(regex, name):
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user