render / rpms / qemu

Forked from rpms/qemu 10 months ago
Clone

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

Hans de Goede 329b58
From 738da364d19bd99b70c79cb1174eef0e19f8e368 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
Hans de Goede 329b58
Subject: [PATCH 108/114] 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 +++++++++++
Hans de Goede 329b58
 1 file changed, 11 insertions(+)
Justin M. Forbes d4cdad
Justin M. Forbes d4cdad
diff --git a/hw/virtio-console.c b/hw/virtio-console.c
Hans de Goede 329b58
index 066590c..2b5e515 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;
Hans de Goede 329b58
 
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
+}
Hans de Goede 329b58
 
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)
Hans de Goede 329b58
@@ -110,6 +120,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
 };
Hans de Goede 329b58
 
Justin M. Forbes d4cdad
 static int virtconsole_initfn(VirtIOSerialPort *port)
Justin M. Forbes d4cdad
-- 
Hans de Goede 329b58
1.7.10.4
Justin M. Forbes d4cdad