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