Commit graph

479 commits

Author SHA1 Message Date
dependabot[bot]
290794b445 build(deps): bump the vhost group with 2 updates
Updates the requirements on [virtio-queue](https://github.com/rust-vmm/vm-virtio) and [vm-memory](https://github.com/rust-vmm/vm-memory) to permit the latest version.

Updates `virtio-queue` to 0.13.0
- [Release notes](https://github.com/rust-vmm/vm-virtio/releases)
- [Commits](https://github.com/rust-vmm/vm-virtio/compare/virtio-queue-v0.13.0...virtio-queue-v0.13.0)

Updates `vm-memory` to 0.16.0
- [Release notes](https://github.com/rust-vmm/vm-memory/releases)
- [Changelog](https://github.com/rust-vmm/vm-memory/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rust-vmm/vm-memory/compare/v0.15.0...v0.16.0)

---
updated-dependencies:
- dependency-name: virtio-queue
  dependency-type: direct:production
  dependency-group: vhost
- dependency-name: vm-memory
  dependency-type: direct:production
  dependency-group: vhost
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-25 13:56:53 +02:00
Stefano Garzarella
4c2526bbe8 vhost-user-backend: prepare v0.16.1 release
Remove the gpu-socket feature just introduced, since it doesn't work
well with cargo feature unification.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2024-10-25 12:50:02 +02:00
Stefano Garzarella
c5fb10cec6 vhost: prepare v0.12.1 release
Remove the gpu-socket feature just introduced, since it doesn't work
well with cargo feature unification.

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2024-10-25 12:50:02 +02:00
Dorinda Bassey
56a374c09f CHANGELOG: fix feature unification
add CHANGELOG for the PR that fixes feature unification
issues with gpu-socket feature.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2024-10-25 10:06:09 +02:00
Dorinda Bassey
1350073485 make set_gpu_socket a default implementation
relax the requirement of the trait when implementing
the `set_gpu_socket` method, make the `set_gpu_socket`
method optional, and ensure that the function `set_gpu_socket`
returns an error if the backend does not implement it.

Fixes #265

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2024-10-25 10:06:09 +02:00
Dorinda Bassey
64cc75a8ab Remove gpu-socket feature
Remove conditional compilation because when multiple crates
that are in thesame workspace set different features,
cargo feature unification already defeats the purpose of
the `gpu-socket` feature flag since cargo merges all the
feature flags specified by dependent crates into a single
set when compiling shared dependencies. for reference see:
[feature-unification](https://doc.rust-lang.org/cargo/reference/features.html#feature-unification)

Fixes: #265

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2024-10-25 10:06:09 +02:00
Ruoqing He
071216060f build: Centralize rust-vmm crates to workspace
By centralizing rust-vmm crates to workspace root, effectively reduce
places to look around when updating dependencies manually.

Signed-off-by: Ruoqing He <heruoqing@iscas.ac.cn>
2024-10-21 14:03:27 +02:00
dependabot[bot]
51e11396ac build(deps): bump rust-vmm-ci from 438f36e to 209c04e
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `438f36e` to `209c04e`.
- [Commits](438f36e242...209c04eb5e)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-10-17 09:13:52 +02:00
Tyler Fanelli
4f160320a8 vhost-user-backend: impl Debug for AddrMapping
It can be useful to debug the various address mappings sent to a vhost
user device backend. impl Debug for both the postcopy and non-postcopy
versions of AddrMapping.

Signed-off-by: Tyler Fanelli <tfanelli@redhat.com>
2024-10-02 16:25:52 +02:00
Stefano Garzarella
51f8aa0100 cargo-config: rename to config.toml
cargo recently complains about our cargo configuration file name:

    $ cargo build
    warning: `vhost/.cargo/config` is deprecated in favor of
    `config.toml`
    note: if you need to support cargo 1.38 or earlier, you can
    symlink `config` to `config.toml`

As suggested, let's update the file name. We don't create the symlink
since 2021 edition is not supported by 1.38 toolchain:

    $ cargo +1.38.0 build
    error: failed to parse manifest at `vhost/Cargo.toml`

    Caused by:
      failed to parse the `edition` key

    Caused by:
      supported edition values are `2015` or `2018`, but `2021` is unknown

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2024-10-02 13:43:29 +02:00
Muminul Islam
db344520f5 vhost-user-backend: Prepare v0.16.0 release
This release has the following changes:
  1. Move the set of event_idx property from set_vring_base callback to set_features one
  2. Add shared objects support
  3. Add support for `VHOST_USER_GPU_SET_SOCKET`
  4. Update virtio-queue version from 0.12.0 to 0.13.0 and vm-memory from 0.14.0 to 0.15.0.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2024-09-13 10:36:19 +02:00
Muminul Islam
6f4279c825 vhost: Prepare v0.12.0 release
This release has the following changes:
  1. Bump vm-memory crate from 0.14.0 to 0.15.0
  2. Add shared objects support
  3. Remove support for FS_* requests
  4. Add support for `VHOST_USER_GPU_SET_SOCKET`
  5. Ignore unknown bits in `VHOST_USER_GET_PROTOCOL_FEATURES` response.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2024-09-13 10:36:19 +02:00
Muminul Islam
e397bdb7cb builds: bump vm-memory and virtio-queue
Update virtio-queue version from 0.12.0 to 0.13.0 and
vm-memory from 0.14.0 to 0.15.0.

Signed-off-by: Muminul Islam <muislam@microsoft.com>
2024-09-12 11:05:46 +02:00
dependabot[bot]
a5c25a9b75 build(deps): bump rust-vmm-ci from 752ad13 to 438f36e
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `752ad13` to `438f36e`.
- [Commits](752ad1322a...438f36e242)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-10 09:38:39 +02:00
dependabot[bot]
12ac255e1f build(deps): bump rust-vmm-ci from 5e818dc to 752ad13
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `5e818dc` to `752ad13`.
- [Commits](5e818dc729...752ad1322a)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-03 11:59:38 +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
Stefano Garzarella
f574a20563 vhost: fix clippy unnecessary use of get(&uuid.uuid).is_some()``
The new clippy in rust-vmm-ci complain about this:

error: unnecessary use of `get(&uuid.uuid).is_some()`
   --> vhost/src/vhost_user/frontend_req_handler.rs:393:36
    |
393 |             if self.shared_objects.get(&uuid.uuid).is_some() {
    |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `contains(&uuid.uuid)`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_get_then_check
    = note: `-D clippy::unnecessary-get-then-check` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::unnecessary_get_then_check)]`

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2024-09-03 11:59:38 +02:00
Stefano Garzarella
aceda54de8 vhost: fix clippy transmute used without annotations
The new clippy in rust-vmm-ci complain about this:

error: transmute used without annotations
   --> vhost/src/vhost_kern/mod.rs:405:29
    |
405 |             msg.perm = mem::transmute(self.__bindgen_anon_1.iotlb.perm);
    |                             ^^^^^^^^^ help: consider adding missing annotations: `transmute::<u8, backend::VhostAccess>`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_transmute_annotations
    = note: `-D clippy::missing-transmute-annotations` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::missing_transmute_annotations)]`

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2024-09-03 11:59:38 +02:00
Stefano Garzarella
5a115dc7d4 vhost: fix clippy doc list item missing indentation
The new clippy in rust-vmm-ci complain about this:

error: doc list item missing indentation
   --> vhost/src/vhost_user/connection.rs:305:9
    |
305 |     /// In other words, recvmsg() operations must not cross the packet boundary, other...
    |         ^
    |
    = help: if this is supposed to be its own paragraph, add a blank line
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation
    = note: `-D clippy::doc-lazy-continuation` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::doc_lazy_continuation)]`

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2024-09-03 11:59:38 +02:00
Stefano Garzarella
b5a117d581 vhost: fix clippy match can be simplified with .unwrap_or_default()``
The new clippy in rust-vmm-ci complain about this:

error: match can be simplified with `.unwrap_or_default()`
   --> vhost/src/vhost_user/connection.rs:138:20
    |
138 |           let rfds = match fds {
    |  ____________________^
139 | |             Some(rfds) => rfds,
140 | |             _ => &[],
141 | |         };
    | |_________^ help: replace it with: `fds.unwrap_or_default()`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or_default
    = note: `-D clippy::manual-unwrap-or-default` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::manual_unwrap_or_default)]`

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2024-09-03 11:59:38 +02:00
Stefano Garzarella
9442110f98 vhost: fix clippy deprecating feature = "cargo-clippy"
The latest toolchain update in rust-vmm-ci caused the following
error:

  error: unexpected `cfg` condition value: `cargo-clippy`
     --> vhost/src/vhost_user/message.rs:758:16
      |
  758 |     #[cfg_attr(feature = "cargo-clippy", allow(clippy::useless_conversion))]
      |                ^^^^^^^^^^^^^^^^^^^^^^^^
      |

As suggested in [1], today is no longer needed to check the
`cargo-clippy` feature (which has been deprecated), but we can
just use `#[allow(clippy::lint_name)]`.

[1] https://blog.rust-lang.org/2024/02/28/Clippy-deprecating-feature-cargo-clippy.html

Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
2024-09-03 11:59:38 +02:00
Matej Hrica
c1e1ba2bf9 Fix bug in test create_listener_from_raw_fd()
Call into_raw_fd() instead of as_raw_fd() to make sure the fd is not closed
by File destructor.

Signed-off-by: Matej Hrica <mhrica@redhat.com>
2024-08-30 16:06:24 +02:00
dependabot[bot]
e4d9e237f2 build(deps): bump rust-vmm-ci from cec97d9 to 5e818dc
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `cec97d9` to `5e818dc`.
- [Commits](cec97d9e6c...5e818dc729)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-26 12:14:37 +02:00
dependabot[bot]
5c6080275f build(deps): bump rust-vmm-ci from 9f641f2 to cec97d9
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `9f641f2` to `cec97d9`.
- [Commits](9f641f269b...cec97d9e6c)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-06 09:08:50 +02:00
dependabot[bot]
50e28018d2 build(deps): bump rust-vmm-ci from 0503867 to 9f641f2
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `0503867` to `9f641f2`.
- [Commits](05038671bb...9f641f269b)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-30 12:14:04 +02:00
Matej Hrica
a4d6c81c8d CI: Build and test with gpu-socket feature
Compile and test with `gpu-socket` feature enabled.

Signed-off-by: Matej Hrica <mhrica@redhat.com>
2024-07-23 14:50:25 +02:00
Matej Hrica
4684f2e9fc Modify changelogs mentioning upcoming gpu-socket feature
Adds links to PR in CHANGELOG.md for both vhost and vhost-user-backend.

Signed-off-by: Matej Hrica <mhrica@redhat.com>
2024-07-23 14:50:25 +02:00
Matej Hrica
9c941c2c90 vhost_user: Add GpuBackend::set_dmabuf_scanout2
Add a method and related struct to send the VHOST_USER_GPU_DMABUF_SCANOUT2
message.

Signed-off-by: Matej Hrica <mhrica@redhat.com>
2024-07-23 14:50:25 +02:00
Dorinda Bassey
219e982479 vhost_user: Add GpuBackend::cursor_* message methods
Add methods to send cursor related messages: VHOST_USER_GPU_CURSOR_POS,
VHOST_USER_GPU_CURSOR_POS_HIDE and VHOST_USER_GPU_CURSOR_UPDATE.

VhostUserGpuCursorUpdate's `data` field is passed as a separate argument
into cursor_update method. The type is also an u8 array instead of u32
array like in the spec. Having the type be u8 array makes it easier to work
with the data without unsafe code for the consumer of this crate. Having it
be a separate argument is useful, because the user of the method doesn't
have to copy the array into a struct.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2024-07-23 14:50:25 +02:00
Dorinda Bassey
7b23ae4609 vhost_user: Add GpuBackend::get_ and set_protocol_features
Add get_protocol_features method to send
VHOST_USER_GPU_GET_PROTOCOL_FEATURES and receive the reply. Also add
a method to send SET_PROTOCOL_FEATURES.
Introduce VhostUserGpuProtocolFeatures bitmap that defines possible feature
flags.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2024-07-23 14:50:25 +02:00
Matej Hrica
fb496c0eaa vhost_user: Add GpuBackend::set_ and update_dmabuf_scanout
Add methods and related structs to send the VHOST_USER_GPU_DMABUF_SCANOUT
and VHOST_USER_GPU_DMABUF_UPDATE update messages.

Signed-off-by: Matej Hrica <mhrica@redhat.com>
2024-07-23 14:50:25 +02:00
Matej Hrica
e385837436 vhost_user: Add GpuBackend::update_scanout
Add a method and related struct to send VHOST_USER_GPU_UPDATE.

The data part of the message is not part of the struct like sugested by
the spec but a separate argument to update_scanout. This is necessary
because of limitations of having an unsized array inside of struct in Rust.
But this aproach seems preferable anyway, because it allows the consumer of
the crate to store the array in a diferent location than the struct.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Signed-off-by: Matej Hrica <mhrica@redhat.com>
2024-07-23 14:50:25 +02:00
Dorinda Bassey
d35c657c05 vhost_user: Add GpuBackend::set_scanout
Add a method set_scanout() that sends VHOST_USER_GPU_SCANOUT and doesn't
wait for a reply.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2024-07-23 14:50:25 +02:00
Dorinda Bassey
a08c43c6ed vhost_user: Add GpuBackend::get_edid
Add a method and related structs to send VHOST_USER_GPU_GET_EDID and
receive the reply.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
2024-07-23 14:50:25 +02:00
Dorinda Bassey
113bd0e187 vhost_user: Add GpuBackend::get_display_info
Add a get_display_info() method and the related reply structs to send
VHOST_USER_GPU_GET_DISPLAY_INFO and receive the reply.

Signed-off-by: Dorinda Bassey <dbassey@redhat.com>
Signed-off-by: Matej Hrica <mhrica@redhat.com>
2024-07-23 14:50:25 +02:00
Matej Hrica
ab0c088bb6 vhost_user: Support sending msg larger than MAX_MSG_SIZE
Introduce another constant MAX_MSG_SIZE that is part of the MsgHeader
trait. For now this is only used for sending messages.
Consider using the more specific trait constant everywhere.

The VHOST_USER_GPU_UPDATE and VHOST_USER_GPU_CURSOR_UPDATE contain image
data and are larger than the existing MAX_MSG_SIZE.

The existing MAX_MSG_SIZE wasn't really a limitation of the protocol,
just an implementation detail limitation in this crate.

Signed-off-by: Matej Hrica <mhrica@redhat.com>
2024-07-23 14:50:25 +02:00
Matej Hrica
9b24090faf Forward VHOST_USER_GPU_SET_SOCKET to VhostUserBackend impls
The VHOST_USER_GPU_SET_SOCKET is only handled when the feature gpu-socket
is enabled. This also introduces a GpuBackend for handling comunication
over the socket.
Signed-off-by: Matej Hrica <mhrica@redhat.com>
2024-07-23 14:50:25 +02:00
Matej Hrica
ca57fb165d vhost_user: Add gpu_message protocol bits
This commit adds the basic definitions of GPU commands on the socket
obtained from VHOST_USER_GPU_SET_SOCKET. This also introduces a new
feature flag `gpu-socket` in the vhost crate.

Signed-off-by: Matej Hrica <mhrica@redhat.com>
2024-07-23 14:50:25 +02:00
Matej Hrica
c66e3a9e0f vhost_user: Move enum_value macro from message.rs to mod.rs
Move the enum_value macro into vhost_user module and make it public within
this module. This will be used in the next commit for defining gpu message
enum.

Signed-off-by: Matej Hrica <mhrica@redhat.com>
2024-07-23 14:50:25 +02:00
Matej Hrica
051c923301 vhost_user: Make Endpoint generic over Header not just Req
The Endpoint was previusly generic only over the Request.
This commit allows Endpoint to be used with a protocol with a slightly
different header such as the QEMU GPU protocol on the socket from
VHOST_USER_GPU_SET_SOCKET.
https://www.qemu.org/docs/master/interop/vhost-user-gpu.html

Signed-off-by: Matej Hrica <mhrica@redhat.com>
2024-07-23 14:50:25 +02:00
Alyssa Ross
7554d06ff4 vhost_user: ignore unknown features from backend
virtiofsd 1.11.0 added support for VHOST_USER_PROTOCOL_F_DEVICE_STATE.
Upgrading virtiofsd meant that the latest released version of Cloud
Hypervisor (39.0) was no longer able to communicate with it, because
rather than just ignoring the unsupported feature, it got an
unrecoverable "invalid message" error.  This demonstrates that it's
better for frontends to just ignore offers of unsupported features.
If the backend requires some feature, it'll get a chance to know that
when we send VHOST_USER_SET_PROTOCOL_FEATURES anyway.

Signed-off-by: Alyssa Ross <hi@alyssa.is>
2024-07-01 14:13:03 +02:00
Albert Esteve
6755c6cd82 CHANGELOG.md: Remove support for FS_* requests
Signed-off-by: Albert Esteve <aesteve@redhat.com>
2024-06-27 21:47:54 +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
dependabot[bot]
48081ddad6 build(deps): update nix requirement from 0.28 to 0.29 in the vhost group
Updates the requirements on [nix](https://github.com/nix-rust/nix) to permit the latest version.

Updates `nix` to 0.29.0
- [Changelog](https://github.com/nix-rust/nix/blob/master/CHANGELOG.md)
- [Commits](https://github.com/nix-rust/nix/compare/v0.28.0...v0.29.0)

---
updated-dependencies:
- dependency-name: nix
  dependency-type: direct:production
  dependency-group: vhost
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-27 09:59:25 +02:00
Albert Esteve
873a9b9bed CHANGELOG.md: Add shared object feature
Signed-off-by: Albert Esteve <aesteve@redhat.com>
2024-06-19 13:11:20 +02:00
Albert Esteve
94be3dfb7d vhost_user.backend_req: check shared_object flag
Check for VHOST_USER_PROTOCOL_F_SHARED_OBJECT flag
before allowing the backend to send SHARED_OBJECT_*
requests.

If it does have negotiated the protocol feature,
avoid sending the message and return error code
(i.e., !=0).

Signed-off-by: Albert Esteve <aesteve@redhat.com>
2024-06-19 13:11:20 +02:00
Albert Esteve
76c347c108 vhost_user: add shared object msg
Add SHARED_OBJECT_* vhost-user request
IDs to align with standard. Implement
backend functions to send these
requests.

Add SHARED_OBJECT protocol feature.

Add GET_SHARED_OBJECT to the frontend
requests (not implemented, this is just to
have the placeholder and align with current
standard).

Signed-off-by: Albert Esteve <aesteve@redhat.com>
2024-06-19 13:11:20 +02:00
Albert Esteve
9323902c59 vhost_user: join frontend handler thread on tests
Assertion fails on the frontend thread in tests
can go unnoticed.
To avoid that the main thread finishes before
and solve this issue, let's `join()` the thread
at the end of the test.

Signed-off-by: Albert Esteve <aesteve@redhat.com>
2024-06-19 13:11:20 +02:00
Albert Esteve
85e00973f4 vhost_user: separate non standard msgs
FS_* vhost-user backend request messages in
BackendReq enum did not make it into the
standard yet. Actually, currently there
are already SHARED_OBJECT_* messages that
use the message type IDs for FS_* types.

To fix this and avoid the issue for future
message IDs, let's move FS_* types further
away and prevent collision to occur.
This way we only need to change it once.

Signed-off-by: Albert Esteve <aesteve@redhat.com>
2024-06-19 13:11:20 +02:00
dependabot[bot]
1991b1d77e build(deps): bump rust-vmm-ci from 7606478 to 0503867
Bumps [rust-vmm-ci](https://github.com/rust-vmm/rust-vmm-ci) from `7606478` to `0503867`.
- [Commits](7606478202...05038671bb)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-11 08:48:08 +02:00