render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

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

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