QEMU-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Michael Roth" <michael.roth@amd.com>,
	"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
	"Fabiano Rosas" <farosas@suse.de>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Dr. David Alan Gilbert" <dave@treblig.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
	"Eric Blake" <eblake@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>
Subject: Re: [PATCH 08/21] qapi: add 'tldr-dump' command for on-demand data recorder output
Date: Thu, 29 Oct 2026 15:37:55 +0000	[thread overview]
Message-ID: <auNoU5fM0z2yBHGY@redhat.com> (raw)
In-Reply-To: <87a4nwgazp.fsf@pond.sub.org>

On Thu, Oct 29, 2026 at 09:35:38AM +0100, Markus Armbruster wrote:
> Daniel P. Berrangé <berrange@redhat.com> writes:
> 
> > While the data recorder is designed to dump its contents in
> > response to various signals that result in a QEMU crash, it
> > is also interesting to explicitly request dump.
> >
> > This could be simply as an adhoc debugging activity, or could
> > be in response to a specific event like a guest OS panic
> > notification.
> >
> > Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> > ---
> >  MAINTAINERS           |  1 +
> >  qapi/meson.build      |  1 +
> >  qapi/qapi-schema.json |  1 +
> >  qapi/tldr.json        | 28 ++++++++++++++++++++++++++++
> >  qemu-options.hx       |  2 ++
> >  util/tldr.c           | 32 ++++++++++++++++++++++++++++++++
> >  6 files changed, 65 insertions(+)
> >  create mode 100644 qapi/tldr.json
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 4fa68810c1e..54265d987cb 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -4780,3 +4780,4 @@ F: util/tldr.c
> >  F: util/tldr-internal.h
> >  F: include/qemu/tldr.h
> >  F: tests/unit/test-util-tldr.c
> > +F: qapi/tldr.json
> > diff --git a/qapi/meson.build b/qapi/meson.build
> > index a46269b5a0c..f8aecb61284 100644
> > --- a/qapi/meson.build
> > +++ b/qapi/meson.build
> > @@ -49,6 +49,7 @@ qapi_all_modules = [
> >    'run-state',
> >    'sockets',
> >    'stats',
> > +  'tldr',
> >    'trace',
> >    'transaction',
> >    'vfio',
> > diff --git a/qapi/qapi-schema.json b/qapi/qapi-schema.json
> > index b93dd68d94c..b36777970d1 100644
> > --- a/qapi/qapi-schema.json
> > +++ b/qapi/qapi-schema.json
> > @@ -76,3 +76,4 @@
> >  { 'include': 'cryptodev.json' }
> >  { 'include': 'cxl.json' }
> >  { 'include': 'uefi.json' }
> > +{ 'include': 'tldr.json' }
> > diff --git a/qapi/tldr.json b/qapi/tldr.json
> > new file mode 100644
> > index 00000000000..8e2b7cda324
> > --- /dev/null
> > +++ b/qapi/tldr.json
> > @@ -0,0 +1,28 @@
> > +# -*- Mode: Python -*-
> > +# vim: filetype=python
> > +# SPDX-License-Identifier: GPL-2.0-or-later
> > +
> > +##
> > +# @QTLDRDumpOptions:
> > +#     Options for `tldr-dump`.
> > +#
> > +# @target: the fully qualified file path to dump
> > +#     the data recorder to
> 
> We're not dumping the data recorder, we're dumping recorded data.

Yes.

> 
> > +#
> > +# Since: 11.2.0
> > +##
> > +{ 'struct': 'QTLDRDumpOptions',
> > +  'data': { 'target': 'str' } }
> > +
> > +##
> > +# @tldr-dump:
> > +#     Dump the data recorder to a file
> > +#
> > +# Since: 11.2.0
> > +#
> > +# .. qmp-example::
> > +#
> > +#     -> { "execute": "tldr-dump", "arguments": { "target": "/tmp/qemu.txt" } }
> > +#     <- { "return": {} }
> > +##
> > +{ 'command': 'tldr-dump', 'data': 'QTLDRDumpOptions' }
> 
> Why do you use a separate type for the arguments?

Original iterations of this patch were passing
around more complex data, so this struct type
is redundant now.

> > diff --git a/util/tldr.c b/util/tldr.c
> > index 13e9881bc9b..ea7c26b8e9b 100644
> > --- a/util/tldr.c
> > +++ b/util/tldr.c
> > @@ -12,6 +12,7 @@
> >  #include "qom/object.h"
> >  #include "qom/object_interfaces.h"
> >  #include "qapi/error.h"
> > +#include "qapi/qapi-commands-tldr.h"
> >  
> >  struct QTLDRConfig {
> >      Object parent;
> > @@ -436,3 +437,34 @@ qtldr_crash_dump_signal(siginfo_t *si)
> >          close(fd);
> >      }
> >  }
> > +
> > +
> > +/*
> > + * WARNING: Code below this marker provides a QMP handler
> > + * WARNING: for use in normal execution. It calls into
> > + * WARNING: the common crash report outputting APIs, but
> > + * WARNING: this specific method is not restricted to async
> > + * WARNING: signal safe POSIX functions.
> > + */
> 
> Why is this a WARNING WARNING WARNING?  Looks scary, then isn't.
> 
> Put it elsewhere, so the comment isn't needed?

Hmm, yes, we could split the file into separate pieces for
different contexts.

> 
> > +
> > +
> > +void
> > +qmp_tldr_dump(const char *target, Error **errp)
> > +{
> > +    int fd;
> > +
> > +    if (!qatomic_read(&qtldr_active)) {
> > +        error_setg(errp, "No 'tldr-config' object has been creted");
> > +        return;
> > +    }
> > +
> > +    fd = qemu_create(target, O_WRONLY | O_TRUNC, 0600, errp);
> > +    if (fd < 0) {
> > +        return;
> > +    }
> > +
> > +    qtldr_crash_dump_internal(fd, NULL);
> > +
> > +    qemu_fdatasync(fd);
> > +    close(fd);
> > +}
> 

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 :|



  reply	other threads:[~2026-10-29 15:38 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
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é [this message]
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=auNoU5fM0z2yBHGY@redhat.com \
    --to=berrange@redhat.com \
    --cc=armbru@redhat.com \
    --cc=dave@treblig.org \
    --cc=eblake@redhat.com \
    --cc=farosas@suse.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox