[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-arm] [PATCH 3/5] sclpconsole: remove bogus check for -EAGAIN
From: |
Cornelia Huck |
Subject: |
Re: [Qemu-arm] [PATCH 3/5] sclpconsole: remove bogus check for -EAGAIN |
Date: |
Thu, 4 Aug 2016 10:13:13 +0200 |
On Wed, 3 Aug 2016 17:22:38 +0100
"Daniel P. Berrange" <address@hidden> wrote:
s/sclpconsole/sclpconsolelm/ in the subject, as there are two sclp
consoles :)
> The write_console_data() method in sclpconsole-lm.c checks
> whether the return value of qemu_chr_fe_write() has the
> value of -EAGAIN and if so then increments the buffer offset
> by the value of EAGAIN. Fortunately qemu_chr_fe_write() will
> never return EAGAIN directly, rather it returns -1 with
> errno set to EAGAIN, so this broken code path was not
> reachable. The behaviour on EAGAIN was stil bad though,
> causing the write_console_data() to busy_wait repeatedly
> calling qemu_chr_fe_write() with no sleep between iters.
>
> Just remove all this loop logic and replace with a call
> to qemu_chr_fe_write_all().
>
> Signed-off-by: Daniel P. Berrange <address@hidden>
> ---
> hw/char/sclpconsole-lm.c | 18 +++---------------
> 1 file changed, 3 insertions(+), 15 deletions(-)
>
> diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c
> index a22ad8d..8cb0026 100644
> --- a/hw/char/sclpconsole-lm.c
> +++ b/hw/char/sclpconsole-lm.c
> @@ -201,21 +201,9 @@ static int write_console_data(SCLPEvent *event, const
> uint8_t *buf, int len)
> return len;
> }
>
> - buf_offset = buf;
> - while (len > 0) {
> - ret = qemu_chr_fe_write(scon->chr, buf, len);
> - if (ret == 0) {
> - /* a pty doesn't seem to be connected - no error */
> - len = 0;
> - } else if (ret == -EAGAIN || (ret > 0 && ret < len)) {
> - len -= ret;
> - buf_offset += ret;
> - } else {
> - len = 0;
> - }
> - }
> -
> - return ret;
> + /* XXX this blocks entire thread. Rewrite to use
> + * qemu_chr_fe_write and background I/O callbacks */
> + return qemu_chr_fe_write_all(scon->chr, buf, len);
This is basically the same change that had been done for the sclp vt220
console already in 2e14211 ("s390/sclpconsole: handle char layer busy
conditions"), so this looks fine.
> }
>
> static int process_mdb(SCLPEvent *event, MDBO *mdbo)
Acked-by: Cornelia Huck <address@hidden>
- [Qemu-arm] [PATCH 0/5] Global fix / workaround usage of qemu_chr_fe_write, Daniel P. Berrange, 2016/08/03
- [Qemu-arm] [PATCH 1/5] virtio-console: set frontend open permanently for console devs, Daniel P. Berrange, 2016/08/03
- [Qemu-arm] [PATCH 4/5] hw: replace most use of qemu_chr_fe_write with qemu_chr_fe_write_all, Daniel P. Berrange, 2016/08/03
- [Qemu-arm] [PATCH 2/5] impi: check return of qemu_chr_fe_write() for errors, Daniel P. Berrange, 2016/08/03
- [Qemu-arm] [PATCH 3/5] sclpconsole: remove bogus check for -EAGAIN, Daniel P. Berrange, 2016/08/03
- Re: [Qemu-arm] [PATCH 3/5] sclpconsole: remove bogus check for -EAGAIN,
Cornelia Huck <=
- [Qemu-arm] [PATCH 5/5] char: convert qemu_chr_fe_write to qemu_chr_fe_write_all, Daniel P. Berrange, 2016/08/03