Blame 0008-virtio-console-Enable-port-throttling-when-chardev-i.patch

Justin M. Forbes fc5c27
>From 8750ea70a68e74ca3ecea6149d1d5289cc77dae3 Mon Sep 17 00:00:00 2001
3f1f29
From: Amit Shah <amit.shah@redhat.com>
3f1f29
Date: Mon, 21 Mar 2011 22:06:41 +0100
Justin M. Forbes fc5c27
Subject: [PATCH 08/28] virtio-console: Enable port throttling when chardev is
3f1f29
 slow to consume data
3f1f29
3f1f29
When a chardev indicates it can't accept more data, we tell the
3f1f29
virtio-serial code to stop sending us any more data till we tell
3f1f29
otherwise.  This helps in guests continuing to run normally while the vq
3f1f29
keeps getting full and eventually the guest stops queueing more data.
3f1f29
As soon as the chardev indicates it can accept more data, start pushing!
3f1f29
3f1f29
Signed-off-by: Amit Shah <amit.shah@redhat.com>
3f1f29
---
3f1f29
 hw/virtio-console.c |   11 +++++++++++
3f1f29
 1 files changed, 11 insertions(+), 0 deletions(-)
3f1f29
3f1f29
diff --git a/hw/virtio-console.c b/hw/virtio-console.c
Justin M. Forbes 5e10b1
index cfc3087..b91f46e 100644
3f1f29
--- a/hw/virtio-console.c
3f1f29
+++ b/hw/virtio-console.c
Justin M. Forbes 5e10b1
@@ -20,6 +20,16 @@ typedef struct VirtConsole {
3f1f29
     CharDriverState *chr;
3f1f29
 } VirtConsole;
3f1f29
 
3f1f29
+/*
3f1f29
+ * Callback function that's called from chardevs when backend becomes
3f1f29
+ * writable.
3f1f29
+ */
3f1f29
+static void chr_write_unblocked(void *opaque)
3f1f29
+{
3f1f29
+    VirtConsole *vcon = opaque;
3f1f29
+
3f1f29
+    virtio_serial_throttle_port(&vcon->port, false);
3f1f29
+}
3f1f29
 
3f1f29
 /* Callback function that's called when the guest sends us data */
3f1f29
 static ssize_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)
Justin M. Forbes 5e10b1
@@ -99,6 +109,7 @@ static const QemuChrHandlers chr_handlers = {
3f1f29
     .fd_can_read = chr_can_read,
3f1f29
     .fd_read = chr_read,
3f1f29
     .fd_event = chr_event,
3f1f29
+    .fd_write_unblocked = chr_write_unblocked,
3f1f29
 };
3f1f29
 
3f1f29
 static int virtconsole_initfn(VirtIOSerialPort *port)
3f1f29
-- 
3f1f29
1.7.5.1
3f1f29