dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

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

bd56df
From 675cb3b8588b2ad494b304998bbf035144ed99be Mon Sep 17 00:00:00 2001
bd56df
Message-Id: <675cb3b8588b2ad494b304998bbf035144ed99be.1346162949.git.crobinso@redhat.com>
bd56df
In-Reply-To: <90a59d545ad6759c105b0bfcfca70f574482584f.1346162949.git.crobinso@redhat.com>
bd56df
References: <90a59d545ad6759c105b0bfcfca70f574482584f.1346162949.git.crobinso@redhat.com>
Justin M. Forbes d4cdad
From: Amit Shah <amit.shah@redhat.com>
Justin M. Forbes d4cdad
Date: Mon, 21 Mar 2011 22:06:41 +0100
bd56df
Subject: [PATCH 108/114] virtio-console: Enable port throttling when chardev
bd56df
 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>
bd56df
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Justin M. Forbes d4cdad
---
b6dd5a
 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
-- 
b6dd5a
1.7.11.2
Justin M. Forbes d4cdad