VhostUserHandler waits for all working thread to exit in drop(), but
there's no mechanism to notify the working threads to exit. So add
VhostUserHandler::send_exit_event() to notify working threads to exit.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Add a generic type parameter `B: Bitmap` to several key structs to
support guest memory dirty page tracking.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Refine VhostUserBackend to support interior mutability to better
support multi-threading. The previous version of VhostUserBackend
has been renamed as VhostUserBackendMut, with an implementatio of
impl<T: VhostUserBackendMut> VhostUserBackend for RwLock<T> {
}
to ease transition.
The change also improves code readability.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
This implementation just returns Err(InvalidOperation), which is the
correct response for a backend that hasn't negotiated the inflight
feature. Eventually, it'd be nice if we allowed the backend to
negotiate this feature; harshanavkis@8b44378 and slp@3346318 are two
attempts at this.
This is intended as a simple, bikeshed-free way to get things compiling
again while we decide on, and implement, a way to actually support the
inflight feature.
Signed-off-by: Gaelan Steele <gbs@canishe.com>
We were explicitly calling libc::close() on fds we were replacing; but
since they were stored as EventFds, which close themselves on drop, this
is unnecessary. Manually closing them is useless at best; at worse, if
there's a race condition and another thread opens an fd between the
manual close and the normal close on drop, we could have closed someone
else's fd.
The new signatures come from an update to the vhost crate.
This commit is intended as a simple, bikeshed-free fix, but I don't
think it's the best way to handle this long-term. See below.
In most cases, we were converting the RawFd into a File anyway, and
the new code is trivial. In a few cases, though, we actually want an
EventFd, which now requires this nasty construction:
unsafe { EventFd::from_raw_fd(file.into_raw_fd())
This is safe--EventFd::from_raw_fd is unsafe becuase it expects to
uniquely own its fd, an invariant File also has--but a little
inelegant.
Ideally, we would either:
- change vmm-sys-util to provide a way to safely create an EventFd
from a File (this would be trivial; EventFd actually stores its
fd as a File internally),
- pass around a generic "uniquely owned fd" struct (like that
proposed by Rust RFC #3128) instead of a File, or
- change vhost to pass us an EventFd instead of a File where
appropriate (which, in practice, would mean implementing one of the
previous options in vhost)
Signed-off-by: Gaelan Steele <gbs@canishe.com>
Relying on latest vhost version, this commit implements
VHOST_USER_GET_MAX_MEM_SLOTS, VHOST_USER_ADD_MEM_REG and
VHOST_USER_REM_MEM_REG commands from the protocol feature
VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS.
VHOST_USER_GET_MAX_MEM_SLOTS provides the maximum amount of memory
slots that can be supported by the vhost-user backend.
VHOST_USER_ADD_MEM_REG lets the frontend provide a new memory region
that must be mapped by the backend.
VHOST_USER_REM_MEM_REG lets the frontend request for the removal of an
existing memory region that must be unmapped by the backend.
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
There's no reason to hide the list of mappings behind a structure. We
can instead store the list directly in VhostUserHandler structure.
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
In case VHOST_USER_PROTOCOL_F_REPLY_ACK has been negotiated, the reply
ack must be explicitly set on the SlaveFsCacheReq handler.
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
The original VhostUserSlaveReqHandler was changed to be immutable in the
latest vhost crate. Along with that, a mutable version called
VhostUserSlaveReqHandlerMut has been introduced.
In order to keep the vhost_user_backend working, we replace
VhostUserSlaveReqHandler with VhostUserSlaveReqHandlerMut.
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Add @jiangliu, @sboeuf and myself (@slp) to CODEOWNERS, to be
automatically assigned as code reviewers, and remove
'gatekeeper-PullAssigner'.
Signed-off-by: Sergio Lopez <slp@redhat.com>
The main change is that Queue now requires a type parameter of
something that implements GuestAddressSpace. As we already switched to
using GuestMemoryAtomic in a previous commit, we just need to add the
annotations.
There's also a minor change to access Queue::next_avail using
accessors instead of the field.
Signed-off-by: Sergio Lopez <slp@redhat.com>
The VHOST_USER_SET_VRING_BASE message is only intended to update the
index for the next descriptor in the available ring.
Signed-off-by: Sergio Lopez <slp@redhat.com>