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

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