All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: "Marc-André Lureau" <marcandre.lureau@gmail.com>
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
	qemu-devel@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	qemu-stable@nongnu.org
Subject: Re: [PATCH v2 7/9] chardev/char: Preserve %errno in qemu_chr_write()
Date: Tue, 28 Oct 2025 14:19:52 +0000	[thread overview]
Message-ID: <aQDRCOXmeKAmyGeL@redhat.com> (raw)
In-Reply-To: <CAJ+F1CJj+00rCtuNkpSfcFN5Amvbe_JiKAXQ8XnBcOHcL5Duaw@mail.gmail.com>

On Tue, Oct 28, 2025 at 06:00:33PM +0400, Marc-André Lureau wrote:
> Hi
> 
> On Wed, Oct 22, 2025 at 7:10 PM Philippe Mathieu-Daudé
> <philmd@linaro.org> wrote:
> >
> > qemu_chr_write() dispatches to ChardevClass::chr_write(),
> > and is expected to propagate the backend error, not some
> > unrelated one produce by "best effort" logfile or replay.
> > Preserve and return the relevant %errno.
> 
> Indeed.. imho we should avoid using errno, it's too easy to clutter.
> Even qemu mutex, which may use trace, may change it...
> 
> patch lgtm anyway
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

Given you say 'qemu mutex, which may use trace, may change it...'
then surely this patch is broken....


> > @@ -154,6 +156,7 @@ static int qemu_chr_write_buffer(Chardev *s,
> >           */
> >          qemu_chr_write_log(s, buf, len);
> >      }
> > +    errno = saved_errno;
> >      qemu_mutex_unlock(&s->chr_write_lock);

^^^ This mutex_unlock call may clobber 'errno' that we've just tried
to restore.

> >
> >      return res;

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2025-10-28 14:21 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-22 15:07 [PATCH v2 0/9] chardev: Improve @docstring and clarify qemu_chr_write() uses Philippe Mathieu-Daudé
2025-10-22 15:07 ` [PATCH v2 1/9] chardev/char-fe: Improve @docstrings Philippe Mathieu-Daudé
2025-10-22 15:07 ` [PATCH v2 2/9] chardev/char-io: Add @docstrings for io_channel_send[_full]() Philippe Mathieu-Daudé
2025-10-22 15:07 ` [PATCH v2 3/9] chardev/char: Improve ChardevClass::chr_write() docstring Philippe Mathieu-Daudé
2025-10-28 13:30   ` Marc-André Lureau
2025-10-22 15:07 ` [PATCH v2 4/9] chardev/char: Document qemu_chr_write[_all]() Philippe Mathieu-Daudé
2025-10-28 13:32   ` Marc-André Lureau
2025-10-22 15:07 ` [PATCH v2 5/9] chardev/char-pty: Do not ignore chr_write() failures Philippe Mathieu-Daudé
2025-10-28 13:44   ` Marc-André Lureau
2025-11-12 12:51     ` Philippe Mathieu-Daudé
2025-10-22 15:07 ` [PATCH v2 6/9] chardev/char: Allow partial writes in qemu_chr_write() Philippe Mathieu-Daudé
2025-10-28 13:53   ` Marc-André Lureau
2025-10-22 15:07 ` [PATCH v2 7/9] chardev/char: Preserve %errno " Philippe Mathieu-Daudé
2025-10-22 15:14   ` Philippe Mathieu-Daudé
2025-10-28 14:25     ` Peter Maydell
2025-11-12  8:33       ` Philippe Mathieu-Daudé
2025-10-28 14:00   ` Marc-André Lureau
2025-10-28 14:19     ` Daniel P. Berrangé [this message]
2025-10-22 15:07 ` [PATCH v2 8/9] chardev/char-hub: Retry when qemu_chr_fe_write() can not write Philippe Mathieu-Daudé
2025-10-28 14:04   ` Marc-André Lureau
2025-10-22 15:07 ` [PATCH v2 9/9] hw/char: Simplify when qemu_chr_fe_write() could " Philippe Mathieu-Daudé
2025-10-28 14:07   ` Marc-André Lureau
2025-10-22 15:16 ` [PATCH v2 0/9] chardev: Improve @docstring and clarify qemu_chr_write() uses Philippe Mathieu-Daudé

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=aQDRCOXmeKAmyGeL@redhat.com \
    --to=berrange@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=marcandre.lureau@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@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.