|
Justin M. Forbes |
252f3a |
>From 7a9e7aaa30abf42879d3f13b41679513045c31ec Mon Sep 17 00:00:00 2001
|
|
Justin M. Forbes |
252f3a |
From: Hans de Goede <hdegoede@redhat.com>
|
|
Justin M. Forbes |
252f3a |
Date: Tue, 22 Mar 2011 16:28:41 +0100
|
|
Justin M. Forbes |
252f3a |
Subject: [PATCH 18/18] spice-qemu-char: Fix flow control in client -> guest direction
|
|
Justin M. Forbes |
252f3a |
|
|
Justin M. Forbes |
252f3a |
In the old spice-vmc device we used to have:
|
|
Justin M. Forbes |
252f3a |
last_out = virtio_serial_write(&svc->port, p, MIN(len, VMC_MAX_HOST_WRITE));
|
|
Justin M. Forbes |
252f3a |
if (last_out > 0)
|
|
Justin M. Forbes |
252f3a |
...
|
|
Justin M. Forbes |
252f3a |
|
|
Justin M. Forbes |
252f3a |
Now in the chardev backend we have:
|
|
Justin M. Forbes |
252f3a |
last_out = MIN(len, VMC_MAX_HOST_WRITE);
|
|
Justin M. Forbes |
252f3a |
qemu_chr_read(scd->chr, p, last_out);
|
|
Justin M. Forbes |
252f3a |
if (last_out > 0) {
|
|
Justin M. Forbes |
252f3a |
...
|
|
Justin M. Forbes |
252f3a |
|
|
Justin M. Forbes |
252f3a |
Which causes us to no longer detect if the virtio port is not ready
|
|
Justin M. Forbes |
252f3a |
to receive data from us. chardev actually has a mechanism to detect this,
|
|
Justin M. Forbes |
252f3a |
but it requires a separate call to qemu_chr_can_read, before calling
|
|
Justin M. Forbes |
252f3a |
qemu_chr_read (which return void).
|
|
Justin M. Forbes |
252f3a |
|
|
Justin M. Forbes |
252f3a |
This patch uses qemu_chr_can_read to fix the flow control from client to
|
|
Justin M. Forbes |
252f3a |
guest.
|
|
Justin M. Forbes |
252f3a |
|
|
Justin M. Forbes |
252f3a |
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
|
|
Justin M. Forbes |
252f3a |
---
|
|
Justin M. Forbes |
252f3a |
spice-qemu-char.c | 11 +++++------
|
|
Justin M. Forbes |
252f3a |
1 files changed, 5 insertions(+), 6 deletions(-)
|
|
Justin M. Forbes |
252f3a |
|
|
Justin M. Forbes |
252f3a |
diff --git a/spice-qemu-char.c b/spice-qemu-char.c
|
|
Justin M. Forbes |
252f3a |
index 343146c..def713a 100644
|
|
Justin M. Forbes |
252f3a |
--- a/spice-qemu-char.c
|
|
Justin M. Forbes |
252f3a |
+++ b/spice-qemu-char.c
|
|
Justin M. Forbes |
252f3a |
@@ -38,14 +38,13 @@ static int vmc_write(SpiceCharDeviceInstance *sin, const uint8_t *buf, int len)
|
|
Justin M. Forbes |
252f3a |
|
|
Justin M. Forbes |
252f3a |
while (len > 0) {
|
|
Justin M. Forbes |
252f3a |
last_out = MIN(len, VMC_MAX_HOST_WRITE);
|
|
Justin M. Forbes |
252f3a |
- qemu_chr_read(scd->chr, p, last_out);
|
|
Justin M. Forbes |
252f3a |
- if (last_out > 0) {
|
|
Justin M. Forbes |
252f3a |
- out += last_out;
|
|
Justin M. Forbes |
252f3a |
- len -= last_out;
|
|
Justin M. Forbes |
252f3a |
- p += last_out;
|
|
Justin M. Forbes |
252f3a |
- } else {
|
|
Justin M. Forbes |
252f3a |
+ if (qemu_chr_can_read(scd->chr) < last_out) {
|
|
Justin M. Forbes |
252f3a |
break;
|
|
Justin M. Forbes |
252f3a |
}
|
|
Justin M. Forbes |
252f3a |
+ qemu_chr_read(scd->chr, p, last_out);
|
|
Justin M. Forbes |
252f3a |
+ out += last_out;
|
|
Justin M. Forbes |
252f3a |
+ len -= last_out;
|
|
Justin M. Forbes |
252f3a |
+ p += last_out;
|
|
Justin M. Forbes |
252f3a |
}
|
|
Justin M. Forbes |
252f3a |
|
|
Justin M. Forbes |
252f3a |
dprintf(scd, 3, "%s: %lu/%zd\n", __func__, out, len + out);
|
|
Justin M. Forbes |
252f3a |
--
|
|
Justin M. Forbes |
252f3a |
1.7.3.2
|
|
Justin M. Forbes |
252f3a |
|