]> git.karo-electronics.de Git - karo-tx-linux.git/commit
virtio: console: Don't block entire guest if host doesn't read data
authorAmit Shah <amit.shah@redhat.com>
Wed, 20 Oct 2010 03:15:43 +0000 (13:45 +1030)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 29 Oct 2010 04:51:39 +0000 (21:51 -0700)
commit64b4822a0e7ae4f54d3d23e860a17f5c1257e1ea
treed95684c9447d850816f0f7bc79800ec0888796bf
parent30756523ef2f21b917c7e85d2361f25488874c40
virtio: console: Don't block entire guest if host doesn't read data

commit 531295e63be8c2b8b909d7400739e8b8df60d61f upstream.

If the host is slow in reading data or doesn't read data at all,
blocking write calls not only blocked the program that called write()
but the entire guest itself.

To overcome this, let's not block till the host signals it has given
back the virtio ring element we passed it.  Instead, send the buffer to
the host and return to userspace.  This operation then becomes similar
to how non-blocking writes work, so let's use the existing code for this
path as well.

This code change also ensures blocking write calls do get blocked if
there's not enough room in the virtio ring as well as they don't return
-EAGAIN to userspace.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Acked-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/char/virtio_console.c