Fix a bug in SlaveReqHandler::set_config(), it should remove the
message header of the buffer passed to backend.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
The vhost crate is written from scratch, so it should be licensed to
Alibaba Cloud instead of Google.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
By relaxing the dependency to ">=0.6" this crate can be used in projects
using newer vm-memory without pulling in duplicates of the crate.
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
vhost_vdpa_config has a flexible array member (buf).
Let's use vmm_sys_util::fam module to handle it in get_config()
and set_config().
This simplifies the code and reduces the unsafe block to just
the ioctl call.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
This function is not used and possible users can call directly
`parse` on structures implementing VhostIotlbMsgParser trait.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
crates.io does not allow publishing crates which have wildcards in
their dependencies. We had one for "serial_test", so replace the
wildcard pointing it to the current major/minor ("0.5").
Signed-off-by: Sergio Lopez <slp@redhat.com>
vDPA simulators are available since Linux 5.7.
The CI may have an older kernel, so to avoid CI failures, for now
we skip the tests if we don't find the device.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Add dma_map/dma_unmap functions in VhostVdpa trait and implement
them in VhostKernVdpa using the IOTLB messages support provided
by VhostIotlbBackend.
Add also a specific test in vhost_kern/vdpa.rs.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Add a vhost-vdpa in-kernel implementation of VhostVdpa trait.
Tests are serialized since the device supports only a single user
at a time.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Add new VhostVdpa trait to handle vhost-vdpa devices and a new
vhost-vdpa building feature.
vhost-vdpa devices is based on vhost backend, for this reason
VhostVdpa trait requires VhostBackend.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Implement VhostIotlbBackend trait for vhost_kern handling both
vhost_msg and vhost_msg_v2 messages according to acked backend
features.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
This new VhostIotlbBackend trait will be implemented by the backends
that support IOTLB messages.
Add also VhostIotlbMsg struct and related enums to handle IOTLB
messages properly.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Add new VhostKernFeatures trait to handle the backend features
supported by the backend and acked by the fronted.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
VHOST_ACCESS_* and VHOST_IOTLB_* constants are assigned to c_uchar
fields and VHOST_IOTLB_MSG to a c_int field.
Let's set the proper types to avoid casts when assigning them.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
recv_with_fds from vmm-sys-util was never safe, but was incorrectly
not marked as safe. Handle it safely in every function where we have
enough information to know that calling it will be safe, and propogate
the unsafe to any function where we don't.
Fortunately this is quite straightforward now all of the high-level
methods have the guarantee that they're returning ByteValued types.
Signed-off-by: Alyssa Ross <hi@alyssa.is>
These error enums are required to handle various errors during
memfd_create, ftruncate and memfd sealing operations.
Signed-off-by: Harshavardhan Unnibhavi <harshanavkis@gmail.com>
Implement FromRawFd for Listener, using the underlying UnixListener
FromRawFd implementation.
This is useful when the listener socket is inherited as a file
descriptor from a parent (such as libvirt or a jailer).
Signed-off-by: Sergio Lopez <slp@redhat.com>
The coverage test started failing in the following PR:
https://github.com/rust-vmm/vhost/pull/73, which only
modified the codeowners file. It is probably a kcov bug.
Signed-off-by: Laura Loghin <lauralg@amazon.com>
Converting arbitrary bytes into an arbitrary Rust value is unsafe.
For example, it's unsafe to create a String that isn't valid UTF-8.
But the various internal recv* functions didn't restrict their return
types enough to enforce this invariant, making them unsafe without
being properly marked.
To fix this, we tighten up the bounds of the functions to enforce that
their return types are ByteValued, meaning that they can only be used
to create types that are safe to initialize with arbitrary data such
as might be received over a socket.
It's worth asking how these functions could have been unsafe in the
first place, since they don't contain any unsafe blocks themselves.
The answer is that the functions that recv into iovecs are also unsafe
but not correctly marked. I'm preparing further patches to fix that
up, but it's a lot of work so I've separated out this change in the
hope of getting it in first and making the diff for the next one
smaller.
This internal tightening shouldn't result in any public API changes.
Signed-off-by: Alyssa Ross <hi@alyssa.is>
"Apache-2.0 or BSD-3-Clause" is not an valid license statement and is
rejected by cargo. So change it to "Apache-2.0 OR BSD-3-Clause".
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
Rename LICENSE-BSD-Chromium as LICENSE-BSD-Google to match the
reference in source file. Also remoce LICENSE-BSD-3-Clause, all code
contributed by Alibaba is licensed under Apache 2.0.
Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
The SET_LOG_BASE implementation was incomplete as it didn't include the
ability to send the shared memory region information along with the file
descriptor.
This is required to perform proper dirty page logging with a vhost-user
device.
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
It is helpful for the consumer of this crate to be able clone and copy
the VringConfigData structure, as well as being able to initialize it
only partially thanks to the Default trait.
Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
build(deps): update vm-memory requirement from 0.2.0 to 0.5.0
Updates the requirements on
[vm-memory](https://github.com/rust-vmm/vm-memory) to permit the latest
version.
Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
fix warning, when compiling with 1.53.0
```
warning: reference to packed field is unaligned
--> src/vhost_user/message.rs:252:53
|
252 | unsafe { std::mem::transmute_copy::<u32, R>(&self.request) }
| ^^^^^^^^^^^^^
|
= note: `#[warn(unaligned_references)]` on by default
= warning: this was previously accepted by the compiler but is being
phased out; it will become a hard error in a future release!
= note: for more information, see issue #82523
<https://github.com/rust-lang/rust/issues/82523>
= note: fields of packed structs are not properly aligned, and
creating a misaligned reference is undefined behavior (even if
that reference is never dereferenced)
```
Signed-off-by: wanglei <wllenyj@linux.alibaba.com>