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

Alon Levy alon at kemper.freedesktop.org
Mon Jul 19 02:46:00 PDT 2010


 hw/spice-vmc.c |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

New commits:
commit b741523f6fb593d0ef249386f65bf937c81e24c1
Author: Alon Levy <alevy at redhat.com>
Date:   Wed Jul 14 16:30:35 2010 +0300

    spice-vmc: add counter to debug statements

diff --git a/hw/spice-vmc.c b/hw/spice-vmc.c
index 06e30e6..041f243 100644
--- a/hw/spice-vmc.c
+++ b/hw/spice-vmc.c
@@ -23,8 +23,9 @@
 
 #define dprintf(_svc, _level, _fmt, ...)                                \
     do {                                                                \
+        static unsigned __dprintf_counter = 0;                          \
         if (_svc->debug >= _level) {                                    \
-            fprintf(stderr, "svc: " _fmt, ## __VA_ARGS__);              \
+            fprintf(stderr, "svc: %3d: " _fmt, ++__dprintf_counter, ## __VA_ARGS__);\
         }                                                               \
     } while (0)
 
commit 5f80c1191503fa81c53f9b7ad6ae6da3491751d8
Author: Alon Levy <alevy at redhat.com>
Date:   Mon Jul 12 22:48:59 2010 +0300

    spice-vmc: two bugfixes in vmc_read
    
     * throttling with no discard means possible recursion, make
      vmc_read handle that.
     * zero datapos when data is done (from rhel6 version)

diff --git a/hw/spice-vmc.c b/hw/spice-vmc.c
index 3f6a2bb..06e30e6 100644
--- a/hw/spice-vmc.c
+++ b/hw/spice-vmc.c
@@ -45,7 +45,7 @@ static int vmc_write(SpiceVDIPortInstance *sin, const uint8_t *buf, int len)
     ssize_t out;
 
     out = virtio_serial_write(&svc->port, buf, len);
-    dprintf(svc, 2, "%s: %lu/%d\n", __func__, out, len);
+    dprintf(svc, 3, "%s: %lu/%d\n", __func__, out, len);
     return out;
 }
 
@@ -54,13 +54,16 @@ static int vmc_read(SpiceVDIPortInstance *sin, uint8_t *buf, int len)
     SpiceVirtualChannel *svc = container_of(sin, SpiceVirtualChannel, sin);
     int bytes = MIN(len, svc->datalen);
 
-    dprintf(svc, 2, "%s: %d/%zd\n", __func__, bytes, svc->datalen);
-    if (bytes) {
+    dprintf(svc, 2, "%s: %p %d/%d/%zd\n", __func__, svc->datapos, len, bytes, svc->datalen);
+    if (bytes > 0) {
         memcpy(buf, svc->datapos, bytes);
         svc->datapos += bytes;
         svc->datalen -= bytes;
-        if (0 == svc->datalen) {
+        assert(svc->datalen >= 0);
+        if (svc->datalen == 0) {
+            svc->datapos = 0;
             virtio_serial_throttle_port(&svc->port, false);
+            // ^^^ !!! may call vmc_have_data, so don't touch svc after it!
         }
     }
     return bytes;
@@ -140,7 +143,7 @@ static void vmc_have_data(VirtIOSerialPort *port, const uint8_t *buf, size_t len
     SpiceVirtualChannel *svc = DO_UPCAST(SpiceVirtualChannel, port, port);
 
     dprintf(svc, 2, "%s: %zd\n", __func__, len);
-    assert(svc->datapos == 0);
+    assert(svc->datalen == 0);
     if (svc->bufsize < len) {
         svc->bufsize = len;
         svc->buffer = qemu_realloc(svc->buffer, svc->bufsize);


More information about the Spice-commits mailing list