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.tan...@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