Blame 0029-spice-vmc-split-vmc_write-to-max-sized-virtio_serial.patch

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