From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOpO7-0007uX-As for qemu-devel@nongnu.org; Tue, 02 Sep 2014 10:48:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XOpNz-00039T-A0 for qemu-devel@nongnu.org; Tue, 02 Sep 2014 10:48:51 -0400 Received: from e8.ny.us.ibm.com ([32.97.182.138]:45547) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOpNz-00039B-5d for qemu-devel@nongnu.org; Tue, 02 Sep 2014 10:48:43 -0400 Received: from /spool/local by e8.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 2 Sep 2014 10:48:40 -0400 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: <53D64927.3000604@redhat.com> References: <1406547554-7968-1-git-send-email-sebastian.tanase@openwide.fr> <53D64927.3000604@redhat.com> Message-ID: <20140902144834.16792.75208@loki> Date: Tue, 02 Sep 2014 09:48:34 -0500 Subject: Re: [Qemu-devel] [PATCH] pty: Fix byte loss bug when connecting to pty List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , Sebastian Tanase , qemu-devel@nongnu.org Cc: Gerd Hoffmann , aliguori@amazon.com, qemu-stable@nongnu.org Quoting Paolo Bonzini (2014-07-28 07:59:19) > 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 > > --- > > = > > 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, co= nst 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? Ping for qemu-stable 2.1.1, freeze is tomorrow. > = > Paolo