All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Cc: marcandre.lureau@redhat.com, pbonzini@redhat.com,
	armbru@redhat.com, eblake@redhat.com, yc-core@yandex-team.ru,
	d-tatianin@yandex-team.ru, qemu-devel@nongnu.org,
	philmd@linaro.org
Subject: Re: [PATCH v3 1/3] char: qemu_chr_write_log() use qemu_write_full()
Date: Mon, 2 Feb 2026 11:26:20 +0000	[thread overview]
Message-ID: <aYCJ3Mu9XJYnl1-r@redhat.com> (raw)
In-Reply-To: <20260201173633.413934-2-vsementsov@yandex-team.ru>

On Sun, Feb 01, 2026 at 08:36:29PM +0300, Vladimir Sementsov-Ogievskiy wrote:
> logfd is blocking, so we don't need to care about EAGAIN.
> Let's simply use qemu_write_full().

Are you sure logfd is always blocking ?  It can be an FD passed in
from outside QEMU, and off-hand, I'm not sure where we force that to
be blocking. Though we could argue it is the client't fault if they
passed a non-blocking FD to QEMU.

NB, we can *not* assume logfd is a plain file as libvirt will pass
in a pipe to send logging via virtlogd.


> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
> ---
>  chardev/char.c | 22 +++++-----------------
>  1 file changed, 5 insertions(+), 17 deletions(-)
> 
> diff --git a/chardev/char.c b/chardev/char.c
> index 3e432195a5..64006a3119 100644
> --- a/chardev/char.c
> +++ b/chardev/char.c
> @@ -82,29 +82,17 @@ void qemu_chr_be_event(Chardev *s, QEMUChrEvent event)
>      CHARDEV_GET_CLASS(s)->chr_be_event(s, event);
>  }
>  
> -/* Not reporting errors from writing to logfile, as logs are
> - * defined to be "best effort" only */
>  static void qemu_chr_write_log(Chardev *s, const uint8_t *buf, size_t len)
>  {
> -    size_t done = 0;
> -    ssize_t ret;
> -
>      if (s->logfd < 0) {
>          return;
>      }
>  
> -    while (done < len) {
> -    retry:
> -        ret = write(s->logfd, buf + done, len - done);
> -        if (ret == -1 && errno == EAGAIN) {
> -            g_usleep(100);
> -            goto retry;
> -        }
> -
> -        if (ret <= 0) {
> -            return;
> -        }
> -        done += ret;
> +    if (qemu_write_full(s->logfd, buf, len) < len) {
> +        /*
> +         * qemu_write_full() is defined with G_GNUC_WARN_UNUSED_RESULT,
> +         * but logging is best‑effort, we do ignore errors.
> +         */
>      }
>  }
>  
> -- 
> 2.52.0
> 

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:[~2026-02-02 11:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-01 17:36 [PATCH v3 0/3] char: add option to inject timestamps into logfile Vladimir Sementsov-Ogievskiy
2026-02-01 17:36 ` [PATCH v3 1/3] char: qemu_chr_write_log() use qemu_write_full() Vladimir Sementsov-Ogievskiy
2026-02-02 11:26   ` Daniel P. Berrangé [this message]
2026-02-19 18:07     ` Vladimir Sementsov-Ogievskiy
2026-02-19 18:08       ` Vladimir Sementsov-Ogievskiy
2026-02-25 16:00       ` Daniel P. Berrangé
2026-02-01 17:36 ` [PATCH v3 2/3] error-report: make real_time_iso8601() public Vladimir Sementsov-Ogievskiy
2026-02-01 17:36 ` [PATCH v3 3/3] chardev: add logtimestamp option Vladimir Sementsov-Ogievskiy
2026-02-04 13:11   ` Markus Armbruster
2026-02-11 11:33 ` [PATCH v3 0/3] char: add option to inject timestamps into logfile Marc-André Lureau

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=aYCJ3Mu9XJYnl1-r@redhat.com \
    --to=berrange@redhat.com \
    --cc=armbru@redhat.com \
    --cc=d-tatianin@yandex-team.ru \
    --cc=eblake@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=vsementsov@yandex-team.ru \
    --cc=yc-core@yandex-team.ru \
    /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.