From nobody Tue Apr 30 09:17:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507224277470688.2625608877095; Thu, 5 Oct 2017 10:24:37 -0700 (PDT) Received: from localhost ([::1]:41114 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e09si-0006xd-EZ for importer@patchew.org; Thu, 05 Oct 2017 13:24:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e09pI-0004a5-3m for qemu-devel@nongnu.org; Thu, 05 Oct 2017 13:20:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e09pH-0000gb-3X for qemu-devel@nongnu.org; Thu, 05 Oct 2017 13:20:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41756) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e09pG-0000fp-Tq for qemu-devel@nongnu.org; Thu, 05 Oct 2017 13:20:47 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC62FC04AC4E for ; Thu, 5 Oct 2017 17:20:45 +0000 (UTC) Received: from localhost (ovpn-116-25.gru2.redhat.com [10.97.116.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71564619C4; Thu, 5 Oct 2017 17:20:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DC62FC04AC4E Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 14:20:11 -0300 Message-Id: <20171005172013.3098-2-ehabkost@redhat.com> In-Reply-To: <20171005172013.3098-1-ehabkost@redhat.com> References: <20171005172013.3098-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 05 Oct 2017 17:20:46 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/3] guestperf: Configure logging on all shell frontends X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The logging module will eventually replace the 'debug' parameter in QEMUMachine and QEMUMonitorProtocol. Cc: Daniel P. Berrange Signed-off-by: Eduardo Habkost Reviewed-by: Luk=C3=A1=C5=A1 Doktor =20 --- Changes v1 -> v2: * Inline init_logging() method on all callers because not all classes derive from BaseShell (reported by Luk=C3=A1=C5=A1 Doktor) --- tests/migration/guestperf/shell.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/migration/guestperf/shell.py b/tests/migration/guestperf= /shell.py index 7992459a97..b272978f47 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 =20 from guestperf.hardware import Hardware from guestperf.engine import Engine @@ -147,6 +148,10 @@ class Shell(BaseShell): =20 def run(self, argv): args =3D self._parser.parse_args(argv) + logging.basicConfig(level=3D(logging.DEBUG if args.debug else + logging.INFO if args.verbose else + logging.WARN)) + =20 engine =3D self.get_engine(args) hardware =3D self.get_hardware(args) @@ -179,6 +184,10 @@ class BatchShell(BaseShell): =20 def run(self, argv): args =3D self._parser.parse_args(argv) + logging.basicConfig(level=3D(logging.DEBUG if args.debug else + logging.INFO if args.verbose else + logging.WARN)) + =20 engine =3D self.get_engine(args) hardware =3D self.get_hardware(args) @@ -231,6 +240,10 @@ class PlotShell(object): =20 def run(self, argv): args =3D self._parser.parse_args(argv) + logging.basicConfig(level=3D(logging.DEBUG if args.debug else + logging.INFO if args.verbose else + logging.WARN)) + =20 if len(args.reports) =3D=3D 0: print >>sys.stderr, "At least one report required" --=20 2.13.6 From nobody Tue Apr 30 09:17:40 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507224149467257.676708342373; Thu, 5 Oct 2017 10:22:29 -0700 (PDT) Received: from localhost ([::1]:41108 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e09qn-0005KS-Sh for importer@patchew.org; Thu, 05 Oct 2017 13:22:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e09pG-0004ZO-Uf for qemu-devel@nongnu.org; Thu, 05 Oct 2017 13:20:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e09pD-0000eF-NV for qemu-devel@nongnu.org; Thu, 05 Oct 2017 13:20:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34134) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e09pD-0000dv-E3 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 13:20:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5FAB74B70E; Thu, 5 Oct 2017 17:20:42 +0000 (UTC) Received: from localhost (ovpn-116-25.gru2.redhat.com [10.97.116.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0D2F85D763; Thu, 5 Oct 2017 17:20:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5FAB74B70E Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 14:20:12 -0300 Message-Id: <20171005172013.3098-3-ehabkost@redhat.com> In-Reply-To: <20171005172013.3098-1-ehabkost@redhat.com> References: <20171005172013.3098-1-ehabkost@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 05 Oct 2017 17:20:42 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/3] scripts: Remove debug parameter from QEMUMonitorProtocol X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Fam Zheng , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Cleber Rosa , =?UTF-8?q?Alex=20Benn=C3=A9e?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Use logging module for the QMP debug messages. The only scripts that set debug=3DTrue are iotests.py and guestperf/engine.py, and they already call logging.basicConfig() to set up logging. Scripts that don't configure logging are safe as long as they don't need debugging output, because debug messages don't trigger the "No handlers could be found for logger" message from the Python logging module. Scripts that already configure logging but don't use debug=3DTrue (e.g. scripts/vm/basevm.py) will get QMP debugging enabled for free. Cc: "Alex Benn=C3=A9e" Cc: Fam Zheng Cc: "Philippe Mathieu-Daud=C3=A9" Signed-off-by: Eduardo Habkost Reviewed-by: Luk=C3=A1=C5=A1 Doktor =20 --- Changes v1 -> v2: * Actually remove debug parameter from method definition (Fam Zheng) * Fix "<<<" vs ">>>" confusion (Fam Zheng) * Remove "import sys" line (Luk=C3=A1=C5=A1 Doktor) --- scripts/qemu.py | 3 +-- scripts/qmp/qmp.py | 16 +++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/scripts/qemu.py b/scripts/qemu.py index c9a106fbce..f6d2e68627 100644 --- a/scripts/qemu.py +++ b/scripts/qemu.py @@ -177,8 +177,7 @@ class QEMUMachine(object): =20 def _pre_launch(self): self._qmp =3D qmp.qmp.QEMUMonitorProtocol(self._monitor_address, - server=3DTrue, - debug=3Dself._debug) + server=3DTrue) =20 def _post_launch(self): self._qmp.accept() diff --git a/scripts/qmp/qmp.py b/scripts/qmp/qmp.py index ef12e8a1a0..07c9632e9e 100644 --- a/scripts/qmp/qmp.py +++ b/scripts/qmp/qmp.py @@ -11,7 +11,7 @@ import json import errno import socket -import sys +import logging =20 =20 class QMPError(Exception): @@ -32,12 +32,14 @@ class QMPTimeoutError(QMPError): =20 class QEMUMonitorProtocol(object): =20 + #: Logger object for debugging messages + logger =3D logging.getLogger('QMP') #: Socket's error class error =3D socket.error #: Socket's timeout timeout =3D socket.timeout =20 - def __init__(self, address, server=3DFalse, debug=3DFalse): + def __init__(self, address, server=3DFalse): """ Create a QEMUMonitorProtocol class. =20 @@ -51,7 +53,6 @@ class QEMUMonitorProtocol(object): """ self.__events =3D [] self.__address =3D address - self._debug =3D debug self.__sock =3D self.__get_sock() self.__sockfile =3D None if server: @@ -83,8 +84,7 @@ class QEMUMonitorProtocol(object): return resp =3D json.loads(data) if 'event' in resp: - if self._debug: - print >>sys.stderr, "QMP:<<< %s" % resp + self.logger.debug("<<< %s", resp) self.__events.append(resp) if not only_event: continue @@ -164,8 +164,7 @@ class QEMUMonitorProtocol(object): @return QMP response as a Python dict or None if the connection has been closed """ - if self._debug: - print >>sys.stderr, "QMP:>>> %s" % qmp_cmd + self.logger.debug(">>> %s", qmp_cmd) try: self.__sock.sendall(json.dumps(qmp_cmd)) except socket.error as err: @@ -173,8 +172,7 @@ class QEMUMonitorProtocol(object): return raise socket.error(err) resp =3D self.__json_read() - if self._debug: - print >>sys.stderr, "QMP:<<< %s" % resp + self.logger.debug("<<< %s", resp) return resp =20 def cmd(self, name, args=3DNone, cmd_id=3DNone): --=20 2.13.6 From nobody Tue Apr 30 09:17:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507224305103470.66066903532226; Thu, 5 Oct 2017 10:25:05 -0700 (PDT) Received: from localhost ([::1]:41115 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e09tL-0007Qn-DG for importer@patchew.org; Thu, 05 Oct 2017 13:24:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35672) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e09pK-0004bd-20 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 13:20:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e09pJ-0000j2-1w for qemu-devel@nongnu.org; Thu, 05 Oct 2017 13:20:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45584) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e09pI-0000i4-P8 for qemu-devel@nongnu.org; Thu, 05 Oct 2017 13:20:48 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C79757F41B for ; Thu, 5 Oct 2017 17:20:47 +0000 (UTC) Received: from localhost (ovpn-116-25.gru2.redhat.com [10.97.116.25]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E3BB600C0; Thu, 5 Oct 2017 17:20:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C79757F41B Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=ehabkost@redhat.com From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Thu, 5 Oct 2017 14:20:13 -0300 Message-Id: <20171005172013.3098-4-ehabkost@redhat.com> In-Reply-To: <20171005172013.3098-1-ehabkost@redhat.com> References: <20171005172013.3098-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 05 Oct 2017 17:20:47 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 3/3] scripts: Remove debug parameter from QEMUMachine X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Luk=C3=A1=C5=A1 Doktor =20 --- scripts/qemu.py | 6 ++---- tests/migration/guestperf/engine.py | 6 ++---- tests/qemu-iotests/iotests.py | 2 -- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/scripts/qemu.py b/scripts/qemu.py index f6d2e68627..9bfdf6d37d 100644 --- a/scripts/qemu.py +++ b/scripts/qemu.py @@ -54,7 +54,7 @@ class QEMUMachine(object): =20 def __init__(self, binary, args=3DNone, wrapper=3DNone, name=3DNone, test_dir=3D"/var/tmp", monitor_address=3DNone, - socket_scm_helper=3DNone, debug=3DFalse): + socket_scm_helper=3DNone): ''' Initialize a QEMUMachine =20 @@ -65,7 +65,6 @@ class QEMUMachine(object): @param test_dir: where to create socket and log file @param monitor_address: address for QMP monitor @param socket_scm_helper: helper program, required for send_fd_scm= ()" - @param debug: enable debug mode @note: Qemu process is not started until launch() is used. ''' if args is None: @@ -85,12 +84,11 @@ class QEMUMachine(object): self._events =3D [] self._iolog =3D None self._socket_scm_helper =3D socket_scm_helper - self._debug =3D debug self._qmp =3D None self._qemu_full_args =3D None =20 # just in case logging wasn't configured by the main script: - logging.basicConfig(level=3D(logging.DEBUG if debug else logging.W= ARN)) + logging.basicConfig() =20 def __enter__(self): return self diff --git a/tests/migration/guestperf/engine.py b/tests/migration/guestper= f/engine.py index 0a13050bc6..e14d4320b2 100644 --- a/tests/migration/guestperf/engine.py +++ b/tests/migration/guestperf/engine.py @@ -388,15 +388,13 @@ class Engine(object): args=3Dself._get_src_args(hardware), wrapper=3Dself._get_src_wrapper(hardware), name=3D"qemu-src-%d" % os.getpid(), - monitor_address=3Dsrcmonaddr, - debug=3Dself._debug) + monitor_address=3Dsrcmonaddr) =20 dst =3D qemu.QEMUMachine(self._binary, args=3Dself._get_dst_args(hardware, uri), wrapper=3Dself._get_dst_wrapper(hardware), name=3D"qemu-dst-%d" % os.getpid(), - monitor_address=3Ddstmonaddr, - debug=3Dself._debug) + monitor_address=3Ddstmonaddr) =20 try: src.launch() diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py index 36a7757aaf..6f057904a9 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=3Dname, test_dir=3Dtest_dir, socket_scm_helper=3Dsocket_scm_helper) - if debug: - self._debug =3D True self._num_drives =3D 0 =20 def add_device(self, opts): --=20 2.13.6