dcavalca / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

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

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