* [Qemu-devel] [PATCH] pty: Fix byte loss bug when connecting to pty
@ 2014-07-28 11:39 Sebastian Tanase
2014-07-28 12:59 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Tanase @ 2014-07-28 11:39 UTC (permalink / raw)
To: qemu-devel; +Cc: Sebastian Tanase, aliguori
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);
}
--
2.0.0.rc2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] pty: Fix byte loss bug when connecting to pty
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
2014-09-02 14:48 ` Michael Roth
0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2014-07-28 12:59 UTC (permalink / raw)
To: Sebastian Tanase, qemu-devel; +Cc: Gerd Hoffmann, aliguori, qemu-stable
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] pty: Fix byte loss bug when connecting to pty
2014-07-28 12:59 ` Paolo Bonzini
@ 2014-09-02 14:48 ` Michael Roth
0 siblings, 0 replies; 3+ messages in thread
From: Michael Roth @ 2014-09-02 14:48 UTC (permalink / raw)
To: Paolo Bonzini, Sebastian Tanase, qemu-devel
Cc: Gerd Hoffmann, aliguori, qemu-stable
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 <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?
Ping for qemu-stable 2.1.1, freeze is tomorrow.
>
> Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-09-02 14:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2014-09-02 14:48 ` Michael Roth
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).