qemu/0409-virtio-console-Enable-port-throttling-when-chardev-i.patch

51 lines
1.6 KiB
Diff
Raw Normal View History

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