+ return s->chr_write_nb(s, buf, len);
+}
I really dislike the idea of adding another function for this.
Having a explicit function for non-blocking mode IMHO is much better.
It makes things more clear when reading the code.
Previous approach was to check for O_NONBLOCK (extra syscall) and behave
differently depending on whenever it is set or not (too much hidden magic).
Can you
explain why you need this functionality for virtio-console and why this
functionality isn't needed for everything else?
virtio-console is just the first user. 16550 emulation can use that
too. With the blocking interface you'll stall the guest (sitting in the
blocking write syscall) in case the outgoing pipe is full. With the
non-blocking interface you can simply delay the "you can send more data"
signal (update status register + raise IRQ) until you can actually
accept more data. Meanwhile the guest can continue to run and do
something else. Basically it allows to implement sane flow control.
cheers,
Gerd