qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [RFC] contrib: add vhost-user-sim


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [RFC] contrib: add vhost-user-sim
Date: Wed, 9 Oct 2019 15:00:21 +0100
User-agent: Mutt/1.12.1 (2019-06-15)

On Mon, Sep 23, 2019 at 11:33:41AM +0200, Johannes Berg wrote:
> On Mon, 2019-09-23 at 10:25 +0100, Stefan Hajnoczi wrote:
> Note, I'm not happy with this code at all, it deadlocks all the time.
> Unfortunately I haven't really been able to figure out how to make glib
> do what I wanted.
> 
> The first issue is that sometimes glib actually seems to reports an FD
> as readable when it's not, so I even put them into non-blocking mode :(

Strange.  Spurious wakeups are possible in general.  I think when using
fd monitoring (select(), poll(), etc) the fds should be in non-blocking
mode.

But if you're seeing this often it makes me wonder if something else is
unintentionally reading available bytes...

> The second is that I can't seem to understand how to do recursive
> mainloops.
> 
> To really do this *well*, it should remain a single-threaded
> application, but would need a hook like
> 
> run_mainloop_until_fd_readable(vdev->call_fd)
> 
> inside the libvhost-user.c code, and that's a bit ugly ... if I even
> could figure out how to implement that in glib.

Recursive mainloops are tricky since usually event loop code isn't
written to be re-entrant.  It opens up a whole new dimension that
existing code usually wasn't designed for.  In this case you are writing
the code from scratch so maybe you can get it to work, but it makes me
wonder why the recursive mainloop is necessary.

Stefan

Attachment: signature.asc
Description: PGP signature


reply via email to

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