|
|
b6dd5a |
From 596c901c52b211425afe4d40e361d3ee1e5ec4bc 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
|
|
|
b6dd5a |
Subject: [PATCH] virtio-console: Enable port throttling when chardev is slow
|
|
|
b6dd5a |
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>
|
|
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 |
--
|
|
|
b6dd5a |
1.7.11.2
|
|
Justin M. Forbes |
d4cdad |
|