On Wed, Dec 20, 2017 at 4:06 AM, Michael S. Tsirkin <m...@redhat.com> wrote: > On Tue, Dec 19, 2017 at 05:05:59PM +0000, Stefan Hajnoczi wrote: >> On Tue, Dec 19, 2017 at 2:56 PM, Michael S. Tsirkin <m...@redhat.com> wrote: >> >> * Please handle short reads/writes and EAGAIN with the UNIX domain >> >> socket. Do >> >> not use read/write_all() functions because they hang QEMU until I/O >> >> completes. >> > >> > I'm not sure I agree with this one. vhost-user uses this extensively >> > right now. It might be a worth-while goal to drop this limitation >> > but I don't see why we should start with vhost-pci. >> > >> > And in particular, VCPU can't make progress unless a slave is present. >> >> Hang on, we're talking about different things: >> >> The QEMU vhost-user master blocks because vhost_*() functions are >> synchronous (they don't use callbacks or yield). Fixing that is >> beyond the scope of this patch series and I'm not asking for it. >> >> This patch series adds a from-scratch vhost-user slave implementation >> which has no good reason to be blocking. A single malicious or broken >> guest must not be able to hang a vhost-pci network switch. > > Hmm that's not an easy change. But I agree, it's more important for > the switch.
It's easy, See "[PATCH v3 4/7] vhost-pci-slave: add vhost-pci slave implementation". There is only one qemu_chr_fe_read_all() call and one qemu_chr_fe_write_all() call! The read is the first thing that happens when the socket becomes readable. The write is the last thing that happens when a vhost-user protocol message has been handled. Moreover, the socket is only used in half-duplex with 1 request/response at any given time. This means most of the code will be unchanged. Only the beginning of vp_slave_read() and vp_slave_write() need to be adapted. I'm not asking for a lot. Stefan