From: Fabiano Rosas <farosas@suse.de>
To: "Daniel P. Berrangé" <berrange@redhat.com>, qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Michael Roth" <michael.roth@amd.com>,
"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Dr. David Alan Gilbert" <dave@treblig.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
"Eric Blake" <eblake@redhat.com>,
"Daniel P. Berrangé" <berrange@redhat.com>,
"Laurent Vivier" <lvivier@redhat.com>
Subject: Re: [PATCH 07/21] util: introduce 'tldr', a system data recorder for crash handling
Date: Tue, 17 Nov 2026 16:52:54 -0300 [thread overview]
Message-ID: <871p8js0a1.fsf@suse.de> (raw)
In-Reply-To: <20261015112044.1999748-8-berrange@redhat.com>
Daniel P. Berrangé <berrange@redhat.com> writes:
> Introduce a new subsystem "tldr" aka "thrifty live data recorder"
> that will be able to continuously collect certain information at
> runtime and dump that in a crash report when QEMU exits abnormally.
> As a second use case, it will support manual triggering on interesting
> events such as guest OS panic.
>
Could we bind this to the existing panic and watchdog actions? Why wait
for management layer permission just to spit some logs?
> Initially the framework does nothing except print the signal
> information. Later commits will introduce broader data collection.
> This relies on the dummy siginfo_t struct for portability to Windows.
>
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
> MAINTAINERS | 8 +
> include/qemu/tldr.h | 24 ++
> qapi/qom.json | 15 ++
> qemu-options.hx | 14 ++
> tests/unit/meson.build | 1 +
> tests/unit/test-util-tldr.c | 105 +++++++++
> util/meson.build | 1 +
> util/tldr-internal.h | 21 ++
> util/tldr.c | 438 ++++++++++++++++++++++++++++++++++++
> 9 files changed, 627 insertions(+)
> create mode 100644 include/qemu/tldr.h
> create mode 100644 tests/unit/test-util-tldr.c
> create mode 100644 util/tldr-internal.h
> create mode 100644 util/tldr.c
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 6b5aafe43b1..4fa68810c1e 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -4772,3 +4772,11 @@ Machine development tool
> M: Maksim Davydov <davydov-max@yandex-team.ru>
> S: Supported
> F: scripts/compare-machine-types.py
> +
> +Data Recorder
> +M: Daniel P. Berrangé <berrange@redhat.com>
> +S: Maintained
> +F: util/tldr.c
> +F: util/tldr-internal.h
> +F: include/qemu/tldr.h
> +F: tests/unit/test-util-tldr.c
> diff --git a/include/qemu/tldr.h b/include/qemu/tldr.h
> new file mode 100644
> index 00000000000..67152b136b3
> --- /dev/null
> +++ b/include/qemu/tldr.h
> @@ -0,0 +1,24 @@
> +/*
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + *
> + * TL;DR: Thrifty Live Data Recorder
> + *
> + * Copyright (C) 2026 Red Hat Inc.
> + */
> +
> +#ifndef QEMU_TLDR_H__
> +#define QEMU_TLDR_H__
> +
> +/**
> + * qtldr_crash_dump_signal:
> + * @si: signal information
> + *
> + * Print a crash dump in response to a signal.
> + *
> + * The crash will be printed to the configured crash
> + * file, if set. If opening the crash file fails, or
> + * no path is configured, STDERR will be used.
> + */
> +void qtldr_crash_dump_signal(siginfo_t *si);
Will the terms get confusing? There's the existing core dump, the crash,
the other crash, and now the crash dump, the crash file, the
crash-target, etc.
Also, does the use case of dumping on guest panic allow the virtual
machine to continue running? If so, then we definitely need to drop the
"crash" mentions all over.
Perhaps qtldr_dump_on_signal for this one.
> +
> +#endif /* QEMU_TLDR_H__ */
> diff --git a/qapi/qom.json b/qapi/qom.json
> index 49f222796ab..1c9031fba9a 100644
> --- a/qapi/qom.json
> +++ b/qapi/qom.json
> @@ -1233,6 +1233,19 @@
> 'data': { '*pretty': 'bool',
> '*close-action': 'MonitorQMPCloseAction' } }
>
> +##
> +# @QTLDRConfigProperties:
> +# Configuration for data recorder
> +#
> +# @crash-target: fully qualified path to perserve data recorder
preserve
Also,
s/crash-target/dump-target/ ?
> +# contents on QEMU crash
Slightly ambiguous, maybe one of:
s/on/about/
s/on/upon/
> +#
> +# Since: 11.2.0
> +##
> +{ 'struct': 'QTLDRConfigProperties',
> + 'data': { '*crash-target': 'str' }
> +}
> +
> ##
> # @ObjectType:
> #
> @@ -1302,6 +1315,7 @@
> 's390-pv-guest',
> 'tdx-guest',
> 'throttle-group',
> + 'tldr-config',
> 'tls-creds-anon',
> 'tls-creds-psk',
> 'tls-creds-x509',
> @@ -1379,6 +1393,7 @@
> 'tdx-guest': 'TdxGuestProperties',
> 'thread-context': 'ThreadContextProperties',
> 'throttle-group': 'ThrottleGroupProperties',
> + 'tldr-config': 'QTLDRConfigProperties',
> 'tls-creds-anon': 'TlsCredsAnonProperties',
> 'tls-creds-psk': 'TlsCredsPskProperties',
> 'tls-creds-x509': 'TlsCredsX509Properties',
> diff --git a/qemu-options.hx b/qemu-options.hx
> index 2f6863180b0..2f63d86b635 100644
> --- a/qemu-options.hx
> +++ b/qemu-options.hx
> @@ -6682,6 +6682,20 @@ SRST
> ::
>
> (qemu) qom-set /objects/iothread1 poll-max-ns 100000
> +
> +
> + ``-object tldr-config,id=id,crash-target=path``
> + Creating the ``tldr-config`` object enables the thrifty live data
> + recorder, which continuously captures important information about
> + the operation of the QEMU process. When a SIGSEGV, SIGBUS,
> + SIGILL, SIGFPE or SIGABRT are seen the contents of the data
> + recorder will be dumped to the stderr stream. If the
> + ``crash-target`` parameter was given, that specifies a fully
> + qualified file path to write the dump to instead of stderr.
> +
> + The ``tldr-config`` object can be added at initial startup
> + or via QMP at runtime. Once created, however, it is not
> + permitted to disable it.
> ERST
>
>
> diff --git a/tests/unit/meson.build b/tests/unit/meson.build
> index d17435c1877..aa02895e767 100644
> --- a/tests/unit/meson.build
> +++ b/tests/unit/meson.build
> @@ -136,6 +136,7 @@ if have_system
> 'test-qmp-cmds': [testqapi],
> 'test-xbzrle': [migration],
> 'test-util-sockets': ['socket-helpers.c'],
> + 'test-util-tldr': [],
> 'test-base64': [],
> 'test-bufferiszero': [],
> 'test-smp-parse': [qom, meson.project_source_root() / 'hw/core/machine-smp.c'],
> diff --git a/tests/unit/test-util-tldr.c b/tests/unit/test-util-tldr.c
> new file mode 100644
> index 00000000000..4384e10cc18
> --- /dev/null
> +++ b/tests/unit/test-util-tldr.c
> @@ -0,0 +1,105 @@
> +/*
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + *
> + * Tests for util/tldr.c
> + *
> + * Copyright 2026 Red Hat, Inc.
> + */
> +
> +#include "qemu/osdep.h"
> +#include "util/tldr-internal.h"
> +
> +typedef struct {
> + bool siginfo;
> + const char *data;
> +} QTLDRTestData;
> +
> +#define TEST_SIGINFO_NULL \
> + QTLDR_DUMP_TRIGGER_PREFIX "manual\n"
> +
> +#define TEST_SIGINFO_SEGV \
> + QTLDR_DUMP_TRIGGER_PREFIX "\n" \
> + " - Signal: SIGSEGV (11)\n" \
> + " - Code: Address not mapped (1)\n" \
> + " - Address: 0x87539319\n"
> +
> +
> +static void
> +test_tldr_one(QTLDRTestData *data)
> +{
> + g_autofree char *tmpname = NULL;
> + int tmpfd;
> + char buf[1024];
> + ssize_t dumplen;
> +
> + tmpfd = g_file_open_tmp("test-util-tldr-XXXXXX",
> + &tmpname, NULL);
> + unlink(tmpname);
> +
> + if (data->siginfo) {
> + siginfo_t si = {};
> + si.si_signo = 11; /*
> + * SIGSEGV on Linux, but don't use constant
> + * since expected output string hardcodes 11
> + */
> + si.si_code = 1;
> + si.si_addr = (void *)0x87539319;
> + qtldr_crash_dump_internal(tmpfd, &si);
> + } else {
> + qtldr_crash_dump_internal(tmpfd, NULL);
> + }
> +
> + lseek(tmpfd, 0, SEEK_SET);
> +
> + dumplen = read(tmpfd, buf, sizeof(buf));
> +
> + assert(dumplen > 0);
> + buf[dumplen] = '\0';
> +
> + close(tmpfd);
> +
> + g_assert_cmpstr(buf, ==, data->data);
> +}
> +
> +
> +static void
> +test_tldr_minimal_default(void)
> +{
> + QTLDRTestData data = {
> + .siginfo = false,
> + .data =
> + QTLDR_DUMP_LEADER
> + TEST_SIGINFO_NULL
> + QTLDR_DUMP_TRAILER
> + };
> +
> + test_tldr_one(&data);
> +}
> +
> +
> +static void
> +test_tldr_minimal_siginfo(void)
> +{
> + QTLDRTestData data = {
> + .siginfo = true,
> + .data =
> + QTLDR_DUMP_LEADER
> + TEST_SIGINFO_SEGV
> + QTLDR_DUMP_TRAILER
> + };
> +
> + test_tldr_one(&data);
> +}
> +
> +
> +int main(int argc, char **argv)
> +{
> + g_test_init(&argc, &argv, NULL);
> +
> + g_test_add_func("/util/tldr/minimal/default",
> + test_tldr_minimal_default);
> + g_test_add_func("/util/tldr/minimal/siginfo",
> + test_tldr_minimal_siginfo);
> +
> + return g_test_run();
> +}
> diff --git a/util/meson.build b/util/meson.build
> index fa174c07a57..00c2350c87e 100644
> --- a/util/meson.build
> +++ b/util/meson.build
> @@ -66,6 +66,7 @@ util_ss.add(files('int128.c'))
> util_ss.add(files('memalign.c'))
> util_ss.add(files('interval-tree.c'))
> util_ss.add(files('lockcnt.c'))
> +util_ss.add(files('tldr.c'))
>
> if have_system
> util_ss.add(files('crc-ccitt.c'))
> diff --git a/util/tldr-internal.h b/util/tldr-internal.h
> new file mode 100644
> index 00000000000..193d8425eee
> --- /dev/null
> +++ b/util/tldr-internal.h
> @@ -0,0 +1,21 @@
> +/*
> + * SPDX-License-Identifier: GPL-2.0-or-later
> + *
> + * TL;DR: Thrifty Live Data Recorder
> + *
> + * Copyright (C) 2026 Red Hat Inc.
> + */
> +
> +#ifndef QEMU_TLDR_INTERNAL_H__
> +#define QEMU_TLDR_INTERNAL_H__
> +
> +#include "qemu/tldr.h"
> +
> +#define QTLDR_DUMP_LEADER "\n🚨🚨🚨 QEMU Data Recorder Start 🚨🚨🚨\n"
> +#define QTLDR_DUMP_TRAILER "\n🚨🚨🚨 QEMU Data Recorder End 🚨🚨🚨\n\n"
> +#define QTLDR_DUMP_TRIGGER_PREFIX "\n🔍 Trigger:"
> +#define QTLDR_DUMP_OPEN_ERROR "🔥 Unable to dump to '"
These markers got me thinking whether regular QEMU logs can interleave
with tldr when directed to stderr. This is a new situation for libvirt.
next prev parent reply other threads:[~2026-11-17 19:53 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 11:20 [PATCH 00/21] system: introduce a live data recorder facility Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 01/21] osdep: add 'ignore_value(x)' macro Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 02/21] system: move SIGBUS signal handling to signal.c Daniel P. Berrangé
2026-10-15 12:15 ` marcandre.lureau
2026-10-15 11:20 ` [PATCH 03/21] system: rename qemu_init_sigbus to qemu_init_crash_signals Daniel P. Berrangé
2026-10-15 12:15 ` marcandre.lureau
2026-10-15 11:20 ` [PATCH 04/21] system: run SIGBUS handler on alternate signal stack Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 05/21] util: expand alternate signal stack to all threads Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 06/21] osdep: provide dummy siginfo_t definition Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 07/21] util: introduce 'tldr', a system data recorder for crash handling Daniel P. Berrangé
2026-10-29 8:29 ` Markus Armbruster
2026-10-29 15:35 ` Daniel P. Berrangé
2026-10-30 8:59 ` Markus Armbruster
2026-11-17 19:52 ` Fabiano Rosas [this message]
2026-10-15 11:20 ` [PATCH 08/21] qapi: add 'tldr-dump' command for on-demand data recorder output Daniel P. Berrangé
2026-10-29 8:35 ` Markus Armbruster
2026-10-29 15:37 ` Daniel P. Berrangé
2026-11-17 19:55 ` Fabiano Rosas
2026-10-15 11:20 ` [PATCH 09/21] system: trigger TLDR crash dump on unhandled SIGBUS Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 10/21] system: simplify signal handler logic Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 11/21] main: allow SIGBUS in the main loop Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 12/21] system: enable SIGBUS handling on non-Linux platforms Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 13/21] system: enable crash dumps on SIGSEGV, SIGILL, SIGFPE and SIGABRT Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 14/21] util: introduce capture of textual messages in data recorder Daniel P. Berrangé
2026-10-29 8:49 ` Markus Armbruster
2026-11-17 20:29 ` Fabiano Rosas
2026-10-15 11:20 ` [PATCH 15/21] util: capture warnings and errors in the " Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 16/21] monitor: remove obsolete/redundant exports Daniel P. Berrangé
2026-10-29 8:51 ` Markus Armbruster
2026-10-15 11:20 ` [PATCH 17/21] monitor: capture monitor commands and events in data recorder Daniel P. Berrangé
2026-10-15 15:57 ` Dr. David Alan Gilbert
2026-10-15 16:11 ` Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 18/21] log: enable directing log messages to " Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 19/21] tests/qtest: add API to declare an expected crash signal Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 20/21] qtest: add 'crash' command to generate 'authentic' process crashes Daniel P. Berrangé
2026-10-15 11:20 ` [PATCH 21/21] tests/qtest: add test to validate data recorder on crashes Daniel P. Berrangé
2026-10-15 12:15 ` [PATCH 00/21] system: introduce a live data recorder facility marcandre.lureau
2026-10-15 12:32 ` Daniel P. Berrangé
2026-10-16 7:20 ` Marc-André Lureau
2026-10-29 17:32 ` Daniel P. Berrangé
2026-10-29 18:15 ` Marc-André Lureau
2026-10-29 18:28 ` Daniel P. Berrangé
2026-10-30 8:47 ` Marc-André Lureau
2026-10-15 17:34 ` Pierrick Bouvier
2026-10-29 17:39 ` Daniel P. Berrangé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871p8js0a1.fsf@suse.de \
--to=farosas@suse.de \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=dave@treblig.org \
--cc=eblake@redhat.com \
--cc=lvivier@redhat.com \
--cc=marcandre.lureau@redhat.com \
--cc=michael.roth@amd.com \
--cc=pbonzini@redhat.com \
--cc=philmd@oss.qualcomm.com \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.