[PATCH v2 8/9] chardev/char-hub: Retry when qemu_chr_fe_write() can not write

Philippe Mathieu-Daudé posted 9 patches 3 weeks, 2 days ago
Maintainers: "Marc-André Lureau" <marcandre.lureau@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Alistair Francis <alistair@alistair23.me>, Peter Maydell <peter.maydell@linaro.org>, Palmer Dabbelt <palmer@dabbelt.com>
There is a newer version of this series
[PATCH v2 8/9] chardev/char-hub: Retry when qemu_chr_fe_write() can not write
Posted by Philippe Mathieu-Daudé 3 weeks, 2 days ago
When qemu_chr_fe_write() can not write to a backend and there
is no error, it might return '0' to let the caller retry.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 chardev/char-hub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/chardev/char-hub.c b/chardev/char-hub.c
index d0967c22336..4bbde9fb033 100644
--- a/chardev/char-hub.c
+++ b/chardev/char-hub.c
@@ -65,7 +65,7 @@ static int hub_chr_write(Chardev *chr, const uint8_t *buf, int len)
             continue;
         }
         r = qemu_chr_fe_write(&d->backends[i].fe, buf, len);
-        if (r < 0) {
+        if (r <= 0) {
             if (errno == EAGAIN) {
                 /* Set index and expect to be called soon on watch wake up */
                 d->be_eagain_ind = i;
-- 
2.51.0


Re: [PATCH v2 8/9] chardev/char-hub: Retry when qemu_chr_fe_write() can not write
Posted by Marc-André Lureau 2 weeks, 3 days ago
Hi

On Wed, Oct 22, 2025 at 7:10 PM Philippe Mathieu-Daudé
<philmd@linaro.org> wrote:
>
> When qemu_chr_fe_write() can not write to a backend and there
> is no error, it might return '0' to let the caller retry.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  chardev/char-hub.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/chardev/char-hub.c b/chardev/char-hub.c
> index d0967c22336..4bbde9fb033 100644
> --- a/chardev/char-hub.c
> +++ b/chardev/char-hub.c
> @@ -65,7 +65,7 @@ static int hub_chr_write(Chardev *chr, const uint8_t *buf, int len)
>              continue;
>          }
>          r = qemu_chr_fe_write(&d->backends[i].fe, buf, len);
> -        if (r < 0) {
> +        if (r <= 0) {

I don't think IO can return 0 and set errno. Can you detail a case?
thanks

>              if (errno == EAGAIN) {
>                  /* Set index and expect to be called soon on watch wake up */
>                  d->be_eagain_ind = i;
> --
> 2.51.0
>
>


-- 
Marc-André Lureau