From: Paolo Bonzini <pbonzini@redhat.com>
To: Sebastian Tanase <sebastian.tanase@openwide.fr>, qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>,
aliguori@amazon.com, qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] pty: Fix byte loss bug when connecting to pty
Date: Mon, 28 Jul 2014 14:59:19 +0200 [thread overview]
Message-ID: <53D64927.3000604@redhat.com> (raw)
In-Reply-To: <1406547554-7968-1-git-send-email-sebastian.tanase@openwide.fr>
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 <sebastian.tanase@openwide.fr>
> ---
>
> 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
next prev parent reply other threads:[~2014-07-28 12:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-28 11:39 [Qemu-devel] [PATCH] pty: Fix byte loss bug when connecting to pty Sebastian Tanase
2014-07-28 12:59 ` Paolo Bonzini [this message]
2014-09-02 14:48 ` Michael Roth
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=53D64927.3000604@redhat.com \
--to=pbonzini@redhat.com \
--cc=aliguori@amazon.com \
--cc=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=sebastian.tanase@openwide.fr \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).