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

Daniel P. Berrangé posted 21 patches 1 month, 1 week ago
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
[PATCH 00/21] system: introduce a live data recorder facility
Posted by Daniel P. Berrangé 1 month, 1 week ago
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

-- 
2.56.0


Re: [PATCH 00/21] system: introduce a live data recorder facility
Posted by marcandre.lureau@redhat.com 1 month, 1 week ago
> 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

It should probably be recorded at emission, not per monitor

>  * 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'.

Instead of allocating and dumping by a signal handler, why not use a file-backed
mmap or a memfd? We would need to define a small fixed header for the file
layout/buckets.  This would avoid all the issues with signal handlers.

There would be a small window for consistency on crash, but that's probably
acceptable.

Plain ASCII section markers would probably be easier to deal with than emojis

-- 
Marc-André Lureau <marcandre.lureau@redhat.com>


Re: [PATCH 00/21] system: introduce a live data recorder facility
Posted by Daniel P. Berrangé 1 month, 1 week ago
On Thu, Oct 15, 2026 at 04:15:52PM +0400, marcandre.lureau@redhat.com wrote:
> > 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
> 
> It should probably be recorded at emission, not per monitor

Opps.

> >  * 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'.
> 
> Instead of allocating and dumping by a signal handler, why not use a file-backed
> mmap or a memfd? We would need to define a small fixed header for the file
> layout/buckets.  This would avoid all the issues with signal handlers.

That would impose a continuous I/O workload on data recording, which
is something I wanted to explicitly avoid, until the time the data is
needed to be preserved. This only persists the final data, not any
intermediate data that is overwritten as the circular buffer wraps.
Coupling the in-memory layout to the on-disk layout also means that
dumps would always be the max size, since we would not have grow-on
demand buffers.

File backed would be even worse for the follow up goal of including
statistics, since it'd be putting disk I/O into the stats gathering
path.

> There would be a small window for consistency on crash, but that's probably
> acceptable.
> 
> Plain ASCII section markers would probably be easier to deal with than emojis



With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
Re: [PATCH 00/21] system: introduce a live data recorder facility
Posted by Marc-André Lureau 1 month, 1 week ago
Hi

On Thu, Oct 15, 2026 at 4:32 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Thu, Oct 15, 2026 at 04:15:52PM +0400, marcandre.lureau@redhat.com wrote:
> > > 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
> >
> > It should probably be recorded at emission, not per monitor
>
> Opps.
>
> > >  * 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'.
> >
> > Instead of allocating and dumping by a signal handler, why not use a file-backed
> > mmap or a memfd? We would need to define a small fixed header for the file
> > layout/buckets.  This would avoid all the issues with signal handlers.
>
> That would impose a continuous I/O workload on data recording, which
> is something I wanted to explicitly avoid, until the time the data is

Yes, a file-backed mapping shouldn't be the default, but memfd/tmpfs
should have the same performance.

> needed to be preserved. This only persists the final data, not any
> intermediate data that is overwritten as the circular buffer wraps.

Same design, the reader would handle the ring data

> Coupling the in-memory layout to the on-disk layout also means that
> dumps would always be the max size, since we would not have grow-on
> demand buffers.

The dump output would not be the raw data, a reader would emit the
same text format, skipping the unused parts.

mapping reserves address space only, pages are allocated on first write.

The benefits:
- no signal handler, no conflict with MCE, ASAN etc
- data survives SIGKILL, OOM, or a crash in the dump path itself
- data can be read from a hung QEMU

Someone needs to hold the memfd to outlive QEMU, otherwise QEMU could
create a file under a runtime dir on tmpfs

>
> File backed would be even worse for the follow up goal of including
> statistics, since it'd be putting disk I/O into the stats gathering
> path.
>
> > There would be a small window for consistency on crash, but that's probably
> > acceptable.
> >
> > Plain ASCII section markers would probably be easier to deal with than emojis
>
>
>
> With regards,
> Daniel
> --
> |: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
> |: https://libvirt.org          ~~          https://entangle-photo.org :|
> |: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
>
Re: [PATCH 00/21] system: introduce a live data recorder facility
Posted by Daniel P. Berrangé 3 weeks, 3 days ago
On Fri, Oct 16, 2026 at 11:20:11AM +0400, Marc-André Lureau wrote:
> Hi
> 
> On Thu, Oct 15, 2026 at 4:32 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
> >
> > On Thu, Oct 15, 2026 at 04:15:52PM +0400, marcandre.lureau@redhat.com wrote:
> > > > 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
> > >
> > > It should probably be recorded at emission, not per monitor
> >
> > Opps.
> >
> > > >  * 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'.
> > >
> > > Instead of allocating and dumping by a signal handler, why not use a file-backed
> > > mmap or a memfd? We would need to define a small fixed header for the file
> > > layout/buckets.  This would avoid all the issues with signal handlers.
> >
> > That would impose a continuous I/O workload on data recording, which
> > is something I wanted to explicitly avoid, until the time the data is
> 
> Yes, a file-backed mapping shouldn't be the default, but memfd/tmpfs
> should have the same performance.
> 
> > needed to be preserved. This only persists the final data, not any
> > intermediate data that is overwritten as the circular buffer wraps.
> 
> Same design, the reader would handle the ring data
> 
> > Coupling the in-memory layout to the on-disk layout also means that
> > dumps would always be the max size, since we would not have grow-on
> > demand buffers.
> 
> The dump output would not be the raw data, a reader would emit the
> same text format, skipping the unused parts.

IMHO that reader has to be QEMU owned code, as otherwise we're
exposing a private data structure to a 3rd party and that makes
it public ABI/API which is highly undesirable for this.

> mapping reserves address space only, pages are allocated on first write.
> 
> The benefits:
> - no signal handler, no conflict with MCE, ASAN etc

A signal handler is integral to some extent, as captured info about
the signal is itself is an important part of the data record. IOW,
even if moving writing of the dump out of the signal handler in some
manner, I still want to be able to capture several siginfo_t fields.

You can get that info from a core dump, but the working premise
is that a core dump is not guaranteed available, whereas the data
record dumps are something we can more easily acquire.

> - data survives SIGKILL, OOM, or a crash in the dump path itself

Simplifying the signal handler to just stash the siginfo_t would
help.

> - data can be read from a hung QEMU

Data can always be read from a hung QEMU by sending it a signal.
We could wire up a non-fatal signal for this purpose if we want
to read hung QEMUs without killing them.

> Someone needs to hold the memfd to outlive QEMU, otherwise QEMU could
> create a file under a runtime dir on tmpfs

I wonder if QEMU could simply fork a child process itself that just
hangs around waiting for death, and has a shared memory region with
the main QEMU.

We already have a '-run-with async-teardown' comamnd line, which
forks a child process and uses prctl(PR_SET_PDEATHSIG) to get
notified with the parent goes away.  We could expand that child
process to also handle crash dump writing.

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|


Re: [PATCH 00/21] system: introduce a live data recorder facility
Posted by Marc-André Lureau 3 weeks, 3 days ago
Hi

On Thu, Oct 29, 2026 at 9:33 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Fri, Oct 16, 2026 at 11:20:11AM +0400, Marc-André Lureau wrote:
> > Hi
> >
> > On Thu, Oct 15, 2026 at 4:32 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
> > >
> > > On Thu, Oct 15, 2026 at 04:15:52PM +0400, marcandre.lureau@redhat.com wrote:
> > > > > 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
> > > >
> > > > It should probably be recorded at emission, not per monitor
> > >
> > > Opps.
> > >
> > > > >  * 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'.
> > > >
> > > > Instead of allocating and dumping by a signal handler, why not use a file-backed
> > > > mmap or a memfd? We would need to define a small fixed header for the file
> > > > layout/buckets.  This would avoid all the issues with signal handlers.
> > >
> > > That would impose a continuous I/O workload on data recording, which
> > > is something I wanted to explicitly avoid, until the time the data is
> >
> > Yes, a file-backed mapping shouldn't be the default, but memfd/tmpfs
> > should have the same performance.
> >
> > > needed to be preserved. This only persists the final data, not any
> > > intermediate data that is overwritten as the circular buffer wraps.
> >
> > Same design, the reader would handle the ring data
> >
> > > Coupling the in-memory layout to the on-disk layout also means that
> > > dumps would always be the max size, since we would not have grow-on
> > > demand buffers.
> >
> > The dump output would not be the raw data, a reader would emit the
> > same text format, skipping the unused parts.
>
> IMHO that reader has to be QEMU owned code, as otherwise we're
> exposing a private data structure to a 3rd party and that makes
> it public ABI/API which is highly undesirable for this.

The resulting data will be ABI/API anyway, no?

>
> > mapping reserves address space only, pages are allocated on first write.
> >
> > The benefits:
> > - no signal handler, no conflict with MCE, ASAN etc
>
> A signal handler is integral to some extent, as captured info about
> the signal is itself is an important part of the data record. IOW,
> even if moving writing of the dump out of the signal handler in some
> manner, I still want to be able to capture several siginfo_t fields.
>
> You can get that info from a core dump, but the working premise
> is that a core dump is not guaranteed available, whereas the data
> record dumps are something we can more easily acquire.

right.. this is something you don't touch in the cover letter. I
assume most systems have a core dump handler already (perhaps
differently on Windows), thus we could also rely on the dumped data
instead of a signal handler. We should be explicit about why we don't
follow that path

systemd/coredumpctl does store siginfo_t of the process too

>
> > - data survives SIGKILL, OOM, or a crash in the dump path itself
>
> Simplifying the signal handler to just stash the siginfo_t would
> help.
>
> > - data can be read from a hung QEMU
>
> Data can always be read from a hung QEMU by sending it a signal.
> We could wire up a non-fatal signal for this purpose if we want
> to read hung QEMUs without killing them.
>
> > Someone needs to hold the memfd to outlive QEMU, otherwise QEMU could
> > create a file under a runtime dir on tmpfs
>
> I wonder if QEMU could simply fork a child process itself that just
> hangs around waiting for death, and has a shared memory region with
> the main QEMU.
>
> We already have a '-run-with async-teardown' comamnd line, which
> forks a child process and uses prctl(PR_SET_PDEATHSIG) to get
> notified with the parent goes away.  We could expand that child
> process to also handle crash dump writing.

Yes, that should work, although I would like to have a rationale
why/when core dump aren't good enough.

thanks
Re: [PATCH 00/21] system: introduce a live data recorder facility
Posted by Daniel P. Berrangé 3 weeks, 3 days ago
On Thu, Oct 29, 2026 at 10:15:46PM +0400, Marc-André Lureau wrote:
> Hi
> 
> On Thu, Oct 29, 2026 at 9:33 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
> >
> > On Fri, Oct 16, 2026 at 11:20:11AM +0400, Marc-André Lureau wrote:
> > > Hi
> > >
> > > On Thu, Oct 15, 2026 at 4:32 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
> > > >
> > > > On Thu, Oct 15, 2026 at 04:15:52PM +0400, marcandre.lureau@redhat.com wrote:
> > > > > > 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
> > > > >
> > > > > It should probably be recorded at emission, not per monitor
> > > >
> > > > Opps.
> > > >
> > > > > >  * 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'.
> > > > >
> > > > > Instead of allocating and dumping by a signal handler, why not use a file-backed
> > > > > mmap or a memfd? We would need to define a small fixed header for the file
> > > > > layout/buckets.  This would avoid all the issues with signal handlers.
> > > >
> > > > That would impose a continuous I/O workload on data recording, which
> > > > is something I wanted to explicitly avoid, until the time the data is
> > >
> > > Yes, a file-backed mapping shouldn't be the default, but memfd/tmpfs
> > > should have the same performance.
> > >
> > > > needed to be preserved. This only persists the final data, not any
> > > > intermediate data that is overwritten as the circular buffer wraps.
> > >
> > > Same design, the reader would handle the ring data
> > >
> > > > Coupling the in-memory layout to the on-disk layout also means that
> > > > dumps would always be the max size, since we would not have grow-on
> > > > demand buffers.
> > >
> > > The dump output would not be the raw data, a reader would emit the
> > > same text format, skipping the unused parts.
> >
> > IMHO that reader has to be QEMU owned code, as otherwise we're
> > exposing a private data structure to a 3rd party and that makes
> > it public ABI/API which is highly undesirable for this.
> 
> The resulting data will be ABI/API anyway, no?

I was considering it human targetted data, not machine
targetted data, so not API and subject to change.

> 
> >
> > > mapping reserves address space only, pages are allocated on first write.
> > >
> > > The benefits:
> > > - no signal handler, no conflict with MCE, ASAN etc
> >
> > A signal handler is integral to some extent, as captured info about
> > the signal is itself is an important part of the data record. IOW,
> > even if moving writing of the dump out of the signal handler in some
> > manner, I still want to be able to capture several siginfo_t fields.
> >
> > You can get that info from a core dump, but the working premise
> > is that a core dump is not guaranteed available, whereas the data
> > record dumps are something we can more easily acquire.
> 
> right.. this is something you don't touch in the cover letter. I
> assume most systems have a core dump handler already (perhaps
> differently on Windows), thus we could also rely on the dumped data
> instead of a signal handler. We should be explicit about why we don't
> follow that path
> 
> systemd/coredumpctl does store siginfo_t of the process too

We often can't get at those core dump records when inside a container.

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|


Re: [PATCH 00/21] system: introduce a live data recorder facility
Posted by Marc-André Lureau 3 weeks, 2 days ago
Hi

On Thu, Oct 29, 2026 at 10:29 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Thu, Oct 29, 2026 at 10:15:46PM +0400, Marc-André Lureau wrote:
> > Hi
> >
> > On Thu, Oct 29, 2026 at 9:33 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
> > >
> > > On Fri, Oct 16, 2026 at 11:20:11AM +0400, Marc-André Lureau wrote:
> > > > Hi
> > > >
> > > > On Thu, Oct 15, 2026 at 4:32 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
> > > > >
> > > > > On Thu, Oct 15, 2026 at 04:15:52PM +0400, marcandre.lureau@redhat.com wrote:
> > > > > > > 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
> > > > > >
> > > > > > It should probably be recorded at emission, not per monitor
> > > > >
> > > > > Opps.
> > > > >
> > > > > > >  * 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'.
> > > > > >
> > > > > > Instead of allocating and dumping by a signal handler, why not use a file-backed
> > > > > > mmap or a memfd? We would need to define a small fixed header for the file
> > > > > > layout/buckets.  This would avoid all the issues with signal handlers.
> > > > >
> > > > > That would impose a continuous I/O workload on data recording, which
> > > > > is something I wanted to explicitly avoid, until the time the data is
> > > >
> > > > Yes, a file-backed mapping shouldn't be the default, but memfd/tmpfs
> > > > should have the same performance.
> > > >
> > > > > needed to be preserved. This only persists the final data, not any
> > > > > intermediate data that is overwritten as the circular buffer wraps.
> > > >
> > > > Same design, the reader would handle the ring data
> > > >
> > > > > Coupling the in-memory layout to the on-disk layout also means that
> > > > > dumps would always be the max size, since we would not have grow-on
> > > > > demand buffers.
> > > >
> > > > The dump output would not be the raw data, a reader would emit the
> > > > same text format, skipping the unused parts.
> > >
> > > IMHO that reader has to be QEMU owned code, as otherwise we're
> > > exposing a private data structure to a 3rd party and that makes
> > > it public ABI/API which is highly undesirable for this.
> >
> > The resulting data will be ABI/API anyway, no?
>
> I was considering it human targetted data, not machine
> targetted data, so not API and subject to change.

So why would intermediate data be considered differently?

>
> >
> > >
> > > > mapping reserves address space only, pages are allocated on first write.
> > > >
> > > > The benefits:
> > > > - no signal handler, no conflict with MCE, ASAN etc
> > >
> > > A signal handler is integral to some extent, as captured info about
> > > the signal is itself is an important part of the data record. IOW,
> > > even if moving writing of the dump out of the signal handler in some
> > > manner, I still want to be able to capture several siginfo_t fields.
> > >
> > > You can get that info from a core dump, but the working premise
> > > is that a core dump is not guaranteed available, whereas the data
> > > record dumps are something we can more easily acquire.
> >
> > right.. this is something you don't touch in the cover letter. I
> > assume most systems have a core dump handler already (perhaps
> > differently on Windows), thus we could also rely on the dumped data
> > instead of a signal handler. We should be explicit about why we don't
> > follow that path
> >
> > systemd/coredumpctl does store siginfo_t of the process too
>
> We often can't get at those core dump records when inside a container.
>

I am not sure I understand that justification. But anyway, since the
record will be in memory, we can also retrieve it from the coredump,
even if a trace is written too.
Re: [PATCH 00/21] system: introduce a live data recorder facility
Posted by Pierrick Bouvier 1 month, 1 week ago
Hi Daniel,

On 10/15/2026 4:20 AM, Daniel P. Berrangé wrote:
> 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.
>

if I understand correctly, the goal of this new object is to provide a
per-topic rotating log in memory that will be flushed on disk only when
we have a specific event (exit, or any signal). That's sounds like a
good idea!

Why not refactor exisiting trace/log and provide the same feature
directly there? This would be transparent, and user could decide to
either dump the full file (same than before) or benefit from rotating
memory buffered, with any custom size.

$QEMU -d category,size=4M -trace events=out,max-size=16M

Regards,
Pierrick

Re: [PATCH 00/21] system: introduce a live data recorder facility
Posted by Daniel P. Berrangé 3 weeks, 3 days ago
On Thu, Oct 15, 2026 at 10:34:14AM -0700, Pierrick Bouvier wrote:
> Hi Daniel,
> 
> On 10/15/2026 4:20 AM, Daniel P. Berrangé wrote:
> > 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.
> >
> 
> if I understand correctly, the goal of this new object is to provide a
> per-topic rotating log in memory that will be flushed on disk only when
> we have a specific event (exit, or any signal). That's sounds like a
> good idea!
> 
> Why not refactor exisiting trace/log and provide the same feature
> directly there? This would be transparent, and user could decide to
> either dump the full file (same than before) or benefit from rotating
> memory buffered, with any custom size.
> 
> $QEMU -d category,size=4M -trace events=out,max-size=16M

The data recorder is intended to report more than just textual
log messages. This series already captures signal info, and  as
noted in the cover letter will also be extended to capture
structured data items such as performance statistics. The text
based messages are just the simple first step.

That said I'll think about whether the split of responsibilities
should adjust so that some of the logic is exposed more broadly
into the log system.

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|