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

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