/* Callback function that's called when the guest sends us data */
-static size_t flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)
+static void flush_buf(VirtIOSerialPort *port, const uint8_t *buf, size_t len)
  {
      VirtConsole *vcon = DO_UPCAST(VirtConsole, port, port);
-    ssize_t ret;

-    ret = qemu_chr_write(vcon->chr, buf, len);
-
-    return ret<  0 ? 0 : ret;
+    qemu_chr_write(vcon->chr, buf, len);
  }

Ok, so we loose data in case qemu_chr_write wasn't able to write out all data? Nice opportunity to show flow control in action here ;)

On failed+partial writes just put the remaining data into a buffer and throttle the port until all buffered data has been successfully written to the chardev.

Incremental patch is fine to avoid the chicken-egg issue (throttling is added by patch #17).

cheers,
  Gerd


Reply via email to