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