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

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