* [PULL 0/8] Tracing patches
@ 2026-01-19 19:08 Stefan Hajnoczi
2026-01-19 19:08 ` [PULL 1/8] tracetool: rename variable with conflicting types Stefan Hajnoczi
` (8 more replies)
0 siblings, 9 replies; 12+ messages in thread
From: Stefan Hajnoczi @ 2026-01-19 19:08 UTC (permalink / raw)
To: qemu-devel
Cc: Cleber Rosa, Stefan Hajnoczi, Mads Ynddal, Richard Henderson,
John Snow
The following changes since commit 38879a667fbb4ef54c70de71494882615f600a64:
Merge tag 'pull-tcg-20260119' of https://gitlab.com/rth7680/qemu into staging (2026-01-19 09:04:31 +1100)
are available in the Git repository at:
https://gitlab.com/stefanha/qemu.git tags/tracing-pull-request
for you to fetch changes up to 0527c4fdd28ae8b13ecc34f80b91e42ce42b917f:
tests/tracetool: Honor the Python interpreter that "configure" detected (2026-01-19 13:58:23 -0500)
----------------------------------------------------------------
Pull request
- Thomas Huth's Python interpreter fix
- Paolo Bonzini's tracetool cleanups
- Stefan Hajnoczi's tracetool test QEMU_TEST_KEEP_SCRATCH=1 support
----------------------------------------------------------------
Paolo Bonzini (6):
tracetool: rename variable with conflicting types
tracetool: apply isort and add check
tracetool: "import annotations"
tracetool: add type annotations
tracetool: complete typing annotations
tracetool: add typing checks to "make -C python check"
Stefan Hajnoczi (1):
tracetool-test: add QEMU_TEST_KEEP_SCRATCH=1 support
Thomas Huth (1):
tests/tracetool: Honor the Python interpreter that "configure"
detected
python/tests/tracetool-isort.sh | 4 +
python/tests/tracetool-mypy.sh | 5 ++
scripts/tracetool.py | 12 +--
scripts/tracetool/__init__.py | 84 ++++++++++----------
scripts/tracetool/backend/__init__.py | 21 ++---
scripts/tracetool/backend/dtrace.py | 19 ++---
scripts/tracetool/backend/ftrace.py | 13 +--
scripts/tracetool/backend/log.py | 13 +--
scripts/tracetool/backend/simple.py | 19 ++---
scripts/tracetool/backend/syslog.py | 13 +--
scripts/tracetool/backend/ust.py | 11 +--
scripts/tracetool/format/__init__.py | 9 ++-
scripts/tracetool/format/c.py | 7 +-
scripts/tracetool/format/d.py | 7 +-
scripts/tracetool/format/h.py | 7 +-
scripts/tracetool/format/log_stap.py | 12 +--
scripts/tracetool/format/rs.py | 7 +-
scripts/tracetool/format/simpletrace_stap.py | 7 +-
scripts/tracetool/format/stap.py | 10 ++-
scripts/tracetool/format/ust_events_c.py | 7 +-
scripts/tracetool/format/ust_events_h.py | 7 +-
tests/tracetool/tracetool-test.py | 27 +++++--
22 files changed, 195 insertions(+), 126 deletions(-)
create mode 100755 python/tests/tracetool-isort.sh
create mode 100755 python/tests/tracetool-mypy.sh
--
2.52.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PULL 1/8] tracetool: rename variable with conflicting types
2026-01-19 19:08 [PULL 0/8] Tracing patches Stefan Hajnoczi
@ 2026-01-19 19:08 ` Stefan Hajnoczi
2026-01-19 19:08 ` [PULL 2/8] tracetool: apply isort and add check Stefan Hajnoczi
` (7 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Stefan Hajnoczi @ 2026-01-19 19:08 UTC (permalink / raw)
To: qemu-devel
Cc: Cleber Rosa, Stefan Hajnoczi, Mads Ynddal, Richard Henderson,
John Snow, Paolo Bonzini, Daniel P. Berrangé
From: Paolo Bonzini <pbonzini@redhat.com>
"backend" is used as both a string and a backend.Wrapper. In preparation
for adding type annotations, use different names.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20251008063546.376603-2-pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
scripts/tracetool/__init__.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index 61ba6f1ba8..fab98bf67e 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -567,9 +567,9 @@ def generate(events, group, format, backends,
if len(backends) == 0:
raise TracetoolError("no backends specified")
- for backend in backends:
- if not tracetool.backend.exists(backend):
- raise TracetoolError("unknown backend: %s" % backend)
+ for backend_name in backends:
+ if not tracetool.backend.exists(backend_name):
+ raise TracetoolError("unknown backend: %s" % backend_name)
backend = tracetool.backend.Wrapper(backends, format)
import tracetool.backend.dtrace
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PULL 2/8] tracetool: apply isort and add check
2026-01-19 19:08 [PULL 0/8] Tracing patches Stefan Hajnoczi
2026-01-19 19:08 ` [PULL 1/8] tracetool: rename variable with conflicting types Stefan Hajnoczi
@ 2026-01-19 19:08 ` Stefan Hajnoczi
2026-01-19 19:08 ` [PULL 3/8] tracetool: "import annotations" Stefan Hajnoczi
` (6 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Stefan Hajnoczi @ 2026-01-19 19:08 UTC (permalink / raw)
To: qemu-devel
Cc: Cleber Rosa, Stefan Hajnoczi, Mads Ynddal, Richard Henderson,
John Snow, Paolo Bonzini, Daniel P. Berrangé
From: Paolo Bonzini <pbonzini@redhat.com>
Sort imports automatically, to keep the coding style more uniform.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20251008063546.376603-3-pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
python/tests/tracetool-isort.sh | 4 ++++
scripts/tracetool.py | 5 ++---
scripts/tracetool/backend/dtrace.py | 1 -
scripts/tracetool/backend/ftrace.py | 3 +--
scripts/tracetool/backend/log.py | 3 +--
scripts/tracetool/backend/simple.py | 1 -
scripts/tracetool/backend/syslog.py | 3 +--
scripts/tracetool/backend/ust.py | 1 -
scripts/tracetool/format/d.py | 2 +-
scripts/tracetool/format/log_stap.py | 1 -
scripts/tracetool/format/stap.py | 1 -
11 files changed, 10 insertions(+), 15 deletions(-)
create mode 100755 python/tests/tracetool-isort.sh
diff --git a/python/tests/tracetool-isort.sh b/python/tests/tracetool-isort.sh
new file mode 100755
index 0000000000..b23f3d4844
--- /dev/null
+++ b/python/tests/tracetool-isort.sh
@@ -0,0 +1,4 @@
+#!/bin/sh -e
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+python3 -m isort --sp . -c ../scripts/tracetool/
diff --git a/scripts/tracetool.py b/scripts/tracetool.py
index 0fdc9cb947..22fdc29e01 100755
--- a/scripts/tracetool.py
+++ b/scripts/tracetool.py
@@ -12,13 +12,12 @@
__email__ = "stefanha@redhat.com"
-import sys
import getopt
+import sys
-from tracetool import error_write, out, out_open
import tracetool.backend
import tracetool.format
-
+from tracetool import error_write, out, out_open
_SCRIPT = ""
diff --git a/scripts/tracetool/backend/dtrace.py b/scripts/tracetool/backend/dtrace.py
index f0b58cc158..5f313ddaed 100644
--- a/scripts/tracetool/backend/dtrace.py
+++ b/scripts/tracetool/backend/dtrace.py
@@ -14,7 +14,6 @@
from tracetool import out
-
PUBLIC = True
diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backend/ftrace.py
index e03698a2ed..0d77bd23a5 100644
--- a/scripts/tracetool/backend/ftrace.py
+++ b/scripts/tracetool/backend/ftrace.py
@@ -12,8 +12,7 @@
__email__ = "stefanha@redhat.com"
-from tracetool import out, expand_format_string
-
+from tracetool import expand_format_string, out
PUBLIC = True
CHECK_TRACE_EVENT_GET_STATE = True
diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/log.py
index 9e3e5046f5..bbfb56911d 100644
--- a/scripts/tracetool/backend/log.py
+++ b/scripts/tracetool/backend/log.py
@@ -12,8 +12,7 @@
__email__ = "stefanha@redhat.com"
-from tracetool import out, expand_format_string
-
+from tracetool import expand_format_string, out
PUBLIC = True
CHECK_TRACE_EVENT_GET_STATE = True
diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backend/simple.py
index b131e4fc19..b67257ce7e 100644
--- a/scripts/tracetool/backend/simple.py
+++ b/scripts/tracetool/backend/simple.py
@@ -14,7 +14,6 @@
from tracetool import out
-
PUBLIC = True
CHECK_TRACE_EVENT_GET_STATE = True
diff --git a/scripts/tracetool/backend/syslog.py b/scripts/tracetool/backend/syslog.py
index 12b826593d..c3efab036c 100644
--- a/scripts/tracetool/backend/syslog.py
+++ b/scripts/tracetool/backend/syslog.py
@@ -12,8 +12,7 @@
__email__ = "stefanha@redhat.com"
-from tracetool import out, expand_format_string
-
+from tracetool import expand_format_string, out
PUBLIC = True
CHECK_TRACE_EVENT_GET_STATE = True
diff --git a/scripts/tracetool/backend/ust.py b/scripts/tracetool/backend/ust.py
index 3aa9bb1da2..a70e3d83e1 100644
--- a/scripts/tracetool/backend/ust.py
+++ b/scripts/tracetool/backend/ust.py
@@ -14,7 +14,6 @@
from tracetool import out
-
PUBLIC = True
diff --git a/scripts/tracetool/format/d.py b/scripts/tracetool/format/d.py
index e9e33dfe30..0befd444e8 100644
--- a/scripts/tracetool/format/d.py
+++ b/scripts/tracetool/format/d.py
@@ -12,9 +12,9 @@
__email__ = "stefanha@redhat.com"
-from tracetool import out
from sys import platform
+from tracetool import out
# Reserved keywords from
# https://wikis.oracle.com/display/DTrace/Types,+Operators+and+Expressions
diff --git a/scripts/tracetool/format/log_stap.py b/scripts/tracetool/format/log_stap.py
index 259303a189..99c6181f38 100644
--- a/scripts/tracetool/format/log_stap.py
+++ b/scripts/tracetool/format/log_stap.py
@@ -18,7 +18,6 @@
from tracetool.backend.simple import is_string
from tracetool.format.stap import stap_escape
-
STATE_SKIP = 0
STATE_LITERAL = 1
STATE_MACRO = 2
diff --git a/scripts/tracetool/format/stap.py b/scripts/tracetool/format/stap.py
index 285c9203ba..f917bd7545 100644
--- a/scripts/tracetool/format/stap.py
+++ b/scripts/tracetool/format/stap.py
@@ -15,7 +15,6 @@
from tracetool import out
from tracetool.backend.dtrace import binary, probeprefix
-
# Technically 'self' is not used by systemtap yet, but
# they recommended we keep it in the reserved list anyway
RESERVED_WORDS = (
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PULL 3/8] tracetool: "import annotations"
2026-01-19 19:08 [PULL 0/8] Tracing patches Stefan Hajnoczi
2026-01-19 19:08 ` [PULL 1/8] tracetool: rename variable with conflicting types Stefan Hajnoczi
2026-01-19 19:08 ` [PULL 2/8] tracetool: apply isort and add check Stefan Hajnoczi
@ 2026-01-19 19:08 ` Stefan Hajnoczi
2026-01-19 19:08 ` [PULL 4/8] tracetool: add type annotations Stefan Hajnoczi
` (5 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Stefan Hajnoczi @ 2026-01-19 19:08 UTC (permalink / raw)
To: qemu-devel
Cc: Cleber Rosa, Stefan Hajnoczi, Mads Ynddal, Richard Henderson,
John Snow, Paolo Bonzini, Daniel P. Berrangé
From: Paolo Bonzini <pbonzini@redhat.com>
In preparations for adding type annotations, make Python process them lazily.
This avoids the need to express some annotations as strings.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20251008063546.376603-4-pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
scripts/tracetool.py | 2 ++
scripts/tracetool/__init__.py | 2 ++
scripts/tracetool/backend/__init__.py | 2 ++
scripts/tracetool/backend/dtrace.py | 2 ++
scripts/tracetool/backend/ftrace.py | 2 ++
scripts/tracetool/backend/log.py | 2 ++
scripts/tracetool/backend/simple.py | 2 ++
scripts/tracetool/backend/syslog.py | 2 ++
scripts/tracetool/backend/ust.py | 2 ++
scripts/tracetool/format/__init__.py | 2 ++
scripts/tracetool/format/c.py | 2 ++
scripts/tracetool/format/d.py | 2 ++
scripts/tracetool/format/h.py | 2 ++
scripts/tracetool/format/log_stap.py | 2 ++
scripts/tracetool/format/rs.py | 2 ++
scripts/tracetool/format/simpletrace_stap.py | 2 ++
scripts/tracetool/format/stap.py | 2 ++
scripts/tracetool/format/ust_events_c.py | 2 ++
scripts/tracetool/format/ust_events_h.py | 2 ++
19 files changed, 38 insertions(+)
diff --git a/scripts/tracetool.py b/scripts/tracetool.py
index 22fdc29e01..390f1a371b 100755
--- a/scripts/tracetool.py
+++ b/scripts/tracetool.py
@@ -4,6 +4,8 @@
Command-line wrapper for the tracetool machinery.
"""
+from __future__ import annotations
+
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
__copyright__ = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index fab98bf67e..0316f3f852 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -4,6 +4,8 @@
Machinery for generating tracing-related intermediate files.
"""
+from __future__ import annotations
+
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
__copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/scripts/tracetool/backend/__init__.py b/scripts/tracetool/backend/__init__.py
index 9109a783c7..8cc9c82138 100644
--- a/scripts/tracetool/backend/__init__.py
+++ b/scripts/tracetool/backend/__init__.py
@@ -49,6 +49,8 @@
"""
+from __future__ import annotations
+
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
__copyright__ = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/scripts/tracetool/backend/dtrace.py b/scripts/tracetool/backend/dtrace.py
index 5f313ddaed..c21a04c653 100644
--- a/scripts/tracetool/backend/dtrace.py
+++ b/scripts/tracetool/backend/dtrace.py
@@ -4,6 +4,8 @@
DTrace/SystemTAP backend.
"""
+from __future__ import annotations
+
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
__copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backend/ftrace.py
index 0d77bd23a5..40bb323f5e 100644
--- a/scripts/tracetool/backend/ftrace.py
+++ b/scripts/tracetool/backend/ftrace.py
@@ -4,6 +4,8 @@
Ftrace built-in backend.
"""
+from __future__ import annotations
+
__author__ = "Eiichi Tsukata <eiichi.tsukata.xh@hitachi.com>"
__copyright__ = "Copyright (C) 2013 Hitachi, Ltd."
__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/log.py
index bbfb56911d..d346a19e40 100644
--- a/scripts/tracetool/backend/log.py
+++ b/scripts/tracetool/backend/log.py
@@ -4,6 +4,8 @@
Stderr built-in backend.
"""
+from __future__ import annotations
+
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
__copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backend/simple.py
index b67257ce7e..9c691dc231 100644
--- a/scripts/tracetool/backend/simple.py
+++ b/scripts/tracetool/backend/simple.py
@@ -4,6 +4,8 @@
Simple built-in backend.
"""
+from __future__ import annotations
+
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
__copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/scripts/tracetool/backend/syslog.py b/scripts/tracetool/backend/syslog.py
index c3efab036c..9311453c5a 100644
--- a/scripts/tracetool/backend/syslog.py
+++ b/scripts/tracetool/backend/syslog.py
@@ -4,6 +4,8 @@
Syslog built-in backend.
"""
+from __future__ import annotations
+
__author__ = "Paul Durrant <paul.durrant@citrix.com>"
__copyright__ = "Copyright 2016, Citrix Systems Inc."
__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/scripts/tracetool/backend/ust.py b/scripts/tracetool/backend/ust.py
index a70e3d83e1..f227072512 100644
--- a/scripts/tracetool/backend/ust.py
+++ b/scripts/tracetool/backend/ust.py
@@ -4,6 +4,8 @@
LTTng User Space Tracing backend.
"""
+from __future__ import annotations
+
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
__copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/scripts/tracetool/format/__init__.py b/scripts/tracetool/format/__init__.py
index 7b9d1b5782..4c606d5757 100644
--- a/scripts/tracetool/format/__init__.py
+++ b/scripts/tracetool/format/__init__.py
@@ -27,6 +27,8 @@
"""
+from __future__ import annotations
+
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
__copyright__ = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/scripts/tracetool/format/c.py b/scripts/tracetool/format/c.py
index 50e03313cb..5b3459f2be 100644
--- a/scripts/tracetool/format/c.py
+++ b/scripts/tracetool/format/c.py
@@ -4,6 +4,8 @@
trace/generated-tracers.c
"""
+from __future__ import annotations
+
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
__copyright__ = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/scripts/tracetool/format/d.py b/scripts/tracetool/format/d.py
index 0befd444e8..dda80eeb76 100644
--- a/scripts/tracetool/format/d.py
+++ b/scripts/tracetool/format/d.py
@@ -4,6 +4,8 @@
trace/generated-tracers.dtrace (DTrace only).
"""
+from __future__ import annotations
+
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
__copyright__ = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py
index dd58713a15..d04cabc63e 100644
--- a/scripts/tracetool/format/h.py
+++ b/scripts/tracetool/format/h.py
@@ -4,6 +4,8 @@
trace/generated-tracers.h
"""
+from __future__ import annotations
+
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
__copyright__ = "Copyright 2012-2017, Lluís Vilanova <vilanova@ac.upc.edu>"
__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/scripts/tracetool/format/log_stap.py b/scripts/tracetool/format/log_stap.py
index 99c6181f38..6551444203 100644
--- a/scripts/tracetool/format/log_stap.py
+++ b/scripts/tracetool/format/log_stap.py
@@ -4,6 +4,8 @@
Generate .stp file that printfs log messages (DTrace with SystemTAP only).
"""
+from __future__ import annotations
+
__author__ = "Daniel P. Berrange <berrange@redhat.com>"
__copyright__ = "Copyright (C) 2014-2019, Red Hat, Inc."
__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/scripts/tracetool/format/rs.py b/scripts/tracetool/format/rs.py
index 7d9af7edfe..1dc43a3b34 100644
--- a/scripts/tracetool/format/rs.py
+++ b/scripts/tracetool/format/rs.py
@@ -4,6 +4,8 @@
trace-DIR.rs
"""
+from __future__ import annotations
+
__author__ = "Tanish Desai <tanishdesai37@gmail.com>"
__copyright__ = "Copyright 2025, Tanish Desai <tanishdesai37@gmail.com>"
__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/scripts/tracetool/format/simpletrace_stap.py b/scripts/tracetool/format/simpletrace_stap.py
index c7bde97a85..eb58b4b959 100644
--- a/scripts/tracetool/format/simpletrace_stap.py
+++ b/scripts/tracetool/format/simpletrace_stap.py
@@ -4,6 +4,8 @@
Generate .stp file that outputs simpletrace binary traces (DTrace with SystemTAP only).
"""
+from __future__ import annotations
+
__author__ = "Stefan Hajnoczi <redhat.com>"
__copyright__ = "Copyright (C) 2014, Red Hat, Inc."
__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/scripts/tracetool/format/stap.py b/scripts/tracetool/format/stap.py
index f917bd7545..808fb478b5 100644
--- a/scripts/tracetool/format/stap.py
+++ b/scripts/tracetool/format/stap.py
@@ -4,6 +4,8 @@
Generate .stp file (DTrace with SystemTAP only).
"""
+from __future__ import annotations
+
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
__copyright__ = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/scripts/tracetool/format/ust_events_c.py b/scripts/tracetool/format/ust_events_c.py
index 074226bfd3..fa7d543798 100644
--- a/scripts/tracetool/format/ust_events_c.py
+++ b/scripts/tracetool/format/ust_events_c.py
@@ -4,6 +4,8 @@
trace/generated-ust.c
"""
+from __future__ import annotations
+
__author__ = "Mohamad Gebai <mohamad.gebai@polymtl.ca>"
__copyright__ = "Copyright 2012, Mohamad Gebai <mohamad.gebai@polymtl.ca>"
__license__ = "GPL version 2 or (at your option) any later version"
diff --git a/scripts/tracetool/format/ust_events_h.py b/scripts/tracetool/format/ust_events_h.py
index cee7970a40..1057d02577 100644
--- a/scripts/tracetool/format/ust_events_h.py
+++ b/scripts/tracetool/format/ust_events_h.py
@@ -4,6 +4,8 @@
trace/generated-ust-provider.h
"""
+from __future__ import annotations
+
__author__ = "Mohamad Gebai <mohamad.gebai@polymtl.ca>"
__copyright__ = "Copyright 2012, Mohamad Gebai <mohamad.gebai@polymtl.ca>"
__license__ = "GPL version 2 or (at your option) any later version"
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PULL 4/8] tracetool: add type annotations
2026-01-19 19:08 [PULL 0/8] Tracing patches Stefan Hajnoczi
` (2 preceding siblings ...)
2026-01-19 19:08 ` [PULL 3/8] tracetool: "import annotations" Stefan Hajnoczi
@ 2026-01-19 19:08 ` Stefan Hajnoczi
2026-01-19 19:08 ` [PULL 5/8] tracetool: complete typing annotations Stefan Hajnoczi
` (4 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Stefan Hajnoczi @ 2026-01-19 19:08 UTC (permalink / raw)
To: qemu-devel
Cc: Cleber Rosa, Stefan Hajnoczi, Mads Ynddal, Richard Henderson,
John Snow, Paolo Bonzini
From: Paolo Bonzini <pbonzini@redhat.com>
Created with a profiling-based tool, righttyper. I used this script:
python -m righttyper --generate-stubs --no-sampling --overwrite -- ./tracetool.py --help
find . -name "*.pyi" | while read fname; do
merge-pyi --in-place -b bak.$fmt ${fname%i} $fname
done
for fmt in c h rs d log-stap simpletrace-stap stap ust-events-c ust-events-h; do
find . -name '*.pyi*' | xargs rm
python -m righttyper --generate-stubs --no-sampling --overwrite ./tracetool.py \
--format=$fmt --backends=ust,simple,syslog,ftrace,dtrace,log --group=testsuite \
--binary=qemu --probe-prefix=qemu ../tests/tracetool/trace-events outfile.$fmt
find . -name "*.pyi" | while read fname; do
merge-pyi --in-place -b bak.$fmt ${fname%i} $fname
done
done
python -m isort $(find tracetool -name "*.py")
Running the script took about 5 minutes. The errors were mostly
due to misunderstanding the "try_import" function:
tracetool/backend/__init__.py:83: error: Incompatible types in assignment (expression has type Module, variable has type "tuple[bool, Module]") [assignment]
tracetool/backend/__init__.py:117: error: Incompatible types in assignment (expression has type Module, variable has type "str") [assignment]
tracetool/__init__.py:543: error: Incompatible return value type (got "tuple[bool, None]", expected "tuple[bool, Module]") [return-value]
tracetool/format/__init__.py:60: error: Incompatible types in assignment (expression has type Module, variable has type "tuple[bool, Module]") [assignment]
tracetool/format/__init__.py:85: error: Argument 2 to "try_import" has incompatible type "str"; expected "None" [arg-type]
tracetool/format/__init__.py:88: error: Module not callable [operator]
On top of this I fixed a little weirdness, while leaving the unannotated
functions unchanged. Being profiling-based, righttyper did not annotate
anything not covered by the check-tracetool testsuite:
- error cases
- PRIxxx macros
It also reported list[Never] for always-empty lists, which is incorrect.
Righttyper also has a few limitations: it does not annotate nested functions
(there were only four of them), or "*args" argument lists. These are fixed
in the next patch.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20251008063546.376603-5-pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
scripts/tracetool.py | 5 +-
scripts/tracetool/__init__.py | 54 ++++++++++----------
scripts/tracetool/backend/__init__.py | 19 +++----
scripts/tracetool/backend/dtrace.py | 16 +++---
scripts/tracetool/backend/ftrace.py | 10 ++--
scripts/tracetool/backend/log.py | 10 ++--
scripts/tracetool/backend/simple.py | 16 +++---
scripts/tracetool/backend/syslog.py | 10 ++--
scripts/tracetool/backend/ust.py | 8 +--
scripts/tracetool/format/__init__.py | 7 +--
scripts/tracetool/format/c.py | 5 +-
scripts/tracetool/format/d.py | 5 +-
scripts/tracetool/format/h.py | 5 +-
scripts/tracetool/format/log_stap.py | 7 +--
scripts/tracetool/format/rs.py | 5 +-
scripts/tracetool/format/simpletrace_stap.py | 5 +-
scripts/tracetool/format/stap.py | 7 +--
scripts/tracetool/format/ust_events_c.py | 5 +-
scripts/tracetool/format/ust_events_h.py | 5 +-
19 files changed, 109 insertions(+), 95 deletions(-)
diff --git a/scripts/tracetool.py b/scripts/tracetool.py
index 390f1a371b..0688c9cf5f 100755
--- a/scripts/tracetool.py
+++ b/scripts/tracetool.py
@@ -16,6 +16,7 @@
import getopt
import sys
+from typing import NoReturn
import tracetool.backend
import tracetool.format
@@ -23,7 +24,7 @@
_SCRIPT = ""
-def error_opt(msg = None):
+def error_opt(msg: str | None = None) -> NoReturn:
if msg is not None:
error_write("Error: " + msg + "\n")
@@ -58,7 +59,7 @@ def error_opt(msg = None):
else:
sys.exit(1)
-def main(args):
+def main(args: list[str]) -> None:
global _SCRIPT
_SCRIPT = args[0]
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index 0316f3f852..f2692de477 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -17,13 +17,15 @@
import os
import re
import sys
+from io import TextIOWrapper
from pathlib import PurePath
+from typing import Any, Iterator
import tracetool.backend
import tracetool.format
-def error_write(*lines):
+def error_write(*lines) -> None:
"""Write a set of error lines."""
sys.stderr.writelines("\n".join(lines) + "\n")
@@ -48,7 +50,7 @@ def error(*lines):
'MAX': 'j',
}
-def expand_format_string(c_fmt, prefix=""):
+def expand_format_string(c_fmt: str, prefix: str="") -> str:
def pri_macro_to_fmt(pri_macro):
assert pri_macro.startswith("PRI")
fmt_type = pri_macro[3] # 'd', 'i', 'u', or 'x'
@@ -80,12 +82,12 @@ def pri_macro_to_fmt(pri_macro):
out_filename = '<none>'
out_fobj = sys.stdout
-def out_open(filename):
+def out_open(filename: str) -> None:
global out_filename, out_fobj
out_filename = posix_relpath(filename)
out_fobj = open(filename, 'wt')
-def out(*lines, **kwargs):
+def out(*lines, **kwargs) -> None:
"""Write a set of output lines.
You can use kwargs as a shorthand for mapping variables when formatting all
@@ -177,7 +179,7 @@ def out(*lines, **kwargs):
"bool",
}
-def validate_type(name):
+def validate_type(name: str) -> None:
bits = name.split(" ")
for bit in bits:
bit = re.sub(r"\*", "", bit)
@@ -192,7 +194,7 @@ def validate_type(name):
"other complex pointer types should be "
"declared as 'void *'" % name)
-def c_type_to_rust(name):
+def c_type_to_rust(name: str) -> str:
ptr = False
const = False
name = name.rstrip()
@@ -227,7 +229,7 @@ def c_type_to_rust(name):
class Arguments:
"""Event arguments description."""
- def __init__(self, args):
+ def __init__(self, args: list[tuple[str, str]]) -> None:
"""
Parameters
----------
@@ -242,7 +244,7 @@ def __init__(self, args):
self._args.append(arg)
@staticmethod
- def build(arg_str):
+ def build(arg_str: str) -> Arguments:
"""Build and Arguments instance from an argument string.
Parameters
@@ -275,15 +277,15 @@ def __getitem__(self, index):
else:
return self._args[index]
- def __iter__(self):
+ def __iter__(self) -> Iterator[tuple[str, str]]:
"""Iterate over the (type, name) pairs."""
return iter(self._args)
- def __len__(self):
+ def __len__(self) -> int:
"""Number of arguments."""
return len(self._args)
- def __str__(self):
+ def __str__(self) -> str:
"""String suitable for declaring function arguments."""
def onearg(t, n):
if t[-1] == '*':
@@ -300,11 +302,11 @@ def __repr__(self):
"""Evaluable string representation for this object."""
return "Arguments(\"%s\")" % str(self)
- def names(self):
+ def names(self) -> list[str]:
"""List of argument names."""
return [ name for _, name in self._args ]
- def types(self):
+ def types(self) -> list[str]:
"""List of argument types."""
return [ type_ for type_, _ in self._args ]
@@ -312,12 +314,12 @@ def casted(self):
"""List of argument names casted to their type."""
return ["(%s)%s" % (type_, name) for type_, name in self._args]
- def rust_decl_extern(self):
+ def rust_decl_extern(self) -> str:
"""Return a Rust argument list for an extern "C" function"""
return ", ".join((f"_{name}: {c_type_to_rust(type_)}"
for type_, name in self._args))
- def rust_decl(self):
+ def rust_decl(self) -> str:
"""Return a Rust argument list for a tracepoint function"""
def decl_type(type_):
if type_ == "const char *":
@@ -327,7 +329,7 @@ def decl_type(type_):
return ", ".join((f"_{name}: {decl_type(type_)}"
for type_, name in self._args))
- def rust_call_extern(self):
+ def rust_call_extern(self) -> str:
"""Return a Rust argument list for a call to an extern "C" function"""
def rust_cast(name, type_):
if type_ == "const char *":
@@ -336,7 +338,7 @@ def rust_cast(name, type_):
return ", ".join((rust_cast(name, type_) for type_, name in self._args))
- def rust_call_varargs(self):
+ def rust_call_varargs(self) -> str:
"""Return a Rust argument list for a call to a C varargs function"""
def rust_cast(name, type_):
if type_ == "const char *":
@@ -379,7 +381,7 @@ class Event(object):
_VALID_PROPS = set(["disable"])
- def __init__(self, name, props, fmt, args, lineno, filename):
+ def __init__(self, name: str, props: list[str], fmt: str, args: Arguments, lineno: int, filename: str) -> None:
"""
Parameters
----------
@@ -415,7 +417,7 @@ def __init__(self, name, props, fmt, args, lineno, filename):
@staticmethod
- def build(line_str, lineno, filename):
+ def build(line_str: str, lineno: int, filename: str) -> Event:
"""Build an Event instance from a string.
Parameters
@@ -457,7 +459,7 @@ def __repr__(self):
# arguments with that format, hence the non-greedy version of it.
_FMT = re.compile(r"(%[\d\.]*\w+|%.*?PRI\S+)")
- def formats(self):
+ def formats(self) -> list[str]:
"""List conversion specifiers in the argument print format string."""
return self._FMT.findall(self.fmt)
@@ -468,13 +470,13 @@ def formats(self):
QEMU_BACKEND_DSTATE = "TRACE_%(NAME)s_BACKEND_DSTATE"
QEMU_EVENT = "_TRACE_%(NAME)s_EVENT"
- def api(self, fmt=None):
+ def api(self, fmt: str|None=None) -> str:
if fmt is None:
fmt = Event.QEMU_TRACE
return fmt % {"name": self.name, "NAME": self.name.upper()}
-def read_events(fobj, fname):
+def read_events(fobj: TextIOWrapper, fname: str) -> list[Event]:
"""Generate the output for the given (format, backends) pair.
Parameters
@@ -513,7 +515,7 @@ class TracetoolError (Exception):
pass
-def try_import(mod_name, attr_name=None, attr_default=None):
+def try_import(mod_name: str, attr_name: str | None=None, attr_default: Any=None) -> tuple[bool, Any]:
"""Try to import a module and get an attribute from it.
Parameters
@@ -539,8 +541,8 @@ def try_import(mod_name, attr_name=None, attr_default=None):
return False, None
-def generate(events, group, format, backends,
- binary=None, probe_prefix=None):
+def generate(events: list[Event], group: str, format: str, backends: list[str],
+ binary: str|None=None, probe_prefix: str|None=None) -> None:
"""Generate the output for the given (format, backends) pair.
Parameters
@@ -580,7 +582,7 @@ def generate(events, group, format, backends,
tracetool.format.generate(events, format, backend, group)
-def posix_relpath(path, start=None):
+def posix_relpath(path: str, start: str|None=None) -> str:
try:
path = os.path.relpath(path, start)
except ValueError:
diff --git a/scripts/tracetool/backend/__init__.py b/scripts/tracetool/backend/__init__.py
index 8cc9c82138..645e78ece0 100644
--- a/scripts/tracetool/backend/__init__.py
+++ b/scripts/tracetool/backend/__init__.py
@@ -60,11 +60,12 @@
import os
+from typing import Any, Iterator
import tracetool
-def get_list(only_public = False):
+def get_list(only_public: bool = False) -> list[tuple[str, str]]:
"""Get a list of (name, description) pairs."""
res = [("nop", "Tracing disabled.")]
modnames = []
@@ -93,7 +94,7 @@ def get_list(only_public = False):
return res
-def exists(name):
+def exists(name: str) -> bool:
"""Return whether the given backend exists."""
if len(name) == 0:
return False
@@ -104,7 +105,7 @@ def exists(name):
class Wrapper:
- def __init__(self, backends, format):
+ def __init__(self, backends: list[str], format: str) -> None:
self._backends = [backend.replace("-", "_") for backend in backends]
self._format = format.replace("-", "_")
self.check_trace_event_get_state = False
@@ -115,13 +116,13 @@ def __init__(self, backends, format):
check_trace_event_get_state = getattr(backend, "CHECK_TRACE_EVENT_GET_STATE", False)
self.check_trace_event_get_state = self.check_trace_event_get_state or check_trace_event_get_state
- def backend_modules(self):
+ def backend_modules(self) -> Iterator[Any]:
for backend in self._backends:
module = tracetool.try_import("tracetool.backend." + backend)[1]
if module is not None:
yield module
- def _run_function(self, name, *args, check_trace_event_get_state=None, **kwargs):
+ def _run_function(self, name: str, *args, check_trace_event_get_state: bool | None=None, **kwargs) -> None:
for backend in self.backend_modules():
func = getattr(backend, name % self._format, None)
if func is not None and \
@@ -129,14 +130,14 @@ def _run_function(self, name, *args, check_trace_event_get_state=None, **kwargs)
check_trace_event_get_state == getattr(backend, 'CHECK_TRACE_EVENT_GET_STATE', False)):
func(*args, **kwargs)
- def generate_begin(self, events, group):
+ def generate_begin(self, events: list[tracetool.Event], group: str) -> None:
self._run_function("generate_%s_begin", events, group)
- def generate(self, event, group, check_trace_event_get_state=None):
+ def generate(self, event: tracetool.Event, group: str, check_trace_event_get_state: bool | None=None) -> None:
self._run_function("generate_%s", event, group, check_trace_event_get_state=check_trace_event_get_state)
- def generate_backend_dstate(self, event, group):
+ def generate_backend_dstate(self, event: tracetool.Event, group: str) -> None:
self._run_function("generate_%s_backend_dstate", event, group)
- def generate_end(self, events, group):
+ def generate_end(self, events: list[tracetool.Event], group: str) -> None:
self._run_function("generate_%s_end", events, group)
diff --git a/scripts/tracetool/backend/dtrace.py b/scripts/tracetool/backend/dtrace.py
index c21a04c653..2ad607c551 100644
--- a/scripts/tracetool/backend/dtrace.py
+++ b/scripts/tracetool/backend/dtrace.py
@@ -14,28 +14,28 @@
__email__ = "stefanha@redhat.com"
-from tracetool import out
+from tracetool import Event, out
PUBLIC = True
-PROBEPREFIX = None
+PROBEPREFIX: str|None = None
-def probeprefix():
+def probeprefix() -> str:
if PROBEPREFIX is None:
raise ValueError("you must set PROBEPREFIX")
return PROBEPREFIX
-BINARY = None
+BINARY: str|None = None
-def binary():
+def binary() -> str:
if BINARY is None:
raise ValueError("you must set BINARY")
return BINARY
-def generate_h_begin(events, group):
+def generate_h_begin(events: list[Event], group: str) -> None:
if group == "root":
header = "trace-dtrace-root.h"
else:
@@ -62,13 +62,13 @@ def generate_h_begin(events, group):
'#endif',
uppername=e.name.upper())
-def generate_h(event, group):
+def generate_h(event: Event, group: str) -> None:
out(' QEMU_%(uppername)s(%(argnames)s);',
uppername=event.name.upper(),
argnames=", ".join(event.args.names()))
-def generate_h_backend_dstate(event, group):
+def generate_h_backend_dstate(event: Event, group: str) -> None:
out(' QEMU_%(uppername)s_ENABLED() || \\',
uppername=event.name.upper())
diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backend/ftrace.py
index 40bb323f5e..fa4a40d44a 100644
--- a/scripts/tracetool/backend/ftrace.py
+++ b/scripts/tracetool/backend/ftrace.py
@@ -14,18 +14,18 @@
__email__ = "stefanha@redhat.com"
-from tracetool import expand_format_string, out
+from tracetool import Event, expand_format_string, out
PUBLIC = True
CHECK_TRACE_EVENT_GET_STATE = True
-def generate_h_begin(events, group):
+def generate_h_begin(events: list[Event], group: str) -> None:
out('#include "trace/ftrace.h"',
'')
-def generate_h(event, group):
+def generate_h(event: Event, group: str) -> None:
argnames = ", ".join(event.args.names())
if len(event.args) > 0:
argnames = ", " + argnames
@@ -41,11 +41,11 @@ def generate_h(event, group):
argnames=argnames)
-def generate_h_backend_dstate(event, group):
+def generate_h_backend_dstate(event: Event, group: str) -> None:
out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\',
event_id="TRACE_" + event.name.upper())
-def generate_rs(event, group):
+def generate_rs(event: Event, group: str) -> None:
out(' let format_string = c"%(fmt)s";',
' unsafe {bindings::ftrace_write(format_string.as_ptr() as *const c_char, %(args)s);}',
fmt=expand_format_string(event.fmt),
diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/log.py
index d346a19e40..39d777218b 100644
--- a/scripts/tracetool/backend/log.py
+++ b/scripts/tracetool/backend/log.py
@@ -14,18 +14,18 @@
__email__ = "stefanha@redhat.com"
-from tracetool import expand_format_string, out
+from tracetool import Event, expand_format_string, out
PUBLIC = True
CHECK_TRACE_EVENT_GET_STATE = True
-def generate_h_begin(events, group):
+def generate_h_begin(events: list[Event], group: str) -> None:
out('#include "qemu/log-for-trace.h"',
'')
-def generate_h(event, group):
+def generate_h(event: Event, group: str) -> None:
argnames = ", ".join(event.args.names())
if len(event.args) > 0:
argnames = ", " + argnames
@@ -42,11 +42,11 @@ def generate_h(event, group):
argnames=argnames)
-def generate_h_backend_dstate(event, group):
+def generate_h_backend_dstate(event: Event, group: str) -> None:
out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\',
event_id="TRACE_" + event.name.upper())
-def generate_rs(event, group):
+def generate_rs(event: Event, group: str) -> None:
out(' let format_string = c"%(fmt)s\\n";',
' if (unsafe { bindings::qemu_loglevel } & bindings::LOG_TRACE) != 0 {',
' unsafe { bindings::qemu_log(format_string.as_ptr() as *const c_char, %(args)s);}',
diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backend/simple.py
index 9c691dc231..519f7a09e5 100644
--- a/scripts/tracetool/backend/simple.py
+++ b/scripts/tracetool/backend/simple.py
@@ -14,13 +14,13 @@
__email__ = "stefanha@redhat.com"
-from tracetool import out
+from tracetool import Event, out
PUBLIC = True
CHECK_TRACE_EVENT_GET_STATE = True
-def is_string(arg):
+def is_string(arg: str) -> bool:
strtype = ('const char*', 'char*', 'const char *', 'char *')
arg_strip = arg.lstrip()
if arg_strip.startswith(strtype) and arg_strip.count('*') == 1:
@@ -29,7 +29,7 @@ def is_string(arg):
return False
-def generate_h_begin(events, group):
+def generate_h_begin(events: list[Event], group: str) -> None:
for event in events:
out('void _simple_%(api)s(%(args)s);',
api=event.api(),
@@ -37,25 +37,25 @@ def generate_h_begin(events, group):
out('')
-def generate_h(event, group):
+def generate_h(event: Event, group: str) -> None:
out(' _simple_%(api)s(%(args)s);',
api=event.api(),
args=", ".join(event.args.names()))
-def generate_h_backend_dstate(event, group):
+def generate_h_backend_dstate(event: Event, group: str) -> None:
out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\',
event_id="TRACE_" + event.name.upper())
-def generate_c_begin(events, group):
+def generate_c_begin(events: list[Event], group: str) -> None:
out('#include "qemu/osdep.h"',
'#include "trace/control.h"',
'#include "trace/simple.h"',
'')
-def generate_c(event, group):
+def generate_c(event: Event, group: str) -> None:
out('void _simple_%(api)s(%(args)s)',
'{',
' TraceBufferRecord rec;',
@@ -100,7 +100,7 @@ def generate_c(event, group):
'}',
'')
-def generate_rs(event, group):
+def generate_rs(event: Event, group: str) -> None:
out(' extern "C" { fn _simple_%(api)s(%(rust_args)s); }',
' unsafe { _simple_%(api)s(%(args)s); }',
api=event.api(),
diff --git a/scripts/tracetool/backend/syslog.py b/scripts/tracetool/backend/syslog.py
index 9311453c5a..dd39df6af6 100644
--- a/scripts/tracetool/backend/syslog.py
+++ b/scripts/tracetool/backend/syslog.py
@@ -14,18 +14,18 @@
__email__ = "stefanha@redhat.com"
-from tracetool import expand_format_string, out
+from tracetool import Event, expand_format_string, out
PUBLIC = True
CHECK_TRACE_EVENT_GET_STATE = True
-def generate_h_begin(events, group):
+def generate_h_begin(events: list[Event], group: str) -> None:
out('#include <syslog.h>',
'')
-def generate_h(event, group):
+def generate_h(event: Event, group: str) -> None:
argnames = ", ".join(event.args.names())
if len(event.args) > 0:
argnames = ", " + argnames
@@ -39,12 +39,12 @@ def generate_h(event, group):
fmt=event.fmt.rstrip("\n"),
argnames=argnames)
-def generate_rs(event, group):
+def generate_rs(event: Event, group: str) -> None:
out(' let format_string = c"%(fmt)s";',
' unsafe {::trace::syslog(::trace::LOG_INFO, format_string.as_ptr() as *const c_char, %(args)s);}',
fmt=expand_format_string(event.fmt),
args=event.args.rust_call_varargs())
-def generate_h_backend_dstate(event, group):
+def generate_h_backend_dstate(event: Event, group: str) -> None:
out(' trace_event_get_state_dynamic_by_id(%(event_id)s) || \\',
event_id="TRACE_" + event.name.upper())
diff --git a/scripts/tracetool/backend/ust.py b/scripts/tracetool/backend/ust.py
index f227072512..a26cd7ace6 100644
--- a/scripts/tracetool/backend/ust.py
+++ b/scripts/tracetool/backend/ust.py
@@ -14,12 +14,12 @@
__email__ = "stefanha@redhat.com"
-from tracetool import out
+from tracetool import Event, out
PUBLIC = True
-def generate_h_begin(events, group):
+def generate_h_begin(events: list[Event], group: str) -> None:
header = 'trace-ust-' + group + '.h'
out('#include <lttng/tracepoint.h>',
'#include "%s"' % header,
@@ -31,7 +31,7 @@ def generate_h_begin(events, group):
'')
-def generate_h(event, group):
+def generate_h(event: Event, group: str) -> None:
argnames = ", ".join(event.args.names())
if len(event.args) > 0:
argnames = ", " + argnames
@@ -41,6 +41,6 @@ def generate_h(event, group):
tp_args=argnames)
-def generate_h_backend_dstate(event, group):
+def generate_h_backend_dstate(event: Event, group: str) -> None:
out(' tracepoint_enabled(qemu, %(name)s) || \\',
name=event.name)
diff --git a/scripts/tracetool/format/__init__.py b/scripts/tracetool/format/__init__.py
index 4c606d5757..c287e93ed3 100644
--- a/scripts/tracetool/format/__init__.py
+++ b/scripts/tracetool/format/__init__.py
@@ -40,9 +40,10 @@
import os
import tracetool
+from tracetool.backend import Wrapper
-def get_list():
+def get_list() -> list[tuple[str, str]]:
"""Get a list of (name, description) pairs."""
res = []
modnames = []
@@ -67,7 +68,7 @@ def get_list():
return res
-def exists(name):
+def exists(name: str) -> bool:
"""Return whether the given format exists."""
if len(name) == 0:
return False
@@ -75,7 +76,7 @@ def exists(name):
return tracetool.try_import("tracetool.format." + name)[0]
-def generate(events, format, backend, group):
+def generate(events: list[tracetool.Event], format: str, backend: Wrapper, group: str) -> None:
if not exists(format):
raise ValueError("unknown format: %s" % format)
format = format.replace("-", "_")
diff --git a/scripts/tracetool/format/c.py b/scripts/tracetool/format/c.py
index 5b3459f2be..e8848c5105 100644
--- a/scripts/tracetool/format/c.py
+++ b/scripts/tracetool/format/c.py
@@ -14,10 +14,11 @@
__email__ = "stefanha@redhat.com"
-from tracetool import out
+from tracetool import Event, out
+from tracetool.backend import Wrapper
-def generate(events, backend, group):
+def generate(events: list[Event], backend: Wrapper, group: str) -> None:
active_events = [e for e in events
if "disable" not in e.properties]
diff --git a/scripts/tracetool/format/d.py b/scripts/tracetool/format/d.py
index dda80eeb76..2abf8bc24b 100644
--- a/scripts/tracetool/format/d.py
+++ b/scripts/tracetool/format/d.py
@@ -16,7 +16,8 @@
from sys import platform
-from tracetool import out
+from tracetool import Event, out
+from tracetool.backend import Wrapper
# Reserved keywords from
# https://wikis.oracle.com/display/DTrace/Types,+Operators+and+Expressions
@@ -31,7 +32,7 @@
)
-def generate(events, backend, group):
+def generate(events: list[Event], backend: Wrapper, group: str) -> None:
events = [e for e in events
if "disable" not in e.properties]
diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py
index d04cabc63e..2324234dd2 100644
--- a/scripts/tracetool/format/h.py
+++ b/scripts/tracetool/format/h.py
@@ -14,10 +14,11 @@
__email__ = "stefanha@redhat.com"
-from tracetool import out
+from tracetool import Event, out
+from tracetool.backend import Wrapper
-def generate(events, backend, group):
+def generate(events: list[Event], backend: Wrapper, group: str) -> None:
header = "trace/control.h"
out('/* This file is autogenerated by tracetool, do not edit. */',
diff --git a/scripts/tracetool/format/log_stap.py b/scripts/tracetool/format/log_stap.py
index 6551444203..d7ad0bb6a7 100644
--- a/scripts/tracetool/format/log_stap.py
+++ b/scripts/tracetool/format/log_stap.py
@@ -15,7 +15,8 @@
import re
-from tracetool import out
+from tracetool import Event, out
+from tracetool.backend import Wrapper
from tracetool.backend.dtrace import binary, probeprefix
from tracetool.backend.simple import is_string
from tracetool.format.stap import stap_escape
@@ -30,7 +31,7 @@ def c_macro_to_format(macro):
raise Exception("Unhandled macro '%s'" % macro)
-def c_fmt_to_stap(fmt):
+def c_fmt_to_stap(fmt: str) -> str:
state = 0
bits = []
literal = ""
@@ -85,7 +86,7 @@ def c_fmt_to_stap(fmt):
fmt = re.sub(r"%(\d*)(l+|z)(x|u|d)", r"%\1\3", "".join(bits))
return fmt
-def generate(events, backend, group):
+def generate(events: list[Event], backend: Wrapper, group: str) -> None:
out('/* This file is autogenerated by tracetool, do not edit. */',
'/* SPDX-License-Identifier: GPL-2.0-or-later */',
'')
diff --git a/scripts/tracetool/format/rs.py b/scripts/tracetool/format/rs.py
index 1dc43a3b34..41e4636d97 100644
--- a/scripts/tracetool/format/rs.py
+++ b/scripts/tracetool/format/rs.py
@@ -14,10 +14,11 @@
__email__ = "stefanha@redhat.com"
-from tracetool import out
+from tracetool import Event, out
+from tracetool.backend import Wrapper
-def generate(events, backend, group):
+def generate(events: list[Event], backend: Wrapper, group: str) -> None:
out('// SPDX-License-Identifier: GPL-2.0-or-later',
'// This file is @generated by tracetool, do not edit.',
'',
diff --git a/scripts/tracetool/format/simpletrace_stap.py b/scripts/tracetool/format/simpletrace_stap.py
index eb58b4b959..c76cf42685 100644
--- a/scripts/tracetool/format/simpletrace_stap.py
+++ b/scripts/tracetool/format/simpletrace_stap.py
@@ -14,13 +14,14 @@
__email__ = "stefanha@redhat.com"
-from tracetool import out
+from tracetool import Event, out
+from tracetool.backend import Wrapper
from tracetool.backend.dtrace import probeprefix
from tracetool.backend.simple import is_string
from tracetool.format.stap import stap_escape
-def generate(events, backend, group):
+def generate(events: list[Event], backend: Wrapper, group: str) -> None:
out('/* This file is autogenerated by tracetool, do not edit. */',
'/* SPDX-License-Identifier: GPL-2.0-or-later */',
'')
diff --git a/scripts/tracetool/format/stap.py b/scripts/tracetool/format/stap.py
index 808fb478b5..af98f3c44a 100644
--- a/scripts/tracetool/format/stap.py
+++ b/scripts/tracetool/format/stap.py
@@ -14,7 +14,8 @@
__email__ = "stefanha@redhat.com"
-from tracetool import out
+from tracetool import Event, out
+from tracetool.backend import Wrapper
from tracetool.backend.dtrace import binary, probeprefix
# Technically 'self' is not used by systemtap yet, but
@@ -27,14 +28,14 @@
)
-def stap_escape(identifier):
+def stap_escape(identifier: str) -> str:
# Append underscore to reserved keywords
if identifier in RESERVED_WORDS:
return identifier + '_'
return identifier
-def generate(events, backend, group):
+def generate(events: list[Event], backend: Wrapper, group: str) -> None:
events = [e for e in events
if "disable" not in e.properties]
diff --git a/scripts/tracetool/format/ust_events_c.py b/scripts/tracetool/format/ust_events_c.py
index fa7d543798..2c8256ed7a 100644
--- a/scripts/tracetool/format/ust_events_c.py
+++ b/scripts/tracetool/format/ust_events_c.py
@@ -14,10 +14,11 @@
__email__ = "stefanha@redhat.com"
-from tracetool import out
+from tracetool import Event, out
+from tracetool.backend import Wrapper
-def generate(events, backend, group):
+def generate(events: list[Event], backend: Wrapper, group: str) -> None:
events = [e for e in events
if "disabled" not in e.properties]
diff --git a/scripts/tracetool/format/ust_events_h.py b/scripts/tracetool/format/ust_events_h.py
index 1057d02577..f0ffcae694 100644
--- a/scripts/tracetool/format/ust_events_h.py
+++ b/scripts/tracetool/format/ust_events_h.py
@@ -14,10 +14,11 @@
__email__ = "stefanha@redhat.com"
-from tracetool import out
+from tracetool import Event, out
+from tracetool.backend import Wrapper
-def generate(events, backend, group):
+def generate(events: list[Event], backend: Wrapper, group: str) -> None:
events = [e for e in events
if "disabled" not in e.properties]
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PULL 5/8] tracetool: complete typing annotations
2026-01-19 19:08 [PULL 0/8] Tracing patches Stefan Hajnoczi
` (3 preceding siblings ...)
2026-01-19 19:08 ` [PULL 4/8] tracetool: add type annotations Stefan Hajnoczi
@ 2026-01-19 19:08 ` Stefan Hajnoczi
2026-01-19 19:08 ` [PULL 6/8] tracetool: add typing checks to "make -C python check" Stefan Hajnoczi
` (3 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Stefan Hajnoczi @ 2026-01-19 19:08 UTC (permalink / raw)
To: qemu-devel
Cc: Cleber Rosa, Stefan Hajnoczi, Mads Ynddal, Richard Henderson,
John Snow, Paolo Bonzini
From: Paolo Bonzini <pbonzini@redhat.com>
Add more annotations so that "mypy --strict". These have to be done
manually due to limitations of RightTyper.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20251008063546.376603-6-pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
scripts/tracetool/__init__.py | 30 +++++++++++++--------------
scripts/tracetool/backend/__init__.py | 2 +-
scripts/tracetool/format/log_stap.py | 2 +-
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/scripts/tracetool/__init__.py b/scripts/tracetool/__init__.py
index f2692de477..e191201819 100644
--- a/scripts/tracetool/__init__.py
+++ b/scripts/tracetool/__init__.py
@@ -19,17 +19,17 @@
import sys
from io import TextIOWrapper
from pathlib import PurePath
-from typing import Any, Iterator
+from typing import Any, Iterator, Sequence
import tracetool.backend
import tracetool.format
-def error_write(*lines) -> None:
+def error_write(*lines: str) -> None:
"""Write a set of error lines."""
sys.stderr.writelines("\n".join(lines) + "\n")
-def error(*lines):
+def error(*lines: str) -> None:
"""Write a set of error lines and exit."""
error_write(*lines)
sys.exit(1)
@@ -51,7 +51,7 @@ def error(*lines):
}
def expand_format_string(c_fmt: str, prefix: str="") -> str:
- def pri_macro_to_fmt(pri_macro):
+ def pri_macro_to_fmt(pri_macro: str) -> str:
assert pri_macro.startswith("PRI")
fmt_type = pri_macro[3] # 'd', 'i', 'u', or 'x'
fmt_size = pri_macro[4:] # '8', '16', '32', '64', 'PTR', 'MAX'
@@ -87,7 +87,7 @@ def out_open(filename: str) -> None:
out_filename = posix_relpath(filename)
out_fobj = open(filename, 'wt')
-def out(*lines, **kwargs) -> None:
+def out(*lines: str, **kwargs: Any) -> None:
"""Write a set of output lines.
You can use kwargs as a shorthand for mapping variables when formatting all
@@ -229,14 +229,14 @@ def c_type_to_rust(name: str) -> str:
class Arguments:
"""Event arguments description."""
- def __init__(self, args: list[tuple[str, str]]) -> None:
+ def __init__(self, args: Sequence[tuple[str, str] | Arguments]) -> None:
"""
Parameters
----------
args :
List of (type, name) tuples or Arguments objects.
"""
- self._args = []
+ self._args: list[tuple[str, str]] = []
for arg in args:
if isinstance(arg, Arguments):
self._args.extend(arg._args)
@@ -271,7 +271,7 @@ def build(arg_str: str) -> Arguments:
res.append((arg_type, identifier))
return Arguments(res)
- def __getitem__(self, index):
+ def __getitem__(self, index: int | slice) -> Arguments | tuple[str, str]:
if isinstance(index, slice):
return Arguments(self._args[index])
else:
@@ -287,7 +287,7 @@ def __len__(self) -> int:
def __str__(self) -> str:
"""String suitable for declaring function arguments."""
- def onearg(t, n):
+ def onearg(t: str, n: str) -> str:
if t[-1] == '*':
return "".join([t, n])
else:
@@ -298,7 +298,7 @@ def onearg(t, n):
else:
return ", ".join([ onearg(t, n) for t,n in self._args ])
- def __repr__(self):
+ def __repr__(self) -> str:
"""Evaluable string representation for this object."""
return "Arguments(\"%s\")" % str(self)
@@ -310,7 +310,7 @@ def types(self) -> list[str]:
"""List of argument types."""
return [ type_ for type_, _ in self._args ]
- def casted(self):
+ def casted(self) -> list[str]:
"""List of argument names casted to their type."""
return ["(%s)%s" % (type_, name) for type_, name in self._args]
@@ -321,7 +321,7 @@ def rust_decl_extern(self) -> str:
def rust_decl(self) -> str:
"""Return a Rust argument list for a tracepoint function"""
- def decl_type(type_):
+ def decl_type(type_: str) -> str:
if type_ == "const char *":
return "&std::ffi::CStr"
return c_type_to_rust(type_)
@@ -331,7 +331,7 @@ def decl_type(type_):
def rust_call_extern(self) -> str:
"""Return a Rust argument list for a call to an extern "C" function"""
- def rust_cast(name, type_):
+ def rust_cast(name: str, type_: str) -> str:
if type_ == "const char *":
return f"_{name}.as_ptr()"
return f"_{name}"
@@ -340,7 +340,7 @@ def rust_cast(name, type_):
def rust_call_varargs(self) -> str:
"""Return a Rust argument list for a call to a C varargs function"""
- def rust_cast(name, type_):
+ def rust_cast(name: str, type_: str) -> str:
if type_ == "const char *":
return f"_{name}.as_ptr()"
@@ -449,7 +449,7 @@ def build(line_str: str, lineno: int, filename: str) -> Event:
return Event(name, props, fmt, args, lineno, posix_relpath(filename))
- def __repr__(self):
+ def __repr__(self) -> str:
"""Evaluable string representation for this object."""
return "Event('%s %s(%s) %s')" % (" ".join(self.properties),
self.name,
diff --git a/scripts/tracetool/backend/__init__.py b/scripts/tracetool/backend/__init__.py
index 645e78ece0..84bab3f42a 100644
--- a/scripts/tracetool/backend/__init__.py
+++ b/scripts/tracetool/backend/__init__.py
@@ -122,7 +122,7 @@ def backend_modules(self) -> Iterator[Any]:
if module is not None:
yield module
- def _run_function(self, name: str, *args, check_trace_event_get_state: bool | None=None, **kwargs) -> None:
+ def _run_function(self, name: str, *args: Any, check_trace_event_get_state: bool | None=None, **kwargs: Any) -> None:
for backend in self.backend_modules():
func = getattr(backend, name % self._format, None)
if func is not None and \
diff --git a/scripts/tracetool/format/log_stap.py b/scripts/tracetool/format/log_stap.py
index d7ad0bb6a7..914e4674ff 100644
--- a/scripts/tracetool/format/log_stap.py
+++ b/scripts/tracetool/format/log_stap.py
@@ -25,7 +25,7 @@
STATE_LITERAL = 1
STATE_MACRO = 2
-def c_macro_to_format(macro):
+def c_macro_to_format(macro: str) -> str:
if macro.startswith("PRI"):
return macro[3]
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PULL 6/8] tracetool: add typing checks to "make -C python check"
2026-01-19 19:08 [PULL 0/8] Tracing patches Stefan Hajnoczi
` (4 preceding siblings ...)
2026-01-19 19:08 ` [PULL 5/8] tracetool: complete typing annotations Stefan Hajnoczi
@ 2026-01-19 19:08 ` Stefan Hajnoczi
2026-01-19 19:08 ` [PULL 7/8] tracetool-test: add QEMU_TEST_KEEP_SCRATCH=1 support Stefan Hajnoczi
` (2 subsequent siblings)
8 siblings, 0 replies; 12+ messages in thread
From: Stefan Hajnoczi @ 2026-01-19 19:08 UTC (permalink / raw)
To: qemu-devel
Cc: Cleber Rosa, Stefan Hajnoczi, Mads Ynddal, Richard Henderson,
John Snow, Paolo Bonzini, Daniel P. Berrangé
From: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20251008063546.376603-7-pbonzini@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
python/tests/tracetool-mypy.sh | 5 +++++
1 file changed, 5 insertions(+)
create mode 100755 python/tests/tracetool-mypy.sh
diff --git a/python/tests/tracetool-mypy.sh b/python/tests/tracetool-mypy.sh
new file mode 100755
index 0000000000..7b4011e52d
--- /dev/null
+++ b/python/tests/tracetool-mypy.sh
@@ -0,0 +1,5 @@
+#!/bin/sh -e
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+cd ../scripts
+python3 -m mypy --strict tracetool
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PULL 7/8] tracetool-test: add QEMU_TEST_KEEP_SCRATCH=1 support
2026-01-19 19:08 [PULL 0/8] Tracing patches Stefan Hajnoczi
` (5 preceding siblings ...)
2026-01-19 19:08 ` [PULL 6/8] tracetool: add typing checks to "make -C python check" Stefan Hajnoczi
@ 2026-01-19 19:08 ` Stefan Hajnoczi
2026-01-19 19:13 ` Daniel P. Berrangé
2026-01-19 19:08 ` [PULL 8/8] tests/tracetool: Honor the Python interpreter that "configure" detected Stefan Hajnoczi
2026-01-19 20:53 ` [PULL 0/8] Tracing patches Richard Henderson
8 siblings, 1 reply; 12+ messages in thread
From: Stefan Hajnoczi @ 2026-01-19 19:08 UTC (permalink / raw)
To: qemu-devel
Cc: Cleber Rosa, Stefan Hajnoczi, Mads Ynddal, Richard Henderson,
John Snow
It can be useful to preserve the temporary files generated by the test
for manual inspection or diffing against expected output.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-id: 20251118183915.177192-1-stefanha@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
tests/tracetool/tracetool-test.py | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/tests/tracetool/tracetool-test.py b/tests/tracetool/tracetool-test.py
index 30006a9919..10e362a407 100755
--- a/tests/tracetool/tracetool-test.py
+++ b/tests/tracetool/tracetool-test.py
@@ -9,6 +9,9 @@
import tempfile
+DELETE_TEMPFILE = not os.getenv("QEMU_TEST_KEEP_SCRATCH", False)
+
+
def get_formats(backend):
formats = [
"c",
@@ -49,7 +52,8 @@ def test_tracetool_one(tracetool, backend, fmt, src_dir, build_dir):
check_call(args, cwd=build_dir)
actual = actual_file.read_text()
finally:
- actual_file.unlink()
+ if DELETE_TEMPFILE:
+ actual_file.unlink()
if os.getenv("QEMU_TEST_REGENERATE", False):
print(f"# regenerate {expect_file}")
@@ -84,14 +88,25 @@ def test_tracetool(tracetool, backend, source_dir, build_dir):
except Exception as e:
print(f"# {e}")
fail = True
+
+ if DELETE_TEMPFILE:
+ tempfile_hint = (
+ "QEMU_TEST_KEEP_SCRATCH=1 to preserve test output "
+ + "files"
+ )
+ else:
+ tempfile_hint = f"check test output files in {build_dir}"
+
hint = (
" (set QEMU_TEST_REGENERATE=1 to recreate reference "
- + "output if tracetool generator was intentionally changed)"
+ + "output if tracetool generator was intentionally "
+ + "changed or " + tempfile_hint + ")"
)
finally:
print(f"{status} {num} - {backend}.{fmt}{hint}")
finally:
- build_events.unlink()
+ if DELETE_TEMPFILE:
+ build_events.unlink()
return fail
@@ -102,7 +117,8 @@ def test_tracetool(tracetool, backend, source_dir, build_dir):
print("syntax: {argv0} TRACE-TOOL BACKEND SRC-DIR BUILD-DIR", file=sys.stderr)
sys.exit(1)
- with tempfile.TemporaryDirectory(prefix=sys.argv[4]) as tmpdir:
+ with tempfile.TemporaryDirectory(prefix=sys.argv[4],
+ delete=DELETE_TEMPFILE) as tmpdir:
fail = test_tracetool(sys.argv[1], sys.argv[2], sys.argv[3], tmpdir)
if fail:
sys.exit(1)
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PULL 8/8] tests/tracetool: Honor the Python interpreter that "configure" detected
2026-01-19 19:08 [PULL 0/8] Tracing patches Stefan Hajnoczi
` (6 preceding siblings ...)
2026-01-19 19:08 ` [PULL 7/8] tracetool-test: add QEMU_TEST_KEEP_SCRATCH=1 support Stefan Hajnoczi
@ 2026-01-19 19:08 ` Stefan Hajnoczi
2026-01-19 20:53 ` [PULL 0/8] Tracing patches Richard Henderson
8 siblings, 0 replies; 12+ messages in thread
From: Stefan Hajnoczi @ 2026-01-19 19:08 UTC (permalink / raw)
To: qemu-devel
Cc: Cleber Rosa, Stefan Hajnoczi, Mads Ynddal, Richard Henderson,
John Snow, Thomas Huth, Paolo Bonzini, Daniel P. Berrangé
From: Thomas Huth <thuth@redhat.com>
The tracetool tests currently fail if the host installation does not
have a "python3" binary (and you compiled QEMU by selecting a different
one during the "configure" step). This happens because tracetool-test.py
executes scripts/tracetool.py directly, so that this script is run via
its shebang line. To fix the issue, use the same Python interpreter to
run scripts/tracetool.py as we are using to run the tracetool-test.py
script.
Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Message-id: 20260115155318.37823-1-thuth@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
tests/tracetool/tracetool-test.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tests/tracetool/tracetool-test.py b/tests/tracetool/tracetool-test.py
index 10e362a407..b99a0cd6d2 100755
--- a/tests/tracetool/tracetool-test.py
+++ b/tests/tracetool/tracetool-test.py
@@ -39,7 +39,8 @@ def test_tracetool_one(tracetool, backend, fmt, src_dir, build_dir):
actual_file = Path(build_dir, rel_filename)
expect_file = Path(src_dir, rel_filename)
- args = [tracetool, f"--format={fmt}", f"--backends={backend}", "--group=testsuite"]
+ args = [sys.executable, tracetool,
+ f"--format={fmt}", f"--backends={backend}", "--group=testsuite"]
if fmt.find("stap") != -1:
args += ["--binary=qemu", "--probe-prefix=qemu"]
--
2.52.0
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PULL 7/8] tracetool-test: add QEMU_TEST_KEEP_SCRATCH=1 support
2026-01-19 19:08 ` [PULL 7/8] tracetool-test: add QEMU_TEST_KEEP_SCRATCH=1 support Stefan Hajnoczi
@ 2026-01-19 19:13 ` Daniel P. Berrangé
0 siblings, 0 replies; 12+ messages in thread
From: Daniel P. Berrangé @ 2026-01-19 19:13 UTC (permalink / raw)
To: Stefan Hajnoczi
Cc: qemu-devel, Cleber Rosa, Mads Ynddal, Richard Henderson,
John Snow
On Mon, Jan 19, 2026 at 02:08:22PM -0500, Stefan Hajnoczi wrote:
> It can be useful to preserve the temporary files generated by the test
> for manual inspection or diffing against expected output.
>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> Message-id: 20251118183915.177192-1-stefanha@redhat.com
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Double S-o-B and no 3rd party R-b, but have this one...
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
> tests/tracetool/tracetool-test.py | 24 ++++++++++++++++++++----
> 1 file changed, 20 insertions(+), 4 deletions(-)
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PULL 0/8] Tracing patches
2026-01-19 19:08 [PULL 0/8] Tracing patches Stefan Hajnoczi
` (7 preceding siblings ...)
2026-01-19 19:08 ` [PULL 8/8] tests/tracetool: Honor the Python interpreter that "configure" detected Stefan Hajnoczi
@ 2026-01-19 20:53 ` Richard Henderson
2026-01-19 21:00 ` Paolo Bonzini
8 siblings, 1 reply; 12+ messages in thread
From: Richard Henderson @ 2026-01-19 20:53 UTC (permalink / raw)
To: Stefan Hajnoczi, qemu-devel
Cc: Cleber Rosa, Mads Ynddal, Richard Henderson, John Snow
On 1/20/26 06:08, Stefan Hajnoczi wrote:
> The following changes since commit 38879a667fbb4ef54c70de71494882615f600a64:
>
> Merge tag 'pull-tcg-20260119' of https://gitlab.com/rth7680/qemu into staging (2026-01-19 09:04:31 +1100)
>
> are available in the Git repository at:
>
> https://gitlab.com/stefanha/qemu.git tags/tracing-pull-request
>
> for you to fetch changes up to 0527c4fdd28ae8b13ecc34f80b91e42ce42b917f:
>
> tests/tracetool: Honor the Python interpreter that "configure" detected (2026-01-19 13:58:23 -0500)
>
> ----------------------------------------------------------------
> Pull request
>
> - Thomas Huth's Python interpreter fix
> - Paolo Bonzini's tracetool cleanups
> - Stefan Hajnoczi's tracetool test QEMU_TEST_KEEP_SCRATCH=1 support
This has lots of failures:
https://gitlab.com/qemu-project/qemu/-/jobs/12772423978
> Summary of Failures:
> 507/512 tracetool - qemu:dtrace FAIL 0.03s exit status 1
> 508/512 tracetool - qemu:ftrace FAIL 0.04s exit status 1
> 509/512 tracetool - qemu:log FAIL 0.04s exit status 1
> 510/512 tracetool - qemu:simple FAIL 0.04s exit status 1
> 511/512 tracetool - qemu:syslog FAIL 0.04s exit status 1
> 512/512 tracetool - qemu:ust FAIL 0.03s exit status 1
https://gitlab.com/qemu-project/qemu/-/jobs/12772423994
> Log file "stdout" content for test "38-tests/tracetool-isort.sh" (FAIL):
> ERROR: /builds/qemu-project/qemu/scripts/tracetool/__init__.py Imports are incorrectly sorted and/or formatted.
> ERROR: /builds/qemu-project/qemu/scripts/tracetool/backend/__init__.py Imports are incorrectly sorted and/or formatted.
> ERROR: /builds/qemu-project/qemu/scripts/tracetool/backend/dtrace.py Imports are incorrectly sorted and/or formatted.
> ERROR: /builds/qemu-project/qemu/scripts/tracetool/backend/ftrace.py Imports are incorrectly sorted and/or formatted.
> ERROR: /builds/qemu-project/qemu/scripts/tracetool/backend/log.py Imports are incorrectly sorted and/or formatted.
> ERROR: /builds/qemu-project/qemu/scripts/tracetool/backend/simple.py Imports are incorrectly sorted and/or formatted.
> ERROR: /builds/qemu-project/qemu/scripts/tracetool/backend/syslog.py Imports are incorrectly sorted and/or formatted.
> ERROR: /builds/qemu-project/qemu/scripts/tracetool/backend/ust.py Imports are incorrectly sorted and/or formatted.
> ERROR: /builds/qemu-project/qemu/scripts/tracetool/format/__init__.py Imports are incorrectly sorted and/or formatted.
> ERROR: /builds/qemu-project/qemu/scripts/tracetool/format/c.py Imports are incorrectly sorted and/or formatted.
> ERROR: /builds/qemu-project/qemu/scripts/tracetool/format/d.py Imports are incorrectly sorted and/or formatted.
> ERROR: /builds/qemu-project/qemu/scripts/tracetool/format/h.py Imports are incorrectly sorted and/or formatted.
> ERROR: /builds/qemu-project/qemu/scripts/tracetool/format/log_stap.py Imports are incorrectly sorted and/or formatted.
> ERROR: /builds/qemu-project/qemu/scripts/tracetool/format/rs.py Imports are incorrectly sorted and/or formatted.
> ERROR: /builds/qemu-project/qemu/scripts/tracetool/format/simpletrace_stap.py Imports are incorrectly sorted and/or formatted.
> ERROR: /builds/qemu-project/qemu/scripts/tracetool/format/stap.py Imports are incorrectly sorted and/or formatted.
> ERROR: /builds/qemu-project/qemu/scripts/tracetool/format/ust_events_c.py Imports are incorrectly sorted and/or formatted.
> ERROR: /builds/qemu-project/qemu/scripts/tracetool/format/ust_events_h.py Imports are incorrectly sorted and/or formatted.
> Log file "stderr" content for test "38-tests/tracetool-isort.sh" (FAIL):
> Log file "stdout" content for test "39-tests/tracetool-mypy.sh" (FAIL):
> tracetool/backend/dtrace.py:76: error: Function is missing a type annotation [no-untyped-def]
> tracetool/backend/dtrace.py:91: error: Function is missing a type annotation [no-untyped-def]
> tracetool/backend/dtrace.py:99: error: Function is missing a type annotation [no-untyped-def]
> Found 3 errors in 1 file (checked 18 source files)
r~
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PULL 0/8] Tracing patches
2026-01-19 20:53 ` [PULL 0/8] Tracing patches Richard Henderson
@ 2026-01-19 21:00 ` Paolo Bonzini
0 siblings, 0 replies; 12+ messages in thread
From: Paolo Bonzini @ 2026-01-19 21:00 UTC (permalink / raw)
To: Richard Henderson, Stefan Hajnoczi, qemu-devel
Cc: Cleber Rosa, Mads Ynddal, Richard Henderson, John Snow
On 1/19/26 21:53, Richard Henderson wrote:
>
> This has lots of failures:
>
> https://gitlab.com/qemu-project/qemu/-/jobs/12772423978
>
>> Summary of Failures:
>> 507/512 tracetool -
>> qemu:dtrace
>> FAIL 0.03s exit status 1
>> 508/512 tracetool -
>> qemu:ftrace
>> FAIL 0.04s exit status 1
>> 509/512 tracetool -
>> qemu:log
>> FAIL 0.04s exit status 1
>> 510/512 tracetool -
>> qemu:simple
>> FAIL 0.04s exit status 1
>> 511/512 tracetool -
>> qemu:syslog
>> FAIL 0.04s exit status 1
>> 512/512 tracetool -
>> qemu:ust
>> FAIL 0.03s exit status 1
>
> https://gitlab.com/qemu-project/qemu/-/jobs/12772423994
Given the PR is based on an old tag ("Merge tag 'pull-tcg-20250905' of
https://gitlab.com/rth7680/qemu into staging") it's probably conflicting
with some changes to python/.
Stefan, drop those and I'll resubmit in some time.
Paolo
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-01-19 21:01 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-19 19:08 [PULL 0/8] Tracing patches Stefan Hajnoczi
2026-01-19 19:08 ` [PULL 1/8] tracetool: rename variable with conflicting types Stefan Hajnoczi
2026-01-19 19:08 ` [PULL 2/8] tracetool: apply isort and add check Stefan Hajnoczi
2026-01-19 19:08 ` [PULL 3/8] tracetool: "import annotations" Stefan Hajnoczi
2026-01-19 19:08 ` [PULL 4/8] tracetool: add type annotations Stefan Hajnoczi
2026-01-19 19:08 ` [PULL 5/8] tracetool: complete typing annotations Stefan Hajnoczi
2026-01-19 19:08 ` [PULL 6/8] tracetool: add typing checks to "make -C python check" Stefan Hajnoczi
2026-01-19 19:08 ` [PULL 7/8] tracetool-test: add QEMU_TEST_KEEP_SCRATCH=1 support Stefan Hajnoczi
2026-01-19 19:13 ` Daniel P. Berrangé
2026-01-19 19:08 ` [PULL 8/8] tests/tracetool: Honor the Python interpreter that "configure" detected Stefan Hajnoczi
2026-01-19 20:53 ` [PULL 0/8] Tracing patches Richard Henderson
2026-01-19 21:00 ` Paolo Bonzini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.