|
Justin M. Forbes |
d4cdad |
From 71108acb189f5fda923013ed72270642199ab50d 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
|
|
Justin M. Forbes |
d4cdad |
Subject: [PATCH 113/118] virtio-console: Enable port throttling when chardev
|
|
Justin M. Forbes |
d4cdad |
is slow 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 |
---
|
|
Justin M. Forbes |
d4cdad |
hw/virtio-console.c | 11 +++++++++++
|
|
Justin M. Forbes |
d4cdad |
1 files changed, 11 insertions(+), 0 deletions(-)
|
|
Justin M. Forbes |
d4cdad |
|
|
Justin M. Forbes |
d4cdad |
diff --git a/hw/virtio-console.c b/hw/virtio-console.c
|
|
Justin M. Forbes |
d4cdad |
index 6d6f3ef..da68211 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;
|
|
Justin M. Forbes |
d4cdad |
|
|
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 |
+}
|
|
Justin M. Forbes |
d4cdad |
|
|
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)
|
|
Justin M. Forbes |
d4cdad |
@@ -99,6 +109,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 |
};
|
|
Justin M. Forbes |
d4cdad |
|
|
Justin M. Forbes |
d4cdad |
static int virtconsole_initfn(VirtIOSerialPort *port)
|
|
Justin M. Forbes |
d4cdad |
--
|
|
Justin M. Forbes |
d4cdad |
1.7.7.5
|
|
Justin M. Forbes |
d4cdad |
|