|
|
22d63f |
From 4e6a76dd0e35b00e9592a53afc8cffac4cc35951 Mon Sep 17 00:00:00 2001
|
|
|
22d63f |
Message-Id: <4e6a76dd0e35b00e9592a53afc8cffac4cc35951.1354903384.git.crobinso@redhat.com>
|
|
|
22d63f |
In-Reply-To: <9f0944a25bc1094fa7a74ac9df14e184e2c5c82d.1354903384.git.crobinso@redhat.com>
|
|
|
22d63f |
References: <9f0944a25bc1094fa7a74ac9df14e184e2c5c82d.1354903384.git.crobinso@redhat.com>
|
|
|
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 |
Signed-off-by: Cole Robinson <crobinso@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
|
|
|
22d63f |
index c921d2d..dfb1773 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);
|
|
|
22d63f |
+ 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 |
--
|
|
|
22d63f |
1.8.0
|
|
|
22d63f |
|