qemu/0412-usb-redir-Add-flow-control-support.patch

60 lines
1.6 KiB
Diff
Raw Normal View History

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