qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH v7 4/6] char: Add qemu_chr_write_nb() for nonblo


From: Anthony Liguori
Subject: [Qemu-devel] Re: [PATCH v7 4/6] char: Add qemu_chr_write_nb() for nonblocking writes
Date: Wed, 05 May 2010 13:48:25 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091209 Fedora/3.0-4.fc12 Lightning/1.0pre Thunderbird/3.0

On 05/05/2010 01:40 PM, Gerd Hoffmann wrote:
+ 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.

The use of char drivers is dominated by a small number of use cases which include serial ports, the monitor, and QMP.

In all of those cases, the devices can and should participate in control flow. IMHO, we should make control flow part of the standard interface and fix all users appropriately.

I've seen blocking result in frozen guests many times in real deployments. It's never the right thing to do as far as I can tell.

Regards,

Anthony Liguori

cheers,
  Gerd






reply via email to

[Prev in Thread] Current Thread [Next in Thread]