[PATCH spice-server 1/2] test-stream-device: Better Qemu emulation for data reading

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Qemu does not trigger a new data read if we don't read all data in
the buffer.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 server/stream-device.c            | 6 ++++++
 server/tests/test-stream-device.c | 8 ++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

Maybe would be better to use a loop inside stream_device_read_msg_from_dev
instead of calling red_char_device_wakeup ?

diff --git a/server/stream-device.c b/server/stream-device.c
index 4eaa959b..18fee2e8 100644
--- a/server/stream-device.c
+++ b/server/stream-device.c
@@ -123,6 +123,12 @@ stream_device_read_msg_from_dev(RedCharDevice *self, SpiceCharDeviceInstance *si
         dev->hdr_pos = 0;
     }
 
+    // Qemu put the device on blocking state if we don't read all data
+    // so schedule another read.
+    // We arrive here only if we have an error or we are reading data
+    // so we can't cause a tighly loop here
+    red_char_device_wakeup(self);
+
     return NULL;
 }
 
diff --git a/server/tests/test-stream-device.c b/server/tests/test-stream-device.c
index 656bf56b..f937e30b 100644
--- a/server/tests/test-stream-device.c
+++ b/server/tests/test-stream-device.c
@@ -68,8 +68,12 @@ static int vmc_read(SPICE_GNUC_UNUSED SpiceCharDeviceInstance *sin,
     pos += ret;
     // kick off next message read
     // currently Qemu kicks the device so we need to do it manually
-    // here
-    spice_server_char_device_wakeup(&vmc_instance);
+    // here. If not all data are read the device goes into blocking
+    // state and we get the wake only when we read from the device
+    // again
+    if (pos >= *message_sizes_curr) {
+        spice_server_char_device_wakeup(&vmc_instance);
+    }
     return ret;
 }
 
-- 
2.14.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]