qemu-e2k/chardev
Anton Nefedov b0a335e351 qemu-char: socket backend: disconnect on write error
Socket backend read handler should normally perform a disconnect, however
the read handler may not get a chance to run if the frontend is not ready
(qemu_chr_be_can_write() == 0).

This means that in virtio-serial frontend case if
 - the host has disconnected (giving EPIPE on socket write)
 - and the guest has disconnected (-> frontend not ready -> backend
   will not read)
 - and there is still data (frontend->backend) to flush (has to be a really
   tricky timing but nevertheless, we have observed the case in production)

This results in virtio-serial trying to flush this data continiously forming
a busy loop.

Solution: react on write error in the socket write handler.
errno is not reliable after qio_channel_writev_full(), so we may not get
the exact EPIPE, so disconnect on any error but QIO_CHANNEL_ERR_BLOCK which
io_channel_send_full() converts to errno EAGAIN.
We must not disconnect right away though, there still may be data to read
(see 4bf1cb0).

Signed-off-by: Anton Nefedov <anton.nefedov@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Daniel P. Berrange <berrange@redhat.com>
CC: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <1486045589-8074-1-git-send-email-den@openvz.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2017-02-16 14:06:55 +01:00
..
char-console.c char: move console in its own file 2017-01-31 23:31:21 +04:00
char-fd.c char: move fd chardev in its own file 2017-01-31 23:31:21 +04:00
char-fd.h char: move fd chardev in its own file 2017-01-31 23:31:21 +04:00
char-file.c char: move file chardev in its own file 2017-01-31 23:31:21 +04:00
char-io.c
char-io.h
char-mux.c
char-mux.h
char-null.c
char-parallel.c char: move parallel chardev in its own file 2017-01-31 23:31:21 +04:00
char-parallel.h char: move parallel chardev in its own file 2017-01-31 23:31:21 +04:00
char-pipe.c char: move pipe chardev in its own file 2017-01-31 23:31:21 +04:00
char-pty.c char: move pty chardev in its own file 2017-01-31 23:31:21 +04:00
char-ringbuf.c
char-serial.c char: move serial chardev to its own file 2017-01-31 23:31:21 +04:00
char-serial.h char: move serial chardev to its own file 2017-01-31 23:31:21 +04:00
char-socket.c qemu-char: socket backend: disconnect on write error 2017-02-16 14:06:55 +01:00
char-stdio.c char: move stdio in its own file 2017-01-31 23:31:21 +04:00
char-udp.c char: move udp chardev in its own file 2017-01-31 23:31:21 +04:00
char-win-stdio.c char: move win-stdio into its own file 2017-01-31 23:31:21 +04:00
char-win-stdio.h char: move win-stdio into its own file 2017-01-31 23:31:21 +04:00
char-win.c char: move win chardev base class in its own file 2017-01-31 23:31:21 +04:00
char-win.h char: move win chardev base class in its own file 2017-01-31 23:31:21 +04:00
char.c char: headers clean-up 2017-01-31 23:31:22 +04:00
Makefile.objs char: move parallel chardev in its own file 2017-01-31 23:31:21 +04:00