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

6986e1
From 8f9c374199cd82c5364d8f759cd23f2f17f2911f Mon Sep 17 00:00:00 2001
22d63f
From: Hans de Goede <hdegoede@redhat.com>
22d63f
Date: Tue, 19 Jul 2011 10:56:19 +0200
22d63f
Subject: [PATCH] usb-redir: Add flow control support
22d63f
22d63f
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
22d63f
---
22d63f
 hw/usb/redirect.c | 22 ++++++++++++++++++++--
22d63f
 1 file changed, 20 insertions(+), 2 deletions(-)
22d63f
22d63f
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
6986e1
index c921d2d..56c3c24 100644
22d63f
--- a/hw/usb/redirect.c
22d63f
+++ b/hw/usb/redirect.c
22d63f
@@ -239,8 +239,9 @@ static int usbredir_read(void *priv, uint8_t *data, int count)
22d63f
 static int usbredir_write(void *priv, uint8_t *data, int count)
22d63f
 {
22d63f
     USBRedirDevice *dev = priv;
22d63f
+    int r;
22d63f
 
22d63f
-    if (!dev->cs->opened) {
22d63f
+    if (!dev->cs->opened || dev->cs->write_blocked) {
22d63f
         return 0;
22d63f
     }
22d63f
 
22d63f
@@ -249,7 +250,16 @@ static int usbredir_write(void *priv, uint8_t *data, int count)
22d63f
         return 0;
22d63f
     }
22d63f
 
22d63f
-    return qemu_chr_fe_write(dev->cs, data, count);
Hans de Goede 4e26a3
+    r = qemu_chr_fe_write(dev->cs, data, count);
22d63f
+
22d63f
+    if (r < 0) {
22d63f
+        if (dev->cs->write_blocked) {
22d63f
+           return 0;
22d63f
+        }
22d63f
+        return -1;
22d63f
+    }
22d63f
+
22d63f
+    return r;
22d63f
 }
22d63f
 
22d63f
 /*
22d63f
@@ -1037,10 +1047,18 @@ static void usbredir_chardev_event(void *opaque, int event)
22d63f
     }
22d63f
 }
22d63f
 
22d63f
+static void usbredir_chardev_write_unblocked(void *opaque)
22d63f
+{
22d63f
+    USBRedirDevice *dev = opaque;
22d63f
+
22d63f
+    usbredirparser_do_write(dev->parser);
22d63f
+}
22d63f
+
22d63f
 static const QemuChrHandlers usbredir_chr_handlers = {
22d63f
     .fd_can_read = usbredir_chardev_can_read,
22d63f
     .fd_read = usbredir_chardev_read,
22d63f
     .fd_event = usbredir_chardev_event,
22d63f
+    .fd_write_unblocked = usbredir_chardev_write_unblocked,
22d63f
 };
22d63f
 
22d63f
 /*
22d63f
-- 
6986e1
1.8.1
22d63f