qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* Replace GSource with AioContext for chardev
@ 2020-04-09 12:46 Coiby Xu
  2020-04-09 13:16 ` Marc-André Lureau
  0 siblings, 1 reply; 8+ messages in thread
From: Coiby Xu @ 2020-04-09 12:46 UTC (permalink / raw)
  To: qemu-devel, Stefan Hajnoczi, Fam Zheng, Paolo Bonzini,
	Marc-André Lureau
  Cc: Kevin Wolf


Hi,

I'm now implementing vhost-user block device backend
https://patchew.org/QEMU/20200309100342.14921-1-coiby.xu@gmail.com/
and want to use chardev to help manage vhost-user client connections
and read socket message. However there are two issues that need to be
addressed.

Firstly, chardev isn't suitable for the case when exported drive is
run in an IOThread because for mow chardev use GSource to dispatch
socket fd events. So I have to specify which IOThread the exported
drive is using when launching vhost-user block device backend,
for example, the following syntax will be used,

   -drive file=file.img,id=disk -device virtio-blk,drive=disk,iothread=iothread0 \
    -object vhost-user-blk-server,node-name=disk,chardev=mon1,iothread=iothread0 \
    -object iothread,id=iothread0 \
    -chardev socket,id=mon1,path=/tmp/vhost-user-blk_vhost.socket,server,nowait

then iothread_get_g_main_context(IOThread *iothread) has to be called
to run the gcontext in IOThread. If we use AioContext to dispatch socket
fd events, we needn't to specify IOThread twice. Besides aio_poll is faster
than g_main_loop_run.

Secondly, socket chardev's async read handler (set through
qemu_chr_fe_set_handlers) doesn't take the case of socket short read
into consideration.  I plan to add one which will make use qio_channel_yield.

According to
[1] Improving the QEMU Event Loop - Linux Foundation Events
http://events17.linuxfoundation.org/sites/events/files/slides/Improving%20the%20QEMU%20Event%20Loop%20-%203.pdf

"Convert chardev GSource to aio or an equivalent source" (p.30) should have
been finished. I'm curious why the plan didn't continue. If it's desirable,
I'm going to finish the leftover work to resolve the aforementioned two issues.

Any suggestion will be appreciated.
Thank you!


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-04-15 12:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-09 12:46 Replace GSource with AioContext for chardev Coiby Xu
2020-04-09 13:16 ` Marc-André Lureau
2020-04-09 13:24   ` Daniel P. Berrangé
2020-04-14  7:25     ` Markus Armbruster
2020-04-14 10:27       ` Daniel P. Berrangé
2020-04-14 10:54         ` Paolo Bonzini
2020-04-14 12:13           ` Kevin Wolf
2020-04-15 12:31             ` Daniel P. Berrangé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).