|
| From: | Gerd Hoffmann |
| Subject: | Re: [Qemu-devel] [PATCH 15/17] virtio-serial: Apps should consume all data that guest sends out / Fix virtio api abuse |
| Date: | Wed, 31 Mar 2010 15:53:59 +0200 |
| User-agent: | Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8) Gecko/20100301 Fedora/3.0.3-1.fc12 Thunderbird/3.0.3 |
/* 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
| [Prev in Thread] | Current Thread | [Next in Thread] |