All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Alessandro Ratti <alessandro@0x65c.net>
Cc: alex.bennee@linaro.org,  alessandro.ratti@gmail.com,
	 philmd@linaro.org, qemu-devel@nongnu.org
Subject: Re: [PATCH v2] virtio: Add function name to error messages
Date: Mon, 22 Sep 2025 12:37:57 +0200	[thread overview]
Message-ID: <87h5wulqm2.fsf@pond.sub.org> (raw)
In-Reply-To: <20250915162643.44716-2-alessandro@0x65c.net> (Alessandro Ratti's message of "Mon, 15 Sep 2025 18:19:38 +0200")

Alessandro Ratti <alessandro@0x65c.net> writes:

> Replace virtio_error() with a macro that automatically prepends the
> calling function name to error messages. This provides better context
> for debugging virtio issues by showing exactly which function
> encountered the error.
>
> Before: "Invalid queue size: 1024"
> After:  "virtio_queue_set_num: Invalid queue size: 1024"
>
> The implementation uses a macro to insert __func__ at compile time,
> avoiding any runtime overhead while providing more specific error
> context than a generic "virtio:" prefix.

A need for function names and such in error messages suggests the error
messages are crap.

Consider the example above.  From users' point of view, the message
changes from gobbledygook to more verbose gobbledygook.  Was the error
the user's fault?  The guest's?  Something else's?  What can the user do
about it now?  If you need a developer to answer such questions, the
user interface is *dire*.

Clue: virtio_error() sets vdev->broken to true.  Did the device just
stop working?  If yes, shouldn't we tell the user?

Note that __func__ does not materially improve things even for developer
when the error message template string is unique.  Almost all are.

Fun example: "Region caches not initialized".  Three instances:

hw/virtio/virtio.c:        virtio_error(vdev, "Region caches not initialized");
hw/virtio/virtio.c:        virtio_error(vdev, "Region caches not initialized");
hw/virtio/virtio.c:            error_setg(errp, "Region caches not initialized");

Your patch adds __func__ in two out of three cases.  I'm not asking you
to add it to the third case, I'm only mentioning this to illustrate the
depth of the error reporting swamp around here.

I'll shut up now :)

> Also remove manual __func__ usage in virtio-balloon to avoid duplicate
> function names in error messages.
>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/230
> Buglink: https://bugs.launchpad.net/qemu/+bug/1919021
>
> Signed-off-by: Alessandro Ratti <alessandro@0x65c.net>



  parent reply	other threads:[~2025-09-22 10:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-15 10:01 [PATCH] virtio: Add function name to error messages Alessandro Ratti
2025-09-15 10:01 ` Alessandro Ratti
2025-09-15 10:35   ` Alex Bennée
2025-09-15 16:19     ` Alessandro Ratti
2025-09-15 16:19       ` [PATCH v2] " Alessandro Ratti
2025-09-22  9:33         ` Alessandro Ratti
2025-09-22  9:33           ` Alessandro Ratti
2025-09-22 10:37           ` Alex Bennée
2025-09-22 10:37         ` Markus Armbruster [this message]
2025-09-22 10:47           ` Daniel P. Berrangé
2025-09-22 11:06             ` Alex Bennée
2025-09-22 12:29               ` Markus Armbruster
2025-09-22 13:37                 ` Alessandro Ratti
2025-09-22 14:23                   ` Markus Armbruster
2025-09-23  9:42                     ` Alessandro Ratti
2025-09-23 13:33                       ` Markus Armbruster

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=87h5wulqm2.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=alessandro.ratti@gmail.com \
    --cc=alessandro@0x65c.net \
    --cc=alex.bennee@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.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.