This release aligns its dependencies with rust-vmm's vhost
infrastructure by moving to virtio-queue v0.3.0 and relaxing the
vm-memory dependency to require ">=0.7".
Signed-off-by: Sergio Lopez <slp@redhat.com>
This allows the use of newer versions of the vm-memory crate when
combined with other dependencies.
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This release implements AsRawFd for VringEpollHandler, as well as adds a
way for running the vhost-user daemon as a client.
Both of these are required by Cloud Hypervisor to rely on the
vhost-user-backend crate.
Fixes#62
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
In order to support vhost-user client mode, we introduce a new method
start_client() to VhostUserDaemon. It allows the daemon to connect to
the VMM side running as the server in this case.
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
In order to let the consumer of the crate access directly the file
descriptor related to the VringEpollHandler, we implement the AsRawFd
trait.
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Previous patch causes dramatic code coverage decrease, it actually
disclose some issue in the code coverage test. Then we add test case
to cover VhostUserHandler, it actually increases the code coverage.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Try to increase code coverage by adding more test code. But it actually
causes dramatic decreases in code coverage:(
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Currently trait bound declarations is a little over complex when
defines traits or implements traits/structs. Let's simplfy it.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Some idea tools advises to keep all methods in the same order as trait
definition when implementation the trait for structure.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Previously VringStateGuard and VringStateMutGuard are defined as enum,
which limits the extensibility of the interface. So convert them into
traits by using the High Rank Trait Bound tricky.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Update virtio-queue dependency to the latest available version, rev
"cc1fa35". This one comes with a number of fixes and new features,
such as QueueGuard and support for big-endian machines.
Signed-off-by: Sergio Lopez <slp@redhat.com>
Commit 66cda80 ("Update vm-memory requirement from 0.6 to 0.7")
is required to build this crate with vm-memory v0.7
There were API changes since commit 6013dd9, so let's update
code and tests.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
There's a wrapper for epoll from vmm-sys-util, so use the wrapper
instead of the epoll crate directly. It may help to ease dependency
management.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
According to the vhost-user specs, we should start the vring upon
receiving the first kick, and stop it when we receive GET_VRING_BASE.
Strictly speaking, we should reset the underlying Queue on the first
kick, but it's actually easier to simply do that in GET_VRING_BASE and
be ready in case the guest re-initializes the vring.
Signed-off-by: Sergio Lopez <slp@redhat.com>
The vhost-user protocol doesn't impose an order for the SET_VRING_KICK
and SET_VRING_CALL messages, which implies it's valid to emit the
first before the latter.
With the current code, this means that if the VMM sends SET_VRING_KICK
before SET_VRING_CALL, and the guest has already placed a request into
the vring, we may miss signaling the guest as that request may be
processed before we have an EventFd for "call".
To fix this, delay listener registration until we have an EventFd for
both call and kick, using "VringState::Queue.ready" as an indicator
that the vring has not been initialized yet.
Signed-off-by: Sergio Lopez <slp@redhat.com>
In addition to bringing the features from the new vhost crate, this
fixes the breakage caused by rust-vmm/vmm-sys-util#135
Signed-off-by: Sergio Lopez <slp@redhat.com>
Backend::handle_event() takes an argument of `vrings: &[V]` with
`V: VringT`, so methods of VringT should not take `&mut self`.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Refine the way to manage epoll event id and simplify interfaces:
- Change VhostUserBackend::exit_event() to return Option<EventFd>
instead of Option<(EventFd, u16)>.
- Delete VringEpollHandler::exit_event_id.
- Add VringEpollHandler::register_event/unregister_event for internal
use.
- Make VringEpollHandler::register_listener/unregister_listener() for
external users only, and 'data` range [0..backend.num_queues()] is
reserved for queues and exit event.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Add VringT::get_mut() to get exclusive reference to underlying
VringState object, so the clients could avoid repeatedly lock/unlock
when using VringMutex and VringRwLock.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Enhance VhostUserBackend, VhostUserBackendMut, VringEpollHandler,
VhostUserHandler and VhostUserDaemon to support generic type
`V: VringT', so clients could choose different VringT implementations.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Introduce trait VringT, and provide three implementations of it:
VringState, VringMutex, VringRwLock.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
The builds are failing since the remote branch's name is changed to
main from master. Fix it by adding the rev for virtio-queue.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>