From 43851b5bd48d952561610d0d6d6c314c97eff543 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 27 Sep 2017 10:03:36 -0300 Subject: iotests: Set up Python logging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set up Python logging module instead of relying on QEMUMachine._debug to enable debugging messages. Cc: Kevin Wolf Cc: Max Reitz Cc: qemu-block@nongnu.org Signed-off-by: Eduardo Habkost Message-Id: <20170927130339.21444-3-ehabkost@redhat.com> Reviewed-by: Daniel P. Berrange Reviewed-by: Lukáš Doktor Signed-off-by: Eduardo Habkost --- tests/qemu-iotests/iotests.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests') diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 1af117e..36a7757 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -28,6 +28,7 @@ import qtest import struct import json import signal +import logging # This will not work if arguments contain spaces but is necessary if we @@ -467,6 +468,8 @@ def main(supported_fmts=[], supported_oses=['linux']): else: output = StringIO.StringIO() + logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN)) + class MyTestRunner(unittest.TextTestRunner): def __init__(self, stream=output, descriptions=True, verbosity=verbosity): unittest.TextTestRunner.__init__(self, stream, descriptions, verbosity) -- cgit v1.1 From fb3b4e6d88120da41ae553853b281214f7aac7cf Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Wed, 27 Sep 2017 10:03:37 -0300 Subject: basevm: Call logging.basicConfig() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Just setting level=DEBUG when debug is enabled is not enough: we need to set up a log handler if we want debug messages generated using logging.getLogger(...).debug() to be printed. This was not a problem before because logging.debug() calls logging.basicConfig() implicitly, but it's safer to not rely on that. Cc: "Alex Bennée" Cc: Fam Zheng Cc: "Philippe Mathieu-Daudé" Signed-off-by: Eduardo Habkost Message-Id: <20170927130339.21444-4-ehabkost@redhat.com> Reviewed-by: Daniel P. Berrange Reviewed-by: Fam Zheng Reviewed-by: Lukáš Doktor Signed-off-by: Eduardo Habkost --- tests/vm/basevm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py index 3c863bc..686d88d 100755 --- a/tests/vm/basevm.py +++ b/tests/vm/basevm.py @@ -227,8 +227,8 @@ def main(vmcls): if not argv and not args.build_qemu and not args.build_image: print "Nothing to do?" return 1 - if args.debug: - logging.getLogger().setLevel(logging.DEBUG) + logging.basicConfig(level=(logging.DEBUG if args.debug + else logging.WARN)) vm = vmcls(debug=args.debug, vcpus=args.jobs) if args.build_image: if os.path.exists(args.image) and not args.force: -- cgit v1.1 From 8af09b8001301e6bb085a23fc029da94e0725c1c Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Thu, 5 Oct 2017 14:20:11 -0300 Subject: guestperf: Configure logging on all shell frontends MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The logging module will eventually replace the 'debug' parameter in QEMUMachine and QEMUMonitorProtocol. Cc: Daniel P. Berrange Signed-off-by: Eduardo Habkost Message-Id: <20171005172013.3098-2-ehabkost@redhat.com> Reviewed-by: Lukáš Doktor Signed-off-by: Eduardo Habkost --- tests/migration/guestperf/shell.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests') diff --git a/tests/migration/guestperf/shell.py b/tests/migration/guestperf/shell.py index 7992459..b272978 100644 --- a/tests/migration/guestperf/shell.py +++ b/tests/migration/guestperf/shell.py @@ -26,6 +26,7 @@ sys.path.append(os.path.join(os.path.dirname(__file__), import argparse import fnmatch import platform +import logging from guestperf.hardware import Hardware from guestperf.engine import Engine @@ -147,6 +148,10 @@ class Shell(BaseShell): def run(self, argv): args = self._parser.parse_args(argv) + logging.basicConfig(level=(logging.DEBUG if args.debug else + logging.INFO if args.verbose else + logging.WARN)) + engine = self.get_engine(args) hardware = self.get_hardware(args) @@ -179,6 +184,10 @@ class BatchShell(BaseShell): def run(self, argv): args = self._parser.parse_args(argv) + logging.basicConfig(level=(logging.DEBUG if args.debug else + logging.INFO if args.verbose else + logging.WARN)) + engine = self.get_engine(args) hardware = self.get_hardware(args) @@ -231,6 +240,10 @@ class PlotShell(object): def run(self, argv): args = self._parser.parse_args(argv) + logging.basicConfig(level=(logging.DEBUG if args.debug else + logging.INFO if args.verbose else + logging.WARN)) + if len(args.reports) == 0: print >>sys.stderr, "At least one report required" -- cgit v1.1 From 1a6d3757107181dc0b9baf3dd8ff40fb2a242b66 Mon Sep 17 00:00:00 2001 From: Eduardo Habkost Date: Thu, 5 Oct 2017 14:20:13 -0300 Subject: scripts: Remove debug parameter from QEMUMachine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All scripts that use the QEMUMachine and QEMUQtestMachine classes (device-crash-test, tests/migration/*, iotests.py, basevm.py) already configure logging. The basicConfig() call inside QEMUMachine.__init__() is being kept just to make sure a script would still work if it didn't configure logging. Signed-off-by: Eduardo Habkost Message-Id: <20171005172013.3098-4-ehabkost@redhat.com> Reviewed-by: Lukáš Doktor Signed-off-by: Eduardo Habkost --- tests/migration/guestperf/engine.py | 6 ++---- tests/qemu-iotests/iotests.py | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/migration/guestperf/engine.py b/tests/migration/guestperf/engine.py index 0a13050..e14d432 100644 --- a/tests/migration/guestperf/engine.py +++ b/tests/migration/guestperf/engine.py @@ -388,15 +388,13 @@ class Engine(object): args=self._get_src_args(hardware), wrapper=self._get_src_wrapper(hardware), name="qemu-src-%d" % os.getpid(), - monitor_address=srcmonaddr, - debug=self._debug) + monitor_address=srcmonaddr) dst = qemu.QEMUMachine(self._binary, args=self._get_dst_args(hardware, uri), wrapper=self._get_dst_wrapper(hardware), name="qemu-dst-%d" % os.getpid(), - monitor_address=dstmonaddr, - debug=self._debug) + monitor_address=dstmonaddr) try: src.launch() diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 36a7757..6f05790 100644 --- a/tests/qemu-iotests/iotests.py +++ b/tests/qemu-iotests/iotests.py @@ -195,8 +195,6 @@ class VM(qtest.QEMUQtestMachine): super(VM, self).__init__(qemu_prog, qemu_opts, name=name, test_dir=test_dir, socket_scm_helper=socket_scm_helper) - if debug: - self._debug = True self._num_drives = 0 def add_device(self, opts): -- cgit v1.1