Skip to contentSkip to conversation

Start a contrib/libvhost-user

PATCH Superseded Marc-André Lureau 1 participant 1 message Oct 18, 2016

lore
Share & tools
lore
#0 lore raw

v2 cover Start a contrib/libvhost-user

Hi

vhost-user & virtio have tricky corners and evolve regularly. There isn't a reference code that would help you get started either. And the backends duplicate most of the effort.

Furthermore, due to usage of ancillary data, shared memory, eventfd, atomics, it is not so simple to implement in other languages than C either. Having a library doing the low-level parts could eventually help to reach other languages (this guided some decisions, such as being able to override message handling)

I found it would help me to experiment with new usages of libvhost-user (with other devices than network for example) if qemu would provide such "reference" library. vhost-user-bridge was the most complete attempt at implementing vhost-user slave in qemu, but it lacked some abstraction and efficient handling of the virt queues.

I propose to provide such library based on virtio.c implementation and vhost-user-bridge socket handling. It is not meant to be complete, or solve all use cases (best efficiency, or multi-threading support are not a goal for this first implementation). My hope is that at some point the library would be complete and stable enough that it could become a standalone project, that could cover most use cases. For now it makes more sense to propose it in qemu/contrib as an internal library where API could evolve.

Comments welcome!

v2:
- add documentation
- updated to follow latest virtio queue qemu implementation
- rename add_watch() to set_watch()
- various fixes from Felipe Franciosi

rfc->v1:
- add vu_gpa_to_va()
- fix indirect descriptors handling
- fix notification
- more error handling
- disable debugging

Marc-André Lureau (6):
tests/vhost-user-bridge: remove false comment tests/vhost-user-bridge: remove unnecessary dispatcher_remove tests/vhost-user-bridge: indicate peer disconnected tests/vhost-user-bridge: do not accept more than one connection
contrib: add libvhost-user
tests/vhost-user-bridge: use contrib/libvhost-user

 contrib/libvhost-user/libvhost-user.c | 1499 +++++++++++++++++++++++++++++++++
 tests/vhost-user-bridge.c             | 1183 +++++---------------------
 Makefile                              |    1 +
 Makefile.objs                         |    2 +-
 contrib/libvhost-user/Makefile.objs   |    1 +
 tests/Makefile.include                |    2 +-
 contrib/libvhost-user/libvhost-user.h |  435 ++++++++++
 7 files changed, 2167 insertions(+), 956 deletions(-)
 create mode 100644 contrib/libvhost-user/libvhost-user.c
 create mode 100644 contrib/libvhost-user/Makefile.objs
 create mode 100644 contrib/libvhost-user/libvhost-user.h
Signature · 1 line
2.10.0