Commit graph

144 commits

Author SHA1 Message Date
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
Catalin Dumitru
ef05ca7e95 Deprecate custom pipeline
We can autogenerate the custom pipelines as well now.

Signed-off-by: Catalin Dumitru <catdum@amazon.com>
2021-09-03 10:16:46 +03:00
Laura Loghin
a4802f6362 update coverage
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>
2021-09-02 15:40:44 +03:00
dependabot[bot]
d19202c3bf build(deps): bump rust-vmm-ci from a00c7d2 to 1311bfa
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `a00c7d2` to `1311bfa`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](a00c7d2f1b...1311bfa03f)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-02 15:40:44 +03:00
Stefano Garzarella
af637585b8 CODEOWNERS: add stefano-garzarella
Add myself to CODEOWNERS to help with reviews and maintaining
this code.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2021-08-31 16:48:22 +08:00
Alyssa Ross
ccaf8c56bf vhost_user: enforce ByteValued for recv-d structs
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>
2021-08-11 22:17:42 +08:00
Liu Jiang
14d754c5c7 Fix an error in license statement
"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>
2021-08-06 10:23:50 +02:00
Liu Jiang
56ad2ae4dd Prepare for release v0.1
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>
2021-08-05 17:51:35 +02:00
Alyssa Ross
2fe5de96f0 vhost_user: fix struct name in Debug impl
I think this might have been a remnant of the example in the fmt
documentation![1]

[1]: https://doc.rust-lang.org/stable/core/fmt/trait.Debug.html#examples

Signed-off-by: Alyssa Ross <hi@alyssa.is>
2021-08-05 10:28:58 +02:00
Sebastien Boeuf
37a6a8e464 Fix set_log_base() implementation for vhost-user
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>
2021-08-04 16:44:05 +08:00
Sebastien Boeuf
868181c1fa Derive Default, Clone and Copy for VringConfigData
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>
2021-08-04 09:55:52 +02:00
dependabot[bot]
9a1aa0b3c7 build(deps): bump rust-vmm-ci from 7693628 to a00c7d2
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `7693628` to `a00c7d2`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](7693628035...a00c7d2f1b)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-03 09:50:08 +01:00
Liu Jiang
0c607bb299 update vm-memory requirement from 0.2.0 to 0.5.0
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>
2021-07-29 18:37:01 +08:00
dependabot[bot]
0ed4dd50ef build(deps): bump rust-vmm-ci from d2ab3c0 to 7693628
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `d2ab3c0` to `7693628`.
- [Release notes](https://github.com/rust-vmm/rust-vmm-ci/releases)
- [Commits](d2ab3c0908...7693628035)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-29 15:06:24 +08:00
wanglei01
488b3adc2f fix warning: unaligned_references
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>
2021-07-29 08:53:15 +02:00
Harshavardhan Unnibhavi
c1f77c778b Inflight I/O: Make struct members public
Signed-off-by: Harshavardhan Unnibhavi <harshanavkis@gmail.com>
2021-07-26 17:07:02 +08:00
Harshavardhan Unnibhavi
99fbfc9692 x86_64 coverage: reduce by 0.6
Signed-off-by: Harshavardhan Unnibhavi <harshanavkis@gmail.com>
2021-07-21 10:43:29 +02:00
Harshavardhan Unnibhavi
18ae8a991d Inflight I/O: Make structs and members public
Signed-off-by: Harshavardhan Unnibhavi <harshanavkis@gmail.com>
2021-07-21 10:43:29 +02:00