From nobody Fri May 3 11:12:59 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520871212561715.8960008439865; Mon, 12 Mar 2018 09:13:32 -0700 (PDT) Received: from localhost ([::1]:32961 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evQ4p-0006J9-Mf for importer@patchew.org; Mon, 12 Mar 2018 12:13:31 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51015) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evPsD-0004uN-OE for qemu-devel@nongnu.org; Mon, 12 Mar 2018 12:00:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evPs9-0000fr-EL for qemu-devel@nongnu.org; Mon, 12 Mar 2018 12:00:29 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:55024 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1evPs9-0000fR-7b for qemu-devel@nongnu.org; Mon, 12 Mar 2018 12:00:25 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7E2DC402290A; Mon, 12 Mar 2018 16:00:23 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A7C810B0F46; Mon, 12 Mar 2018 16:00:20 +0000 (UTC) From: Stefan Hajnoczi To: Date: Mon, 12 Mar 2018 16:00:10 +0000 Message-Id: <20180312160014.6804-2-stefanha@redhat.com> In-Reply-To: <20180312160014.6804-1-stefanha@redhat.com> References: <20180312160014.6804-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 12 Mar 2018 16:00:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Mon, 12 Mar 2018 16:00:23 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'stefanha@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 1/5] log-for-trace.h: Split out parts of log.h used by trace.h 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: Peter Maydell , Eduardo Habkost , Stefan Hajnoczi , 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" From: Peter Maydell A persistent build problem we see is where a source file accidentally omits the #include of log.h. This slips through local developer testing because if you configure with the default (log) trace backend trace.h will pull in log.h for you. Compilation fails only if some other backend is selected. To make this error cause a compile failure regardless of the configured trace backend, split out the parts of log.h that trace.h requires into a new log-for-trace.h header. Since almost all manual uses of the log.h functions will use constants or functions which aren't in log-for-trace.h, this will let us catch missing #include "qemu/log.h" more consistently. Signed-off-by: Peter Maydell Reviewed-by: Eric Blake Reviewed-by: Richard Henderson Message-id: 20180213140029.8308-1-peter.maydell@linaro.org Signed-off-by: Stefan Hajnoczi --- include/qemu/log-for-trace.h | 35 +++++++++++++++++++++++++++++++++++ include/qemu/log.h | 18 ++++-------------- scripts/tracetool/backend/log.py | 13 ++++++------- 3 files changed, 45 insertions(+), 21 deletions(-) create mode 100644 include/qemu/log-for-trace.h diff --git a/include/qemu/log-for-trace.h b/include/qemu/log-for-trace.h new file mode 100644 index 0000000000..2f0a5b080e --- /dev/null +++ b/include/qemu/log-for-trace.h @@ -0,0 +1,35 @@ +/* log-for-trace.h: logging basics required by the trace.h generated + * by the log trace backend. + * + * This should not be included directly by any .c file: if you + * need to use the logging functions include "qemu/log.h". + * + * The purpose of splitting these parts out into their own header + * is to catch the easy mistake where a .c file includes trace.h + * but forgets to include qemu/log.h. Without this split, that + * would result in the .c file compiling fine when the default + * trace backend is in use but failing to compile with any other + * backend. + * + * This code is licensed under the GNU General Public License, + * version 2 or (at your option) any later version. + */ + +#ifndef QEMU_LOG_FOR_TRACE_H +#define QEMU_LOG_FOR_TRACE_H + +/* Private global variable, don't use */ +extern int qemu_loglevel; + +#define LOG_TRACE (1 << 15) + +/* Returns true if a bit is set in the current loglevel mask */ +static inline bool qemu_loglevel_mask(int mask) +{ + return (qemu_loglevel & mask) !=3D 0; +} + +/* main logging function */ +int GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...); + +#endif diff --git a/include/qemu/log.h b/include/qemu/log.h index a50e994c21..ff92a8b86a 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -1,10 +1,11 @@ #ifndef QEMU_LOG_H #define QEMU_LOG_H =20 +/* A small part of this API is split into its own header */ +#include "qemu/log-for-trace.h" =20 -/* Private global variables, don't use */ +/* Private global variable, don't use */ extern FILE *qemu_logfile; -extern int qemu_loglevel; =20 /*=20 * The new API: @@ -41,16 +42,9 @@ static inline bool qemu_log_separate(void) #define CPU_LOG_MMU (1 << 12) #define CPU_LOG_TB_NOCHAIN (1 << 13) #define CPU_LOG_PAGE (1 << 14) -#define LOG_TRACE (1 << 15) +/* LOG_TRACE (1 << 15) is defined in log-for-trace.h */ #define CPU_LOG_TB_OP_IND (1 << 16) =20 -/* Returns true if a bit is set in the current loglevel mask - */ -static inline bool qemu_loglevel_mask(int mask) -{ - return (qemu_loglevel & mask) !=3D 0; -} - /* Lock output for a series of related logs. Since this is not needed * for a single qemu_log / qemu_log_mask / qemu_log_mask_and_addr, we * assume that qemu_loglevel_mask has already been tested, and that @@ -69,10 +63,6 @@ static inline void qemu_log_unlock(void) =20 /* Logging functions: */ =20 -/* main logging function - */ -int GCC_FMT_ATTR(1, 2) qemu_log(const char *fmt, ...); - /* vfprintf-like logging function */ static inline void GCC_FMT_ATTR(1, 0) diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/l= og.py index da86f6b882..78933d03ad 100644 --- a/scripts/tracetool/backend/log.py +++ b/scripts/tracetool/backend/log.py @@ -20,7 +20,7 @@ PUBLIC =3D True =20 =20 def generate_h_begin(events, group): - out('#include "qemu/log.h"', + out('#include "qemu/log-for-trace.h"', '') =20 =20 @@ -35,14 +35,13 @@ def generate_h(event, group): else: cond =3D "trace_event_get_state(%s)" % ("TRACE_" + event.name.uppe= r()) =20 - out(' if (%(cond)s) {', + out(' if (%(cond)s && qemu_loglevel_mask(LOG_TRACE)) {', ' struct timeval _now;', ' gettimeofday(&_now, NULL);', - ' qemu_log_mask(LOG_TRACE,', - ' "%%d@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",', - ' getpid(),', - ' (size_t)_now.tv_sec, (size_t)_now.tv_usec', - ' %(argnames)s);', + ' qemu_log("%%d@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",', + ' getpid(),', + ' (size_t)_now.tv_sec, (size_t)_now.tv_usec', + ' %(argnames)s);', ' }', cond=3Dcond, name=3Devent.name, --=20 2.14.3 From nobody Fri May 3 11:12:59 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520871045325928.8118312847083; Mon, 12 Mar 2018 09:10:45 -0700 (PDT) Received: from localhost ([::1]:32937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evQ28-0003ns-EF for importer@patchew.org; Mon, 12 Mar 2018 12:10:44 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evPsF-0004wD-UI for qemu-devel@nongnu.org; Mon, 12 Mar 2018 12:00:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evPsB-0000iL-Op for qemu-devel@nongnu.org; Mon, 12 Mar 2018 12:00:31 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:54358 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1evPsB-0000hT-K4 for qemu-devel@nongnu.org; Mon, 12 Mar 2018 12:00:27 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1A0EB4040856; Mon, 12 Mar 2018 16:00:27 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id A12867C51; Mon, 12 Mar 2018 16:00:24 +0000 (UTC) From: Stefan Hajnoczi To: Date: Mon, 12 Mar 2018 16:00:11 +0000 Message-Id: <20180312160014.6804-3-stefanha@redhat.com> In-Reply-To: <20180312160014.6804-1-stefanha@redhat.com> References: <20180312160014.6804-1-stefanha@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 12 Mar 2018 16:00:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Mon, 12 Mar 2018 16:00:27 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'stefanha@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 2/5] simpletrace: fix timestamp argument type 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: Peter Maydell , Eduardo Habkost , Stefan Hajnoczi , 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" The timestamp argument to a trace event method is documented as follows: The method can also take a timestamp argument before the trace event arguments: def runstate_set(self, timestamp, new_state): ... Timestamps have the uint64_t type and are in nanoseconds. In reality methods with a timestamp argument actually receive a tuple like (123456789,) as the timestamp argument. This is due to a bug in simpletrace.py. This patch unpacks the tuple so that methods receive the correct timestamp argument type. Signed-off-by: Stefan Hajnoczi Message-id: 20180222163901.14095-1-stefanha@redhat.com Signed-off-by: Stefan Hajnoczi --- scripts/simpletrace.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/simpletrace.py b/scripts/simpletrace.py index a3a6315055..be3d1affaf 100755 --- a/scripts/simpletrace.py +++ b/scripts/simpletrace.py @@ -199,7 +199,7 @@ def process(events, log, analyzer, read_header=3DTrue): fn_argcount =3D len(inspect.getargspec(fn)[0]) - 1 if fn_argcount =3D=3D event_argcount + 1: # Include timestamp as first argument - return lambda _, rec: fn(*((rec[1:2],) + rec[3:3 + event_argco= unt])) + return lambda _, rec: fn(*(rec[1:2] + rec[3:3 + event_argcount= ])) elif fn_argcount =3D=3D event_argcount + 2: # Include timestamp and pid return lambda _, rec: fn(*rec[1:3 + event_argcount]) --=20 2.14.3 From nobody Fri May 3 11:12:59 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520871085071709.6439040686056; Mon, 12 Mar 2018 09:11:25 -0700 (PDT) Received: from localhost ([::1]:32941 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evQ2k-0004O0-9U for importer@patchew.org; Mon, 12 Mar 2018 12:11:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51106) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evPsJ-0004zS-6f for qemu-devel@nongnu.org; Mon, 12 Mar 2018 12:00:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evPsD-0000k0-8u for qemu-devel@nongnu.org; Mon, 12 Mar 2018 12:00:35 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33204 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1evPsC-0000jV-Vd for qemu-devel@nongnu.org; Mon, 12 Mar 2018 12:00:29 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7CE4F230EEE; Mon, 12 Mar 2018 16:00:28 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6B5110B0F43; Mon, 12 Mar 2018 16:00:27 +0000 (UTC) From: Stefan Hajnoczi To: Date: Mon, 12 Mar 2018 16:00:12 +0000 Message-Id: <20180312160014.6804-4-stefanha@redhat.com> In-Reply-To: <20180312160014.6804-1-stefanha@redhat.com> References: <20180312160014.6804-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 12 Mar 2018 16:00:28 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 12 Mar 2018 16:00:28 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'stefanha@redhat.com' RCPT:'' 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: 66.187.233.73 Subject: [Qemu-devel] [PULL 3/5] trace: include filename when printing parser error messages 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: Peter Maydell , Eduardo Habkost , Stefan Hajnoczi , 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" From: Daniel P. Berrang=C3=A9 Improves error messages from: ValueError: Error on line 72: need more than 1 value to unpack To ValueError: Error at /home/berrange/src/virt/qemu/trace-events:72: need more than 1 value to unpack Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20180306154650.24075-1-berrange@redhat.com Signed-off-by: Stefan Hajnoczi --- scripts/simpletrace.py | 4 ++-- scripts/tracetool.py | 2 +- scripts/tracetool/__init__.py | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/simpletrace.py b/scripts/simpletrace.py index be3d1affaf..9d45c6ba4e 100755 --- a/scripts/simpletrace.py +++ b/scripts/simpletrace.py @@ -168,7 +168,7 @@ class Analyzer(object): def process(events, log, analyzer, read_header=3DTrue): """Invoke an analyzer on each event in a log.""" if isinstance(events, str): - events =3D read_events(open(events, 'r')) + events =3D read_events(open(events, 'r'), events) if isinstance(log, str): log =3D open(log, 'rb') =20 @@ -233,7 +233,7 @@ def run(analyzer): '\n' % sys.argv[0]) sys.exit(1) =20 - events =3D read_events(open(sys.argv[1], 'r')) + events =3D read_events(open(sys.argv[1], 'r'), sys.argv[1]) process(events, sys.argv[2], analyzer, read_header=3Dread_header) =20 if __name__ =3D=3D '__main__': diff --git a/scripts/tracetool.py b/scripts/tracetool.py index c55a21518b..fe2b0771f2 100755 --- a/scripts/tracetool.py +++ b/scripts/tracetool.py @@ -142,7 +142,7 @@ def main(args): events =3D [] for arg in args: with open(arg, "r") as fh: - events.extend(tracetool.read_events(fh)) + events.extend(tracetool.read_events(fh, arg)) =20 try: tracetool.generate(events, arg_group, arg_format, arg_backends, diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index 3646c2b9fc..4236062650 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -291,13 +291,15 @@ class Event(object): self) =20 =20 -def read_events(fobj): +def read_events(fobj, fname): """Generate the output for the given (format, backends) pair. =20 Parameters ---------- fobj : file Event description file. + fname : str + Name of event file =20 Returns a list of Event objects """ @@ -312,7 +314,7 @@ def read_events(fobj): try: event =3D Event.build(line) except ValueError as e: - arg0 =3D 'Error on line %d: %s' % (lineno, e.args[0]) + arg0 =3D 'Error at %s:%d: %s' % (fname, lineno, e.args[0]) e.args =3D (arg0,) + e.args[1:] raise =20 --=20 2.14.3 From nobody Fri May 3 11:12:59 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 152087068440516.834955856146394; Mon, 12 Mar 2018 09:04:44 -0700 (PDT) Received: from localhost ([::1]:32873 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evPwJ-0007ej-4N for importer@patchew.org; Mon, 12 Mar 2018 12:04:43 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evPsF-0004vc-9d for qemu-devel@nongnu.org; Mon, 12 Mar 2018 12:00:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evPsE-0000l4-F6 for qemu-devel@nongnu.org; Mon, 12 Mar 2018 12:00:31 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:57156 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1evPsE-0000ki-6K for qemu-devel@nongnu.org; Mon, 12 Mar 2018 12:00:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B7FD98182D1D; Mon, 12 Mar 2018 16:00:29 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 69B292026E03; Mon, 12 Mar 2018 16:00:29 +0000 (UTC) From: Stefan Hajnoczi To: Date: Mon, 12 Mar 2018 16:00:13 +0000 Message-Id: <20180312160014.6804-5-stefanha@redhat.com> In-Reply-To: <20180312160014.6804-1-stefanha@redhat.com> References: <20180312160014.6804-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 12 Mar 2018 16:00:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 12 Mar 2018 16:00:29 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'stefanha@redhat.com' RCPT:'' 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: 66.187.233.73 Subject: [Qemu-devel] [PULL 4/5] trace: remove use of QEMU specific types from trace probes 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: Peter Maydell , Eduardo Habkost , Stefan Hajnoczi , Cleber Rosa 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" From: Daniel P. Berrang=C3=A9 Any compound structs / unions / etc, should always be declared as 'void *' pointers, since it cannot be assumed that trace backends are able to resolve QEMU typedefs. Signed-off-by: Daniel P. Berrang=C3=A9 Message-id: 20180308155524.5082-2-berrange@redhat.com Signed-off-by: Stefan Hajnoczi --- trace-events | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/trace-events b/trace-events index 89fcad0fd1..855b0ab240 100644 --- a/trace-events +++ b/trace-events @@ -68,9 +68,9 @@ memory_region_tb_read(int cpu_index, uint64_t addr, uint6= 4_t value, unsigned siz memory_region_tb_write(int cpu_index, uint64_t addr, uint64_t value, unsig= ned size) "cpu %d addr 0x%"PRIx64" value 0x%"PRIx64" size %u" memory_region_ram_device_read(int cpu_index, void *mr, uint64_t addr, uint= 64_t value, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64"= size %u" memory_region_ram_device_write(int cpu_index, void *mr, uint64_t addr, uin= t64_t value, unsigned size) "cpu %d mr %p addr 0x%"PRIx64" value 0x%"PRIx64= " size %u" -flatview_new(FlatView *view, MemoryRegion *root) "%p (root %p)" -flatview_destroy(FlatView *view, MemoryRegion *root) "%p (root %p)" -flatview_destroy_rcu(FlatView *view, MemoryRegion *root) "%p (root %p)" +flatview_new(void *view, void *root) "%p (root %p)" +flatview_destroy(void *view, void *root) "%p (root %p)" +flatview_destroy_rcu(void *view, void *root) "%p (root %p)" =20 # gdbstub.c gdbstub_op_start(const char *device) "Starting gdbstub using device %s" --=20 2.14.3 From nobody Fri May 3 11:12:59 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1520870847871466.80095077439273; Mon, 12 Mar 2018 09:07:27 -0700 (PDT) Received: from localhost ([::1]:32906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evPyi-0000v5-Gl for importer@patchew.org; Mon, 12 Mar 2018 12:07:12 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51066) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evPsG-0004x5-Rs for qemu-devel@nongnu.org; Mon, 12 Mar 2018 12:00:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evPsF-0000nQ-St for qemu-devel@nongnu.org; Mon, 12 Mar 2018 12:00:32 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33208 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1evPsF-0000mO-DE for qemu-devel@nongnu.org; Mon, 12 Mar 2018 12:00:31 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DFF1A230EEE; Mon, 12 Mar 2018 16:00:30 +0000 (UTC) Received: from localhost (unknown [10.36.118.38]) by smtp.corp.redhat.com (Postfix) with ESMTP id 84581215CDA7; Mon, 12 Mar 2018 16:00:30 +0000 (UTC) From: Stefan Hajnoczi To: Date: Mon, 12 Mar 2018 16:00:14 +0000 Message-Id: <20180312160014.6804-6-stefanha@redhat.com> In-Reply-To: <20180312160014.6804-1-stefanha@redhat.com> References: <20180312160014.6804-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 12 Mar 2018 16:00:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.2]); Mon, 12 Mar 2018 16:00:30 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'stefanha@redhat.com' RCPT:'' 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: 66.187.233.73 Subject: [Qemu-devel] [PULL 5/5] trace: only permit standard C types and fixed size integer types 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: Peter Maydell , Eduardo Habkost , Stefan Hajnoczi , 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" From: Daniel P. Berrang=C3=A9 Some trace backends will compile code based on the declared trace events. It should not be assumed that the backends can resolve any QEMU specific typedefs. So trace events should restrict their argument types to the standard C types and fixed size integer types. Any complex pointer types can be declared as "void *" for purposes of trace events, since nothing will be dereferencing these pointer arguments. Signed-off-by: Daniel P. Berrang=C3=A9 Message-id: 20180308155524.5082-3-berrange@redhat.com Signed-off-by: Stefan Hajnoczi --- scripts/tracetool/__init__.py | 46 +++++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 46 insertions(+) diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py index 4236062650..b20fac34a3 100644 --- a/scripts/tracetool/__init__.py +++ b/scripts/tracetool/__init__.py @@ -41,6 +41,51 @@ def out(*lines, **kwargs): lines =3D [ l % kwargs for l in lines ] sys.stdout.writelines("\n".join(lines) + "\n") =20 +# We only want to allow standard C types or fixed sized +# integer types. We don't want QEMU specific types +# as we can't assume trace backends can resolve all the +# typedefs +ALLOWED_TYPES =3D [ + "int", + "long", + "short", + "char", + "bool", + "unsigned", + "signed", + "float", + "double", + "int8_t", + "uint8_t", + "int16_t", + "uint16_t", + "int32_t", + "uint32_t", + "int64_t", + "uint64_t", + "void", + "size_t", + "ssize_t", + "uintptr_t", + "ptrdiff_t", + # Magic substitution is done by tracetool + "TCGv", +] + +def validate_type(name): + bits =3D name.split(" ") + for bit in bits: + bit =3D re.sub("\*", "", bit) + if bit =3D=3D "": + continue + if bit =3D=3D "const": + continue + if bit not in ALLOWED_TYPES: + raise ValueError("Argument type '%s' is not in whitelist. " + "Only standard C types and fixed size integer= " + "types should be used. struct, union, and " + "other complex pointer types should be " + "declared as 'void *'" % name) =20 class Arguments: """Event arguments description.""" @@ -87,6 +132,7 @@ class Arguments: else: arg_type, identifier =3D arg.rsplit(None, 1) =20 + validate_type(arg_type) res.append((arg_type, identifier)) return Arguments(res) =20 --=20 2.14.3