[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] pty: Fix byte loss bug when connecting to pty
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH] pty: Fix byte loss bug when connecting to pty |
Date: |
Mon, 28 Jul 2014 14:59:19 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
Il 28/07/2014 13:39, Sebastian Tanase ha scritto:
> When trying to print data to the pty, we first check if it is connected.
> If not, we try to reconnect, but we drop the pending data even if we
> have successfully reconnected; this makes us lose the first byte of the very
> first transmission.
> This small fix addresses the issue by checking once more if the pty is
> connected
> after having tried to reconnect.
>
> Signed-off-by: Sebastian Tanase <address@hidden>
> ---
>
> To reproduce the bug, launch a qemu image that has a parallel port (say lp0)
> and redirect it to a pty (-parallel pty). After the VM is launched,
> open the corresponding pty on your host (cat /dev/pts/X) and send some
> data from the VM to the host: echo "abcd" > /dev/lp0
> The first time, the received string will be "bcd" instead of "abcd".
> This bug can have important consequences if you try, for example,
> to send a postscript file from a printer within the VM. Losing the
> first character will render the .ps file unusable.
> ---
> qemu-char.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/qemu-char.c b/qemu-char.c
> index 7acc03f..ce52d0f 100644
> --- a/qemu-char.c
> +++ b/qemu-char.c
> @@ -1160,7 +1160,9 @@ static int pty_chr_write(CharDriverState *chr, const
> uint8_t *buf, int len)
> if (!s->connected) {
> /* guest sends data, check for (re-)connect */
> pty_chr_update_read_handler_locked(chr);
> - return 0;
> + if (!s->connected) {
> + return 0;
> + }
> }
> return io_channel_send(s->fd, buf, len);
> }
>
Looks ok, though only for 2.2 and 2.1.1. Gerd, can you take care of
this patch?
Paolo