Patchwork [RFC] virtio-console fails on unconnected pty

login
register
mail settings
Submitter Christian Borntraeger
Date Dec. 15, 2011, 12:44 p.m.
Message ID <4EE9EBB9.9020300@de.ibm.com>
Download mbox | patch
Permalink /patch/131589/
State New
Headers show

Comments

Christian Borntraeger - Dec. 15, 2011, 12:44 p.m.
Amit,

when I tried qemu with -virtio-console pty the guest hangs and attaching on /dev/pts/<x> does
not return anything if the attachement is too late.
Turns out that the console is already throttled and the guest is heavily spinning but get_buf
never returns the buffer. There seems to be no way for the console to unthrottle the port.

For the virtio-serial use case we dont want to loose data but for the console we better drop 
data instead of "killing" the guest console. The old serial console also drops data after a 
retry, so what about dropping data righ away if no listener is connected to the pty?

This experimental patch seems to help. Makes sense?

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Amit Shah - Dec. 16, 2011, 9:23 a.m.
Hi Christian,

On (Thu) 15 Dec 2011 [13:44:41], Christian Borntraeger wrote:
> Amit,
> 
> when I tried qemu with -virtio-console pty the guest hangs and attaching on /dev/pts/<x> does
> not return anything if the attachement is too late.

Unfortunately we don't yet have chardevs to signal to frontends that
they're writable again.  This leads to things staying blocked, and
guests spinning.  (At least Fedora has patches that mitigate this
situation, after upstream acceptance of the patches failed.)

> Turns out that the console is already throttled and the guest is heavily spinning but get_buf
> never returns the buffer. There seems to be no way for the console to unthrottle the port.

Hm, looks like pty open/close notifications might be broken if you
never attached a pty to a console but the guest sent out stuff to the
host anyway.

> For the virtio-serial use case we dont want to loose data but for the console we better drop 
> data instead of "killing" the guest console. The old serial console also drops data after a 
> retry, so what about dropping data righ away if no listener is connected to the pty?

This should be temporary, though.  Once chardevs can notify frontends
about the ability to consume more data, this patch should be reverted,
right?

> This experimental patch seems to help. Makes sense?

If it's a temporary thing, I don't mind.  Can you please re-submit
without the RFC tag and perhaps a comment below to make explicit why
we're doing this?

> --- a/hw/virtio-serial-bus.c
> +++ b/hw/virtio-serial-bus.c
> @@ -163,7 +163,9 @@ static void do_flush_queued_data(VirtIOSerialPort *port, VirtQueue *vq,
>                  abort();
>              }
>              if (ret == -EAGAIN || (ret >= 0 && ret < buf_size)) {
> -                virtio_serial_throttle_port(port, true);
> +                if (!info->is_console) {
> +                    virtio_serial_throttle_port(port, true);
> +                }
>                  port->iov_idx = i;
>                  if (ret > 0) {
>                      port->iov_offset += ret;
> 

		Amit

Patch

--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -163,7 +163,9 @@  static void do_flush_queued_data(VirtIOSerialPort *port, VirtQueue *vq,
                 abort();
             }
             if (ret == -EAGAIN || (ret >= 0 && ret < buf_size)) {
-                virtio_serial_throttle_port(port, true);
+                if (!info->is_console) {
+                    virtio_serial_throttle_port(port, true);
+                }
                 port->iov_idx = i;
                 if (ret > 0) {
                     port->iov_offset += ret;