dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

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

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