render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame qemu-virtio-console-unconnected-pty.patch

9e4ae0
commit ed8e5a85a1741147ce06932b478a509ce3407061
9e4ae0
Author: Christian Borntraeger <borntraeger@de.ibm.com>
9e4ae0
Date:   Thu Dec 29 13:47:43 2011 +0100
9e4ae0
9e4ae0
    virtio-console: Fix failure on unconnected pty
9e4ae0
    
9e4ae0
    when I tried qemu with -virtio-console pty the guest hangs and attaching
9e4ae0
    on /dev/pts/<x> does not return anything if the attachment is too late.
9e4ae0
    
9e4ae0
    This results in pty_chr_write() returning 0, which causes the port to
9e4ae0
    get throttled. This results in the guest getting frozen as the
9e4ae0
    guest->host virtio_console writes don't return until the host releases
9e4ae0
    the vq element back to the guest.
9e4ae0
    
9e4ae0
    For the virtio-serial use case we don't want to lose data but for the
9e4ae0
    console case we better drop data instead of "killing" the guest
9e4ae0
    console. If we get chardev->frontend notification and a better behaving
9e4ae0
    virtio-console we can revert this fix.
9e4ae0
    
9e4ae0
    Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
9e4ae0
    Signed-off-by: Amit Shah <amit.shah@redhat.com>
9e4ae0
9e4ae0
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
9e4ae0
index fe0233f..3a9004a 100644
9e4ae0
--- a/hw/virtio-serial-bus.c
9e4ae0
+++ b/hw/virtio-serial-bus.c
9e4ae0
@@ -163,7 +163,19 @@ static void do_flush_queued_data(VirtIOSerialPort *port, VirtQueue *vq,
9e4ae0
                 abort();
9e4ae0
             }
9e4ae0
             if (ret == -EAGAIN || (ret >= 0 && ret < buf_size)) {
9e4ae0
-                virtio_serial_throttle_port(port, true);
9e4ae0
+		/*
9e4ae0
+                 * this is a temporary check until chardevs can signal to
9e4ae0
+                 * frontends that they are writable again. This prevents
9e4ae0
+                 * the console from going into throttled mode (forever)
9e4ae0
+                 * if virtio-console is connected to a pty without a
9e4ae0
+                 * listener. Otherwise the guest spins forever.
9e4ae0
+                 * We can revert this if
9e4ae0
+                 * 1: chardevs can notify frondends
9e4ae0
+                 * 2: the guest driver does not spin in these cases
9e4ae0
+                 */
9e4ae0
+                if (!info->is_console) {
9e4ae0
+                    virtio_serial_throttle_port(port, true);
9e4ae0
+                }
9e4ae0
                 port->iov_idx = i;
9e4ae0
                 if (ret > 0) {
9e4ae0
                     port->iov_offset += ret;