Skip to content

system: introduce a live data recorder facility

Daniel P. Berrangé qemu-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest21 patches 23 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/21osdep: add 'ignore_value(x)' macroinclude/qemu/osdep.h+8 -00 replies
2/21system: move SIGBUS signal handling to signal.cMAINTAINERS include/system/signal.h system/cpus.c +2 more+136 -751 reply
3/21system: rename qemu_init_sigbus to qemu_init_crash_signalsinclude/system/signal.h system/cpus.c system/signal.c+4 -41 reply
4/21system: run SIGBUS handler on alternate signal stackmeson.build system/signal.c+14 -10 replies
5/21util: expand alternate signal stack to all threadsutil/qemu-thread-posix.c+20 -00 replies
6/21osdep: provide dummy siginfo_t definitioninclude/qemu/osdep.h meson.build+10 -00 replies
7/21util: introduce 'tldr', a system data recorder for crash handlingMAINTAINERS include/qemu/tldr.h qapi/qom.json +6 more+627 -04 replies
8/21qapi: add 'tldr-dump' command for on-demand data recorder outputMAINTAINERS qapi/meson.build qapi/qapi-schema.json +3 more+65 -03 replies
9/21system: trigger TLDR crash dump on unhandled SIGBUSsystem/signal.c+6 -40 replies
10/21system: simplify signal handler logicsystem/signal.c+6 -90 replies
11/21main: allow SIGBUS in the main looputil/main-loop.c+0 -10 replies
12/21system: enable SIGBUS handling on non-Linux platformsmeson.build system/signal.c+16 -70 replies
13/21system: enable crash dumps on SIGSEGV, SIGILL, SIGFPE and SIGABRTsystem/signal.c+28 -50 replies
14/21util: introduce capture of textual messages in data recorderinclude/qemu/tldr.h qapi/qom.json qapi/tldr.json +4 more+682 -22 replies
15/21util: capture warnings and errors in the data recorderMAINTAINERS stubs/meson.build stubs/monitor-puts.c +1 more+35 -190 replies
16/21monitor: remove obsolete/redundant exportsmonitor/monitor-internal.h monitor/qmp.c+2 -31 reply
17/21monitor: capture monitor commands and events in data recordermonitor/qmp.c+59 -82 replies
18/21log: enable directing log messages to data recorderinclude/qemu/log.h util/log.c+34 -90 replies
19/21tests/qtest: add API to declare an expected crash signaltests/qtest/libqtest.c tests/qtest/libqtest.h+38 -90 replies
20/21qtest: add 'crash' command to generate 'authentic' process crashessystem/qtest.c tests/qtest/libqtest.c tests/qtest/libqtest.h+92 -00 replies
21/21tests/qtest: add test to validate data recorder on crashestests/qtest/meson.build tests/qtest/tldr-test.c+127 -00 replies

Reviews trailers per patch

5 of 21 patches have a Reviewed-by or Acked-by.

PatchMarc-André LureauMarkus ArmbrusterFabiano Rosas
1/21R-b
2/21R-b
3/21R-b
4/21
5/21
6/21
7/21
8/21R-b
9/21
10/21
11/21
12/21
13/21
14/21
15/21
16/21R-b
17/21
18/21
19/21
20/21
21/21

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH 00/21] system: introduce a live data recorder facility

This series introduces a new facility called 'tldr' which is a live data recorder. This is intended to aid support of production QEMU deployments, by providing a data collection facility that can be left "always on", such that in the event of a QEMU crash or guest OS crash, certain important information will be recorded.

The data recorder has to be enabled by adding a "tldr-config" object instance with -object / object_add.

With this series, the data recorder collects

* error_report/warn_report/error_printf messages
* QMP events
* QMP errors
* QMP commands, which are not query-XXX/qom-list, or any command associated with a QMP error.
* qemu_log output

The last item is intended primarily to be used in combination with tracing and its 'log' backend, to have continuous recording of certain interesting probes.

Each type of data is collected in a distinct circular buffer, such that high volumes of one type of data, does not result in overwriting other types of low volume data.

The data recorder is set to trigger on SIGBUS, SIGSEGV, SIGILL, SIGFPE and SIGABRT, or manually via QMP 'tldr-dump'.

There is a open question in one of the patches about SIGBUS handling, since that is already used for MCE capture and I'm unclear if I'm breaking something about KVM MCE reporting.

This series proposes using sigaltstack() to register an alternative signal handling stack. This would mainly be useful if we have a crash from a stack overflow, but the cost is that we have 8k extra per thread, and I'm not entirely convinced that's a beneficial tradeoff. Might be better to just accept stack overflows as a risk.

This series only captures text based info, but as a followup I would like to extend this to capture statistics data from relevant subsystems. For example, the BlockBackend has its own "always on" stats accounting code, which can be queried with QMP. Ideally I would like to figure out a way to dump all the BlockBackend stats in the data recorder output. Likewise perhaps capture NIC stats and/or KVM stats in an "always on" manner for some interesting baseline dataset. The challenge with that is making it safe to access the stats data without taking any mutex locks, since this must run from a signal handler.

A typical recommended usage would be:

$QEMU -object tldr-config,id=tldr
-d tldr
-trace events=/var/lib/libvirt/qemu/trace.txt

This leaves dumps to go to QEMU's stderr on crash, but to send them to a file

-object tldr-config,id=tldr,crash-target=/some/path

The '-d tldr' flag redirects qemu_log() to the TLDR buffer instead of stdout, and the '-trace events' arg defines the "always on" tracepoints we want to capture.

An example crash dump seen if I send SIGBUS to a libvirt managed QEMU is, with 'object*' tracepoints collected:

🚨🚨🚨 QEMU Data Recorder Start 🚨🚨🚨

🔍 Trigger:
- Signal: SIGBUS (7)
- Code: User process kill (0)
- Address: 0x1e5a9e

🎥 Message recording 'command':

2026-10-15T10:59:11.318427Z {"execute": "qmp_capabilities", "id": "libvirt-1"}
2026-10-15T10:59:11.322047Z {"execute": "migrate-set-capabilities", "arguments": {"capabilities": [{"state": true, "capability": "events"}]}, "id": "libvirt-3"}
2026-10-15T10:59:11.347566Z {"execute": "balloon", "arguments": {"value": 4294967296}, "id": "libvirt-9"}
2026-10-15T10:59:11.354570Z {"execute": "set-action", "arguments": {"panic": "pause"}, "id": "libvirt-12"}
2026-10-15T10:59:11.358046Z {"execute": "cont", "id": "libvirt-14"}

🎥 Message recording 'event':

2026-10-15T10:59:11.358108Z {"timestamp": {"seconds": 1792061951, "microseconds": 358094}, "event": "RESUME"}
2026-10-15T10:59:20.757392Z {"timestamp": {"seconds": 1792061960, "microseconds": 757371}, "event": "VSERPORT_CHANGE", "data": {"open": true, "id": "console1"}}
2026-10-15T10:59:24.431398Z {"timestamp": {"seconds": 1792061964, "microseconds": 431379}, "event": "NIC_RX_FILTER_CHANGED", "data": {"name": "net0", "path": "/machine/peripheral/net0/virtio-backend"}}
2026-10-15T10:59:32.586658Z {"timestamp": {"seconds": 1792061972, "microseconds": 586603}, "event": "RTC_CHANGE", "data": {"offset": 0, "qom-path": "/machine/unattached/device[12]/rtc"}}

🎥 Message recording 'log':
28:QIO_CHANNEL_FILE)

2026-10-15T10:59:31.753125Z object_dynamic_cast_assert obj=0x557d5c828780 type=chardev-pty->chardev-pty (../chardev/char-pty.c:50:PTY_CHARDEV)
2026-10-15T10:59:31.753128Z object_dynamic_cast_assert obj=0x557d5c828780 type=chardev-pty->chardev-pty (../chardev/char-pty.c:50:PTY_CHARDEV)
2026-10-15T10:59:31.796114Z object_dynamic_cast_assert obj=0x557d5ca7d3a0 type=host-x86_64-cpu->x86_64-cpu (../target/i386/cpu-qom.h:31:X86_CPU)
2026-10-15T10:59:31.796148Z object_class_dynamic_cast_assert type=kvm-apic->apic-common (/home/berrange/src/virt/qemu/include/hw/i386/apic_internal.h:131:APIC_COMMON_GET_CLASS)

...snip...

2026-10-15T10:59:33.713641Z object_dynamic_cast_assert obj=0x557d5cc20b10 type=PCIE->PCI (/home/berrange/src/virt/qemu/include/hw/pci/pci.h:289:PCI_BUS)
2026-10-15T10:59:33.713643Z object_class_dynamic_cast_assert type=PCIE->PCI (/home/berrange/src/virt/qemu/include/hw/pci/pci.h:289:PCI_BUS_GET_CLASS)
2026-10-15T10:59:33.713648Z object_dynamic_cast_assert obj=0x557d5ca03700 type=host-x86_64-cpu->x86_64-cpu (../target/i386/cpu-qom.h:31:X86_CPU)
2026-10-15T10:59:33.713664Z object_dynamic_cast_assert obj=0x557d5eadd320 type=virtio-gpu-device->virtio-device (/home/berrange/src/virt/qemu/include/hw/virtio/virtio.h:91:VIRTIO_DEVICE)

🚨🚨🚨 QEMU Data Recorder End 🚨🚨🚨

"object_*" is not a particularly good choice for 'always on' data collection as it is high volume and mostly noise. The job of identifying the "interesting" low volume tracepoints is outstanding. We can provide guidance upstream but downstream should control what they're interested in collecting. We might want to add further tracepoints in the code at interesting places that we useful for post-crash debugging.

Daniel P. Berrangé (21):
osdep: add 'ignore_value(x)' macro
system: move SIGBUS signal handling to signal.c
system: rename qemu_init_sigbus to qemu_init_crash_signals
system: run SIGBUS handler on alternate signal stack
util: expand alternate signal stack to all threads
osdep: provide dummy siginfo_t definition
util: introduce 'tldr', a system data recorder for crash handling
qapi: add 'tldr-dump' command for on-demand data recorder output
system: trigger TLDR crash dump on unhandled SIGBUS
system: simplify signal handler logic
main: allow SIGBUS in the main loop
system: enable SIGBUS handling on non-Linux platforms
system: enable crash dumps on SIGSEGV, SIGILL, SIGFPE and SIGABRT
util: introduce capture of textual messages in data recorder
util: capture warnings and errors in the data recorder
monitor: remove obsolete/redundant exports
monitor: capture monitor commands and events in data recorder
log: enable directing log messages to data recorder tests/qtest: add API to declare an expected crash signal
qtest: add 'crash' command to generate 'authentic' process crashes tests/qtest: add test to validate data recorder on crashes

 MAINTAINERS                 |  12 +
 include/qemu/log.h          |   1 +
 include/qemu/osdep.h        |  16 +
 include/qemu/tldr.h         |  76 ++++
 include/system/signal.h     |  25 ++
 meson.build                 |   4 +
 monitor/monitor-internal.h  |   2 -
 monitor/qmp.c               |  66 +++-
 qapi/meson.build            |   1 +
 qapi/qapi-schema.json       |   1 +
 qapi/qom.json               |  18 +
 qapi/tldr.json              |  62 +++
 qemu-options.hx             |  24 ++
 stubs/meson.build           |   1 +
 stubs/monitor-puts.c        |   9 +
 system/cpus.c               |  78 +---
 system/meson.build          |   1 +
 system/qtest.c              |  50 +++
 system/signal.c             | 149 +++++++
 tests/qtest/libqtest.c      |  62 ++-
 tests/qtest/libqtest.h      |  27 ++
 tests/qtest/meson.build     |   3 +
 tests/qtest/tldr-test.c     | 124 ++++++
 tests/unit/meson.build      |   1 +
 tests/unit/test-util-tldr.c | 377 ++++++++++++++++++
 util/error-report.c         |  43 ++-
 util/log.c                  |  42 +-
 util/main-loop.c            |   1 -
 util/meson.build            |   1 +
 util/qemu-thread-posix.c    |  20 +
 util/tldr-internal.h        |  52 +++
 util/tldr.c                 | 750 ++++++++++++++++++++++++++++++++++++
 32 files changed, 1976 insertions(+), 123 deletions(-)
 create mode 100644 include/qemu/tldr.h
 create mode 100644 include/system/signal.h
 create mode 100644 qapi/tldr.json
 create mode 100644 stubs/monitor-puts.c
 create mode 100644 system/signal.c
 create mode 100644 tests/qtest/tldr-test.c
 create mode 100644 tests/unit/test-util-tldr.c
 create mode 100644 util/tldr-internal.h
 create mode 100644 util/tldr.c
Signature · 1 line
2.56.0