Commit graph

44 commits

Author SHA1 Message Date
dependabot[bot]
a5735744be build(deps): bump rust-vmm-ci from 209c04e to 1150c47
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `209c04e` to `1150c47`.
- [Commits](209c04eb5e...1150c47872)

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

Signed-off-by: dependabot[bot] <support@github.com>

[SG] Updated coverage score since we fixed its calculation, see
https://github.com/rust-vmm/rust-vmm-ci/pull/171

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2024-10-25 14:18:16 +02:00
Stefano Garzarella
2d85e865ec coverage: update the score
The latest toolchain update in rust-vmm-ci increased the coverage,
causing the following CI error:

  Current code coverage (78.40%) deviates by 5.36% from the previous code
  coverage 73.04%

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2024-09-03 11:59:38 +02:00
Albert Esteve
569ef077fa vhost_user: Remove support for FS_* requests
Since these non-standard backend request
message types are confirmed not to be used
anymore, let's just remove them.

```
pub enum BackendReq {
    ...
    /// Virtio-fs draft: map file content into the window.
    FS_MAP = 100,
    /// Virtio-fs draft: unmap file content from the window.
    FS_UNMAP = 1001,
    /// Virtio-fs draft: sync file content.
    FS_SYNC = 1002,
    /// Virtio-fs draft: perform a read/write from an fd directly to GPA.
    FS_IO = 1003,
    ...
}
```

Closes: #213
Signed-off-by: Albert Esteve <aesteve@redhat.com>
2024-06-27 21:47:54 +02:00
Egor Lazarchuk
3044602efd coverage: add vhost-user-backend/postcopy feature
Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
2024-01-24 16:25:52 +01:00
German Maglione
b5550a941d coverage: lowering the coverage score
New code was added to the `BackendReqHandler` that is not feasible to
test right now. The rest of the code are just definitions.

Signed-off-by: German Maglione <gmaglione@redhat.com>
2024-01-23 11:31:32 +01:00
Stefano Garzarella
f8c77dffd1 coverage: update the score
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2023-12-11 15:33:51 +01:00
Stefano Garzarella
f29830ab87 coverage: update the score
After updating the CI the coverage value changed causing failures:

    Current code coverage (76.33%) deviates by 7.67% from the
    previous code coverage 84.00%.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2023-09-14 16:40:26 +08:00
Albert Esteve
4db81adcd2 vhost: Adopt new backend naming
Following vhost-user specification, replace
all uses of master/slave with backend/frontend
in the vhost crate.

Signed-off-by: Albert Esteve <aesteve@redhat.com>
2023-09-13 13:00:10 +02:00
Viresh Kumar
3cbdceaaf7 Update coverage
Update coverage to 84.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2023-06-29 09:09:31 +02:00
Viresh Kumar
40006d0b39 Merge remote-tracking branch 'vhost-user-backend/main' into workspace
This merges vhost-user-backend into this workspace along with its git
history.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2022-10-11 12:27:44 +05:30
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
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
Sebastien Boeuf
bbc892ba45 lib: Allow the daemon to run as a client
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>
2022-02-03 17:13:29 +08:00
Sebastien Boeuf
1c4ee49a89 Implement AsRawFd for VringEpollHandler
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>
2022-02-03 00:15:43 +08: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
Sergii Glushchenko
9517235567 Fix clippy warnings and adjust test coverage
Signed-off-by: Sergii Glushchenko <gsserge@amazon.com>
2022-01-24 12:54:10 +02:00
Liu Jiang
48070ccb7c Add test case to cover VhostUserHandler
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>
2021-12-22 18:58:54 +08:00
Liu Jiang
4e16112122 Refine test case to increase code coverage
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>
2021-12-22 18:58:54 +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
Liu Jiang
6d5fccefc7 epoll: use epoll wrapper from vmm-sys-util
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>
2021-10-15 21:55:35 +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
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
Liu Jiang
f2e38e294a vring: do not take &mut self for VringT
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>
2021-09-09 10:19:50 +02:00
Liu Jiang
e8beb233b5 epoll: refine the way to manage event id
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>
2021-09-07 16:32:34 +08: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
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
Liu Jiang
6d04368c46 backend: set default type for VhostUserBackend
Use () as default type for trait VhostUserBackend and
VhostUserBackendMut.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-08-30 17:52:22 +08:00
Liu Jiang
ca2b434900 Implement Display for Error
Implement Display for Error, and minor documentation enhancement.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-08-30 17:52:21 +08: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
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
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
4c8a94065c x86_64 coverage: reduce by 0.8
Signed-off-by: Harshavardhan Unnibhavi <harshanavkis@gmail.com>
2021-07-07 14:30:54 +02:00
Keiichi Watanabe
9982541776 vhost_user: Stop passing around RawFd
Use `File` or `dyn AsRawFd` instead of `RawFd` to handle ownership
easily.
Fixes #37.

Signed-off-by: Keiichi Watanabe <keiichiw@chromium.org>
Change-Id: I6c79d73d1a54163d4612b0ca4d30bf7bd53f9b0f
2021-06-23 09:52:42 +02:00
Keiichi Watanabe
77b5aaf915 coverage: Update coverage_score
Signed-off-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-06-22 13:06:10 +02:00
Sebastien Boeuf
a8ff939161 vhost_user: Add Inflight I/O tracking support
The inflight I/O tracking feature is useful for handling crashes and
disconnections from the backend. It allows the backend to rely on a
buffer that was shared earlier with the VMM to restore to the previous
state it was before the crash.

This feature depends on the availability of the protocol feature
VHOST_USER_PROTOCOL_F_INFLIGHT_SHMFD, and it implements both
VHOST_USER_GET_INFLIGHT_FD and VHOST_USER_SET_INFLIGHT_FD messages.

Fixes #43

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-06-11 13:51:37 +02:00
Sebastien Boeuf
30ba3e7bbe vhost_user: Add header flags support
Introduce a new method set_flags() in order to let the caller define the
expected set of flags that should be applied to the header for the
following messages.

Fixes #40

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-06-08 10:35:35 +02:00
Ayaan Zaidi
4f31df77bd Add default coverage config for x86_64 2021-03-14 09:59:41 +05:30
Sebastien Boeuf
ee3e872270 vhost_user: Add support for REM_MEM_REG
Adding support for a new message REM_MEM_REG. This command request an
existing memory region to be removed and unmapped from the vhost-user
backend.

It is designed for supporting memory hot-unplug, rather than using
SET_MEM_TABLE, which is less efficient as it would remap all remaining
regions.

It is only available if the protocol feature
VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS has been negotiated.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
2021-03-10 23:37:29 +08:00
Liu Jiang
e543bf2a8d vhost_user: add more negative unit test cases
Add more negative unit test cases to improve code coverage.
Also add two helper functions to simplify code.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-03-01 12:50:56 +01:00
Liu Jiang
ec6eae722e vhost_user: add more unit test cases
Add more unit test cases for vhost-user protocol.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-03-01 12:50:56 +01:00
Liu Jiang
97421f754d Upgrade to rust 2018 edition
Upgrade Cargo.toml to rust edition 2018. Also introduce a helper
feature flag "vhost-user" to simplify code.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2021-03-01 12:50:56 +01:00
Liu Jiang
6ccc681e7e vhost-user: enlarge supported number of vrings
Enlarge VHOST_USER_MAX_VRINGS from 0xff to 0x8000, there's devices
needing more vrings than 0xff.

Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
2020-12-14 12:15:40 +01:00
Arron Wang
9154907c98 Switch to rust-vmm-ci for the CI
Signed-off-by: Arron Wang <arron.wang@intel.com>
2020-09-04 17:59:53 +03:00