Skip to content

Commit 768e940

Browse files
committed
Add option to disable debug logs of libvirtaio
The root level and handlers can have the log level debug, but libvirt is too verbose for that. Disabling it makes the output easier to read. Especially considering the previous commit that allows logging dom0 qrexec calls, when in debug mode.
1 parent 5a4a672 commit 768e940

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

qubes/log.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def formatMessage(self, record):
4343
return fmt % record.__dict__
4444

4545

46-
def enable(log_level: int = logging.INFO):
46+
def enable(log_level: int = logging.INFO, disable_debug_libvirt: bool = False):
4747
"""Enable global logging
4848
4949
Use :py:mod:`logging` module from standard library to log messages.
@@ -64,6 +64,8 @@ def enable(log_level: int = logging.INFO):
6464
if log_level == logging.DEBUG:
6565
for handler in logging.root.handlers:
6666
handler.setFormatter(Formatter(debug=True))
67+
if disable_debug_libvirt:
68+
logging.getLogger("virEventAsyncIOImpl").setLevel(logging.INFO)
6769
logging.root.setLevel(log_level)
6870

6971

qubes/tools/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,15 @@ def set_qubes_verbosity(namespace):
475475
This is done by configuring global logging.
476476
:param argparse.Namespace args: args as parsed by parser
477477
"""
478+
if namespace.debug:
479+
qubes.log.enable(
480+
log_level=logging.DEBUG,
481+
disable_debug_libvirt=getattr(
482+
namespace, "disable_debug_libvirt", False
483+
),
484+
)
485+
return
486+
478487
verbose = namespace.verbose - namespace.quiet
479488
levels = [logging.NOTSET, logging.INFO, logging.DEBUG]
480489
log_level = levels[min(verbose, 2)]

qubes/tools/qubesd.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ def sighandler(loop, signame, servers, app):
3838
help="Enable verbose error logging (all exceptions with full "
3939
"tracebacks) and also send tracebacks to Admin API clients",
4040
)
41+
parser.add_argument(
42+
"--disable-debug-libvirt",
43+
action="store_true",
44+
default=False,
45+
help="Disables verbose logging of libvirtaio, specifically the "
46+
"virEventAsyncIOImpl handler",
47+
)
4148
parser.add_argument(
4249
"--log-dom0-call",
4350
action="store_true",
@@ -60,9 +67,6 @@ def main(args=None):
6067
# Stop storage for domains not currently running
6168
loop.run_until_complete(args.app.stop_storage())
6269

63-
if args.debug:
64-
qubes.log.enable(log_level=10)
65-
6670
servers = loop.run_until_complete(
6771
qubes.api.create_servers(
6872
qubes.api.admin.QubesAdminAPI,

0 commit comments

Comments
 (0)