Commit graph

161 commits

Author SHA1 Message Date
Viresh Kumar
d4c021dea3 Convert to a workspace
Convert the vhost git repository into a crate, which hosts vhost crate
for now. Support for vhost-user-backend and other crates will be added
later on.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2022-10-11 11:59:25 +05:30
Sebastien Boeuf
f87156b776 vhost_kern: vdpa: Add missing ioctls
New ioctls have been recently introduced to interact with vDPA devices.

This patch is based on Linux kernel v6.0, adding the list of missing
ioctls:

- VHOST_VDPA_GET_CONFIG_SIZE
- VHOST_VDPA_GET_VQS_COUNT
- VHOST_VDPA_GET_GROUP_NUM
- VHOST_VDPA_GET_AS_NUM
- VHOST_VDPA_GET_VRING_GROUP
- VHOST_VDPA_SET_GROUP_ASID
- VHOST_VDPA_SUSPEND

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2022-10-10 16:02:38 +02:00
Sebastien Boeuf
787a424a86 vhost_user: Fix warning about unsafe not needed
There's no need to specify unsafe given the whole function is already
considered unsafe.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2022-10-10 16:02:38 +02:00
wanglei01
796b9d9dfc release 0.5.0
See CHANGELOG.md file for details.

Signed-off-by: wanglei01 <wllenyj@linux.alibaba.com>
2022-09-07 16:09:23 +08:00
wanglei01
88b57518c3 update dependency requirements
Use caret requirements for dependencies.

Fixes: rust-vmm/community#131

Signed-off-by: wanglei01 <wllenyj@linux.alibaba.com>
2022-08-25 09:43:33 +03:00
Alex Bennée
ebaac3c6b1 vhost_user: update link to the vhost-user spec
The spec has been converted to .rst and now generated a nicer rendered
version whenever it is updated in QEMU's master branch. Lets use it
instead.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
2022-08-04 08:39:34 +02:00
Alex Bennée
e128197954 vhost_user: expand error messages for clarity
The InvalidOperation error type covers a wide range of error cases
which can be inscrutable when passed to the user. To help with this
we:

  - add a textual reason field to the error message
  - create InactiveFeature for use of un-neogitated features
  - create InactiveOperation for use of un-negotiated protocol extensions

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
2022-08-04 08:39:34 +02:00
Alex Bennée
102d14e3b5 vhost_user: re-factor feature/proto bit checking
We can wrap up the feature checking into helpers to reduce the amount
of boilerplate code while enabling us to use a more idiomatic ?; exit
path on error.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
2022-08-04 08:39:34 +02:00
Sebastien Boeuf
7772f02e1a Release v0.4.0
This release contains some fixes for the CI as well as the CODEOWNERS
file. It fixes the implementation of get_iova_range() for vDPA, and
finally it implements its own version of the VhostKernBackend::valid()
method for vDPA.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2022-03-19 00:05:42 +08:00
Sebastien Boeuf
4fa43567d6 vhost_kern: vdpa: Override valid()
Since vDPA could be dealing with IOVAs corresponding to GVAs, it
wouldn't make sense to go through the validation of the descriptor
table address, available ring address and used ring address against
the guest memory representation we have access to.

For this reason, we override the default implementation of the valid()
method from the VhostKernBackend trait, to provide a simpler
implementation.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2022-03-18 18:39:03 +08:00
dependabot[bot]
171603c6b5 build(deps): bump rust-vmm-ci from d216a46 to 99fe2eb
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `d216a46` to `99fe2eb`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](d216a46879...99fe2eb2e0)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-18 11:31:45 +02:00
Stefano Garzarella
c605e7a62a vhost_kern/vdpa: fix get_iova_range()
A wrong ioctl request was used in get_iova_range().
Unfortunately, there was no test, otherwise the ioctl would fail.

Let's fix this by using the right ioctl request.
We also add a test by checking the values we expect from
a vDPA-block simulator that returns [0, u64::MAX] range.

Fixes  #106

Reported-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2022-03-12 11:24:55 +08:00
Laura Loghin
4bc87adf80 fix CODEOWNERS file
The gatekeeper-PullAssigner was not correctly added in
the codeowners file (with its github handle). Removed it
from the file, so that the codewners are automatically
requested to review a new PR.
Since I was here, also reordered alphabetically the users.

Signed-off-by: Laura Loghin <lauralg@amazon.com>
2022-02-16 15:55:50 +01:00
Sergii Glushchenko
8b4f6d4f36 Fix warnings and adjust test coverage
Signed-off-by: Sergii Glushchenko <gsserge@amazon.com>
2022-01-25 09:10:00 +01:00
dependabot[bot]
8b4e5d8f80 build(deps): bump rust-vmm-ci from b6858b2 to d216a46
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `b6858b2` to `d216a46`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](b6858b232d...d216a46879)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-25 09:10:00 +01:00
dependabot[bot]
4e1101f6c0 build(deps): bump rust-vmm-ci from aee82cf to b6858b2
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `aee82cf` to `b6858b2`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](aee82cf0a4...b6858b232d)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-18 09:11:16 +01:00
Liu Jiang
faa15d988b Prepare for publishing v0.3.0
Update CHANGELOG.md and version number.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-20 16:43:35 +08:00
Liu Jiang
c008d26f51 doc: enable all features for doc.rs
Generate documentation for doc.rs with all features enabled.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-12-20 16:43:35 +08:00
Liu Jiang
0d2acd505d vhost-user: fix SlaveReqHandler::set_config()
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>
2021-12-20 16:43:35 +08:00
Wu Zongyong
45f026046b vhost_net: implement vhost_net backend
Signed-off-by: Wu Zongyong <wuzongyong@linux.alibaba.com>
2021-11-29 16:52:57 +08:00
Liu Jiang
49526acdc6 vdpa: add method to restore Vdpa objects
Add a method to restore Vdpa objects.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-11-26 21:19:40 +08:00
Liu Jiang
85ab9e3c4e Refine BSD-3-Clause license file
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>
2021-11-26 21:19:40 +08:00
dependabot[bot]
78542ec600 build(deps): bump rust-vmm-ci from 7931077 to aee82cf
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `7931077` to `aee82cf`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](7931077cdc...aee82cf0a4)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-02 11:18:15 +01:00
Rob Bradford
fca9e51956 build: Relax vm-memory dependency
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>
2021-10-25 08:59:24 +08:00
Stefano Garzarella
64577a3c6c vhost_kern/vdpa: use FAM for vhost_vdpa_config
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>
2021-10-19 11:55:37 +08:00
Stefano Garzarella
833b8975cc vdpa: add vDPA and vhost-vdpa simple description
Explained a bit vDPA and vhost-vdpa in the documentation of
the VhostVdpa trait.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2021-10-19 11:55:37 +08:00
Stefano Garzarella
1215bae8a9 Remove parse_iotlb_msg from VhostIotlbBackend
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>
2021-10-19 11:55:37 +08:00
dependabot[bot]
2535efd9aa build(deps): bump rust-vmm-ci from 7f22582 to 7931077
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `7f22582` to `7931077`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](7f22582590...7931077cdc)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-10-12 09:44:14 +03:00
dependabot[bot]
6bb347aa78 build(deps): bump rust-vmm-ci from f67ef4c to 7f22582
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `f67ef4c` to `7f22582`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](f67ef4c84d...7f22582590)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-28 10:52:15 +03:00
Sergio Lopez
38fae60d81 Cargo: replace wildcard with 0.5 for serial_test
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>
2021-09-23 08:57:05 +02:00
Sergio Lopez
b4d4ce7cc4 Prepare for release v0.2.0
Update version in Cargo.toml and add info about v0.2.0 to CHANGELOG.md

Signed-off-by: Sergio Lopez <slp@redhat.com>
2021-09-23 06:50:11 +02:00
dependabot[bot]
7fdba6e557 build(deps): bump rust-vmm-ci from ae7db2d to f67ef4c
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `ae7db2d` to `f67ef4c`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](ae7db2d98a...f67ef4c84d)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-21 17:08:02 +03:00
Stefano Garzarella
354dd56adf vhost_kern/vdpa: skip tests if device is not found
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>
2021-09-15 15:01:53 +08:00
Stefano Garzarella
82d1a3cd02 vdpa: add dma_map/dma_unmap functions
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>
2021-09-15 15:01:53 +08:00
Stefano Garzarella
866932e6cc vhost_kern: add VhostKernVdpa struct
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>
2021-09-15 15:01:53 +08:00
Stefano Garzarella
8884465b95 Add VhostVdpa trait
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>
2021-09-15 15:01:53 +08:00
Stefano Garzarella
7b70a12731 vhost_kern: add VHOST_VDPA_* ioctls and structs
Add ioctls, structs, and test needed to support vhost-vdpa.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2021-09-15 15:01:53 +08:00
Stefano Garzarella
58680d5826 vhost_kern: add IOTLB message support
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>
2021-09-15 15:01:53 +08:00
Stefano Garzarella
a2bc456bed Add VhostIotlbBackend trait
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>
2021-09-15 15:01:53 +08:00
Stefano Garzarella
19066861ee vhost_kern: add VhostKernFeatures trait
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>
2021-09-15 15:01:53 +08:00
Stefano Garzarella
8dea3b6df4 vhost_kern: add VHOST_BACKEND ioctls and flags
vhost-kern support these ioctls to set/get backend features related
to IOTLB message support.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2021-09-15 15:01:53 +08:00
Stefano Garzarella
81dd5a91a1 vhost_kern: add vhost_msg_v2 bindings
Add structs and tests for the C 'struct vhost_msg_v2' type supported
by vhost-kern.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2021-09-15 15:01:53 +08:00
Stefano Garzarella
c489e2ba03 vhost_kern: add VHOST_IOTLB_BATCH_* constants
These two new VHOST_IOTLB message types are supported by vhost-vdpa.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2021-09-15 15:01:53 +08:00
Stefano Garzarella
761c144a71 vhost_kern: set the proper type of constants
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>
2021-09-15 15:01:53 +08:00
Alyssa Ross
3355764355 vhost_user: handle recv_with_fds being unsafe
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>
2021-09-15 07:33:56 +02:00
Andreea Florescu
8c2f10ba98 update dependabot formatting
Signed-off-by: Andreea Florescu <fandree@amazon.com>
2021-09-10 13:49:37 +03:00
Harshavardhan Unnibhavi
371af5f204 coverage x86: reduce by 0.2
Signed-off-by: Harshavardhan Unnibhavi <harshanavkis@gmail.com>
2021-09-10 09:51:02 +02:00
Harshavardhan Unnibhavi
5cd68f5245 Inflight I/O: Introduce new error enums
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>
2021-09-10 09:51:02 +02:00
Sergio Lopez
ac73584d6e vhost-user: Implement FromRawFd for Listener
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>
2021-09-03 21:27:01 +08:00
dependabot[bot]
33fffff025 build(deps): bump rust-vmm-ci from 1311bfa to ae7db2d
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `1311bfa` to `ae7db2d`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](1311bfa03f...ae7db2d98a)

---
updated-dependencies:
- dependency-name: rust-vmm-ci
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-03 10:29:05 +03:00