On (Tue) Apr 06 2010 [09:36:17], Gerd Hoffmann wrote: > Hi, > >> In case of EAGAIN, the unix_write() function just kept spinning while >> attempting to write to the chardev till it succeeded. This resulted in >> a stuck VM in case a chardev had opened connection but wasn't reading >> anything from qemu. > > It spins only for non-blocking file handles. In blocking mode the write > syscall just goes sleep until it can write out data (or gets a signal).
True. I'm interesting in non-blocking files for now. >> There are two fixes for that case: >> - Poll for POLLOUT instead of directly attempting write(), which helps >> relax the CPU (and we become greener). > > No need to do that, see above. Having a poll() call in unix_write() is > wrong IMHO. So you mean just return -EAGAIN in case write returns with -EAGAIN? Yeah, makes sense. >> - If the file that we're writing to is nonblocking, return -EAGAIN to >> the caller of qemu_chr_write() so that appropriate actions can be >> taken higher up in the stack. > > Good. Amit