render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

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

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