a81953e
From f86c044ae075d142e658e866572eb0a37ecad2e1 Mon Sep 17 00:00:00 2001
a81953e
From: Alon Levy <alevy@redhat.com>
a81953e
Date: Thu, 22 Jul 2010 00:21:18 +0300
a81953e
Subject: [PATCH 29/39] spice-vmc: split vmc_write to max sized virtio_serial_write calls
a81953e
a81953e
workaround for current windows driver limitation (RHBZ 617000)
a81953e
---
a81953e
 hw/spice-vmc.c |   21 ++++++++++++++++++---
a81953e
 1 files changed, 18 insertions(+), 3 deletions(-)
a81953e
a81953e
diff --git a/hw/spice-vmc.c b/hw/spice-vmc.c
a81953e
index 041f243..b9d64a2 100644
a81953e
--- a/hw/spice-vmc.c
a81953e
+++ b/hw/spice-vmc.c
a81953e
@@ -21,6 +21,8 @@
a81953e
 #define VMC_GUEST_DEVICE_NAME "com.redhat.spice.0"
a81953e
 #define VMC_DEVICE_NAME       "spicevmc"
a81953e
a81953e
+#define VMC_MAX_HOST_WRITE    2048
a81953e
+
a81953e
 #define dprintf(_svc, _level, _fmt, ...)                                \
a81953e
     do {                                                                \
a81953e
         static unsigned __dprintf_counter = 0;                          \
a81953e
@@ -43,10 +45,23 @@ typedef struct SpiceVirtualChannel {
a81953e
 static int vmc_write(SpiceVDIPortInstance *sin, const uint8_t *buf, int len)
a81953e
 {
a81953e
     SpiceVirtualChannel *svc = container_of(sin, SpiceVirtualChannel, sin);
a81953e
-    ssize_t out;
a81953e
+    ssize_t out = 0;
a81953e
+    ssize_t last_out;
a81953e
+    uint8_t* p = (uint8_t*)buf;
a81953e
+
a81953e
+    while (len > 0) {
a81953e
+        last_out = virtio_serial_write(&svc->port, p,
a81953e
+                            MIN(len, VMC_MAX_HOST_WRITE));
a81953e
+        if (last_out > 0) {
a81953e
+            out += last_out;
a81953e
+            len -= last_out;
a81953e
+            p += last_out;
a81953e
+        } else {
a81953e
+            break;
a81953e
+        }
a81953e
+    }
a81953e
a81953e
-    out = virtio_serial_write(&svc->port, buf, len);
a81953e
-    dprintf(svc, 3, "%s: %lu/%d\n", __func__, out, len);
a81953e
+    dprintf(svc, 3, "%s: %lu/%zd\n", __func__, out, len + out);
a81953e
     return out;
a81953e
 }
a81953e
a81953e
-- 
a81953e
1.7.2.3
a81953e