render / rpms / qemu

Forked from rpms/qemu 9 months ago
Clone

Blame 0410-usb-redir-Add-flow-control-support.patch

5544c1
From 539b42dbeefbf2fc7dc40ab7c1b5d9592a87d9b8 Mon Sep 17 00:00:00 2001
Justin M. Forbes d4cdad
From: Hans de Goede <hdegoede@redhat.com>
Justin M. Forbes d4cdad
Date: Tue, 19 Jul 2011 10:56:19 +0200
5544c1
Subject: [PATCH] usb-redir: Add flow control support
Justin M. Forbes d4cdad
Justin M. Forbes d4cdad
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
bd56df
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Justin M. Forbes d4cdad
---
5544c1
 hw/usb/redirect.c | 22 ++++++++++++++++++++--
5544c1
 1 file changed, 20 insertions(+), 2 deletions(-)
Justin M. Forbes d4cdad
Hans de Goede 329b58
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
5544c1
index 8b22c80..b7c7f1e 100644
Hans de Goede 329b58
--- a/hw/usb/redirect.c
Hans de Goede 329b58
+++ b/hw/usb/redirect.c
5544c1
@@ -229,12 +229,22 @@ static int usbredir_read(void *priv, uint8_t *data, int count)
Justin M. Forbes d4cdad
 static int usbredir_write(void *priv, uint8_t *data, int count)
Justin M. Forbes d4cdad
 {
Justin M. Forbes d4cdad
     USBRedirDevice *dev = priv;
Justin M. Forbes d4cdad
+    int r;
Hans de Goede 329b58
 
Justin M. Forbes d4cdad
-    if (!dev->cs->opened) {
Justin M. Forbes d4cdad
+    if (!dev->cs->opened || dev->cs->write_blocked) {
Justin M. Forbes d4cdad
         return 0;
Justin M. Forbes d4cdad
     }
Hans de Goede 329b58
 
Justin M. Forbes d4cdad
-    return qemu_chr_fe_write(dev->cs, data, count);
Justin M. Forbes d4cdad
+    r = qemu_chr_fe_write(dev->cs, data, count);
Justin M. Forbes d4cdad
+
Justin M. Forbes d4cdad
+    if (r < 0) {
Justin M. Forbes d4cdad
+        if (dev->cs->write_blocked) {
Justin M. Forbes d4cdad
+            return 0;
Justin M. Forbes d4cdad
+        }
Justin M. Forbes d4cdad
+        return -1;
Justin M. Forbes d4cdad
+    }
Justin M. Forbes d4cdad
+
Justin M. Forbes d4cdad
+    return r;
Justin M. Forbes d4cdad
 }
Hans de Goede 329b58
 
Justin M. Forbes d4cdad
 /*
5544c1
@@ -867,10 +877,18 @@ static void usbredir_chardev_event(void *opaque, int event)
Justin M. Forbes d4cdad
     }
Justin M. Forbes d4cdad
 }
Hans de Goede 329b58
 
Justin M. Forbes d4cdad
+static void usbredir_chardev_write_unblocked(void *opaque)
Justin M. Forbes d4cdad
+{
Justin M. Forbes d4cdad
+    USBRedirDevice *dev = opaque;
Justin M. Forbes d4cdad
+
Justin M. Forbes d4cdad
+    usbredirparser_do_write(dev->parser);
Justin M. Forbes d4cdad
+}
Justin M. Forbes d4cdad
+
Justin M. Forbes d4cdad
 static const QemuChrHandlers usbredir_chr_handlers = {
Justin M. Forbes d4cdad
     .fd_can_read = usbredir_chardev_can_read,
Justin M. Forbes d4cdad
     .fd_read = usbredir_chardev_read,
Justin M. Forbes d4cdad
     .fd_event = usbredir_chardev_event,
Justin M. Forbes d4cdad
+    .fd_write_unblocked = usbredir_chardev_write_unblocked,
Justin M. Forbes d4cdad
 };
Hans de Goede 329b58
 
Justin M. Forbes d4cdad
 /*
Justin M. Forbes d4cdad
-- 
5544c1
1.7.12.1
Justin M. Forbes d4cdad