summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmit Shah <amit.shah@redhat.com>2011-03-21 22:06:41 +0100
committerHans de Goede <hdegoede@redhat.com>2011-05-02 18:16:27 +0200
commit176ff5d6ce9b457b052618ce825c7ef392de6cff (patch)
treebc23b0e77304f8853f01d4730f200903f4c08b99
parent3e2ac29f3ea82c9825644ae4cc89f349bbcce07b (diff)
virtio-console: Enable port throttling when chardev is slow to consume data
When a chardev indicates it can't accept more data, we tell the virtio-serial code to stop sending us any more data till we tell otherwise. This helps in guests continuing to run normally while the vq keeps getting full and eventually the guest stops queueing more data. As soon as the chardev indicates it can accept more data, start pushing! Signed-off-by: Amit Shah <amit.shah@redhat.com>
-rw-r--r--hw/virtio-console.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/hw/virtio-console.c b/hw/virtio-console.c
index e204be26a0..fe12760d15 100644
--- a/hw/virtio-console.c
+++ b/hw/virtio-console.c
@@ -19,6 +19,16 @@ typedef struct VirtConsole {
CharDriverState *chr;
} VirtConsole;
+/*
+ * Callback function that's called from chardevs when backend becomes
+ * writable.
+ */
+static void chr_write_unblocked(void *opaque)
+{
+ VirtConsole *vcon = opaque;
+
+ virtio_serial_throttle_port(&vcon->port, false);
+}
/* Callback function that's called when the guest sends us data */
static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)
@@ -62,6 +72,7 @@ static const QemuChrHandlers chr_handlers = {
.fd_can_read = chr_can_read,
.fd_read = chr_read,
.fd_event = chr_event,
+ .fd_write_unblocked = chr_write_unblocked,
};
static int generic_port_init(VirtConsole *vcon, VirtIOSerialPort *port)