Commit Graph

17 Commits

Author SHA1 Message Date
Sebastien Boeuf
9ff42060e0 vhost_user_backend: Fix clippy issues
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-30 13:06:00 -07:00
Cathy Zhang
db151819f1 Cargo.toml: Add workspace config changes
Remove workspace from vhost_user_backend/Cargo.toml to have
vhost-user-backend compiled in cloud-hypervisor. Add workspace in
Cargo.toml to have vhost-user-backend consumed by vhost-user-net.

Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
2019-09-30 13:06:00 -07:00
Sebastien Boeuf
09392f0530 vhost_user_backend: Fix remaining issues
This commit fixes all the remaining issues that were found as part of
the integration with vhost-user-net.

It fixes the way to notify that a vring is used, by using the proper
EventFd.

It removes the process_queue() function from the trait, since the
complexity it was introducing was leading to deadlocks with mutexes.

It moves the register/unregister functions for registering custom events
from the backend, from the VringEpollHandler to the VringWorker. This
allows for a lot of simplification and solve a deadlock issue.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-30 09:26:11 -07:00
Cathy Zhang
527dd68ce1 vhost_user_backend: Update vmm_va_to_gpa with adding offset
The original logic does not has any problem without offset, since the
current offset is zero. However, if offset is not zero, while convert
vmm address to backend process address, it needs to consider the
offset.

Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
2019-09-30 09:26:11 -07:00
Cathy Zhang
4a1af7f63c vhost-user-backend: Correct error handling in run
The error handling here to trigger break epoll seems not correct,
epoll will be ended once one event is handled, no matter successfully
or failed. Fix it.

Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
2019-09-30 09:26:11 -07:00
Cathy Zhang
c4309515c9 vhost-user-backend: Remove one checking from set_features
The vhost-user protocol does not indicate set_features could not
be issued more than once, the checking is not needed at all, and
prevent communication between master and slave. Remove it to
fix the issue.

Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
2019-09-30 09:26:11 -07:00
Sebastien Boeuf
347611b0c7 vhost_user_backend: Pass a backend that can be modified
This patch modifies the library so that a consumer can update the
backend after it's been passed to the daemon.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-30 09:26:11 -07:00
Sebastien Boeuf
f14ab872ec vhost_user_backend: Give access to the EpollVringHandler
By letting the consumer of this crate getting access to the vring
handler, we will be able to let it perform several actions without
producing a deadlock.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-30 09:26:11 -07:00
Sebastien Boeuf
cfc8c39446 vhost_user_backend: Provide some default trait implementations
We cannot expect every backend to support GET_CONFIG and SET_CONFIG
commands. That's why this patch adds some default implementations for
the trait VhostUserBackend regarding both get_config() and set_config()
functions.

Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-30 09:26:11 -07:00
Sebastien Boeuf
1aab372a06 vhost_user_backend: Make the backend a server
The code needs to initialize a listener to accept connection from the
VMM being the client in this case.

Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-30 09:26:11 -07:00
Sebastien Boeuf
c1b26b1fab vhost_user_backend: Don't process disabled queues
Every time an event is triggered, it needs to be read, but only based on
the status of the vring (enabled or not) will decide if the queue needs
to be processed.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-30 09:26:11 -07:00
Sebastien Boeuf
d80ac43ef1 vhost_user_backend: Remove useless started field
The Queue structure already contains a field "ready" that can be used to
track the status of the vrings.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-30 09:26:11 -07:00
Sebastien Boeuf
5f076923d3 vhost_user_backend: Allow for proper error propagation
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-30 09:26:11 -07:00
Sebastien Boeuf
36de390caf vhost_user_backend: Make some trait functions as mutable
Let's be realistic, the trait VhostUserBackend will need to have mutable
self for some functions like handle_event, process_queue and set_config,
which is the reason why this commit needs to introduce a RwLock on the
backend instance that was passed around as a simple Arc.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-30 09:26:11 -07:00
Sebastien Boeuf
d4f7f73bc8 vhost_user_backend: Move to a per-queue RwLock
Instead of locking every queues whenever something needs to be updated,
this patch modifies the code design to lock each Vring independently.
This allows for much finer granularity, and will allow multiple queues
to be handled at the same time.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-30 09:26:11 -07:00
Sebastien Boeuf
4ed81894aa vhost_user_backend: Replace Mutex with RwLock when possible
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-30 09:26:11 -07:00
Sebastien Boeuf
2e2cad91ae vhost_user_backend: Add new crate
The purpose of this new crate is to provide a common library to all
vhost-user backend implementations. The more is handled by this library,
the less duplication will need to happen in each vhost-user daemon.

This crate relies a lot on vhost_rs, vm-memory and vm-virtio crates.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2019-09-30 09:26:11 -07:00