[Spice-commits] Branch 'spice.kvm.v11' - hw/spice-vmc.c

Alon Levy alon at kemper.freedesktop.org
Thu Jul 22 00:14:07 PDT 2010


 hw/spice-vmc.c |   21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

New commits:
commit 19ee79090a331fe6c4ea6e01038990c4db2d901d
Author: Alon Levy <alevy at redhat.com>
Date:   Thu Jul 22 00:21:18 2010 +0300

    spice-vmc: split vmc_write to max sized virtio_serial_write calls
    
    workaround for current windows driver limitation (RHBZ 617000)

diff --git a/hw/spice-vmc.c b/hw/spice-vmc.c
index 8e14446..bf0c06e 100644
--- a/hw/spice-vmc.c
+++ b/hw/spice-vmc.c
@@ -21,6 +21,8 @@
 #define VMC_GUEST_DEVICE_NAME "com.redhat.spice.0"
 #define VMC_DEVICE_NAME       "spicevmc"
 
+#define VMC_MAX_HOST_WRITE    2048
+
 #define dprintf(_svc, _level, _fmt, ...)                                \
     do {                                                                \
         static unsigned __dprintf_counter = 0;                          \
@@ -43,10 +45,23 @@ typedef struct SpiceVirtualChannel {
 static int vmc_write(SpiceVDIPortInstance *sin, const uint8_t *buf, int len)
 {
     SpiceVirtualChannel *svc = container_of(sin, SpiceVirtualChannel, sin);
-    ssize_t out;
+    ssize_t out = 0;
+    ssize_t last_out;
+    uint8_t* p = (uint8_t*)buf;
+
+    while (len > 0) {
+        last_out = virtio_serial_write(&svc->port, p,
+                            MIN(len, VMC_MAX_HOST_WRITE));
+        if (last_out > 0) {
+            out += last_out;
+            len -= last_out;
+            p += last_out;
+        } else {
+            break;
+        }
+    }
 
-    out = virtio_serial_write(&svc->port, buf, len);
-    dprintf(svc, 3, "%s: %lu/%d\n", __func__, out, len);
+    dprintf(svc, 3, "%s: %lu/%zd\n", __func__, out, len + out);
     return out;
 }
 


More information about the Spice-commits mailing list