Commit graph

68 commits

Author SHA1 Message Date
Alexandre Courbot
2532c07b39 vmm_vhost: fix the VFIO implementation of set_nonblocking()
The set_nonblocking() implementation of the VFIO Listener was marked as
unimplemented and caused a crash. However, given that accept() on a VFIO
listener never blocks, it is just as safe to mark the operation as
successful, since the behavior of accept() won't be impacted and it will
behave properly both in blocking and non-blocking modes.

Removing this panic will allow us to safely use the Listener's interface
set_nonblocking() method in generic code.

BUG=b:229554679
TEST=vhost-user console device works.
TEST=vvu console device works.

Change-Id: Ibbde7bcd048505fc3a84eb4881a74285bae6bf54
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3591111
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-05-27 06:53:08 +00:00
Alexandre Courbot
64a3fc2d08 devices: vhost-user: remove Arc from SlaveListener and SlaveReqHandler
The SlaveReqHandler should be the sole owner of a VhostUserBackend since
it calls its mutable methods, so we shouldn't need an Arc here. If
sharing is necessary users can use their own locking mechanism.

Single ownership will help to retrieve the backend after a client
disconnects, to reuse it for another connection if needed.

BUG=b:229554679
BUG=b:216407443
TEST=cargo test -p vmm_vhost
TEST=vhost-user console device works.
TEST=cargo test -p devices

Change-Id: I2358c807ac3ddb1ee4b29d97df0ade5a3e30a85a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3591108
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-27 06:53:06 +00:00
Rob Clark
953670c3ea virglrenderer: Add cross-domain support
For cross-domain, virgl_renderer needs to be able to import a dmabuf fd
allocated by another component.

BUG=b:230100768
TEST=gfxbench, android games in arcvm

Change-Id: I9d6f965589ec24f06a83a6d921a9c00db1f057f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3501130
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Commit-Queue: Rob Clark <robdclark@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
2022-05-20 20:49:55 +00:00
Daniel Verkamp
e78f169547 third_party/minijail: update to latest
Pull in commit 77c59db8ff9a ("rust: add minijail_run_env to
minijail-sys") so the minijail-sys build script does not keep making the
submodule dirty on every build.

BUG=None
TEST=cargo build && git status

Change-Id: I662a4a9801eb27245691f69644508026a69e8a11
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631409
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-06 23:09:20 +00:00
Daniel Verkamp
4fb38ced74 base: improve the WaitContext doc test
Use the PollToken derive and the build_with() function to make the
example more representative of actual uses.

BUG=None
TEST=cargo doc
TEST=cargo test -p base --doc wait_context

Change-Id: I1f154dfd6247786024dc94035ea63db11968e85a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630424
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-06 20:46:59 +00:00
Daniel Verkamp
d47ca53c26 third_party/minijail: update to latest
Pull in ff062d54f9a4 ("rust: remove redundant format in unreachable") to
fix warnings in Rust 1.60.

BUG=None
TEST=cargo build # no warnings with Rust 1.60.0

Change-Id: Ib2bf2445bc064fe3f81589e426de104565805bbf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3624801
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-05 21:12:48 +00:00
Daniel Verkamp
f35f636cc5 Rust 1.60 clippy fixes
BUG=None
TEST=tools/presubmit # with rust-toolchain updated to 1.60.0

Change-Id: I5772e8b0593f8d92003e93aeb2145e87610abe2e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3577332
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-11 20:40:36 +00:00
Alexandre Courbot
f9eb7f26ea vmm_host: remove default implementation of protocol()
Having a default protocol implementation is dangerous, as implementors
can just ignore this method and return an erroneous type.

BUG=None
TEST=cargo build

Change-Id: Iee7dbcf563be1e5b15903b0fd7bdfb7ff5823545
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3565619
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-04-03 12:45:06 +00:00
Vikram Auradkar
de1f006a08 Enable clippy on windows
Also fixes few warning introduced during upstream which linux clippy
run does not catch.

test: py tools\clippy
bug: 226966790
Change-Id: I6979f87be5d6d34727afabafcaccb57631975567
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3553401
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-03-31 16:09:00 +00:00
Vikram Auradkar
2b43443edc Enable vmm_vhost windows tests
Does couple of things
- move tube under right directory
- cleanup cros_async dependency
- export tube module from base
- enable base windows tests
- add verbose flag to test runner

test: built on window and presubmit
bug: b:213151429
bug: b:213153157
Change-Id: I0d1906d7edcc3352db53325ea7527550eaf00895
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3550296
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-03-29 20:29:54 +00:00
Keiichi Watanabe
2558b26297 vmm_vhost: Allow vmm to turn down before device
This is follow-up of CL:3468235.
For vhost-user, a device (i.e. slave) works like a server while a
vmm (i.e., master) does like a client. So the devices should allow the
vmm to close the connection. An error handling code added by CL:3468235
was opposite. It should have been added to `slave_req_handler.rs`
instead of `master_req_handler.rs`.

BUG=b:219674197
BUG=b:220639724
TEST=run tast.vm.Audio*.vhost_user_cras and tast.vm.VhostUserNet

Change-Id: Ie661c02bed8287d9d770c6c6c0c658ef6681db10
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3533239
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-03-23 23:23:39 +00:00
Daniel Verkamp
445fd4d3f8 vmm_vhost: use base::Event in place of EventFd
Use the cross-platform base::Event type to replace the Linux-specific
base::EventFd.

BUG=b:221882601
BUG=b:219522861
TEST=tools/presubmit

Change-Id: I0503c130306b508af9dd5044653408bd316c7ef1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3533618
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-22 20:25:00 +00:00
Vikram Auradkar
eba2940049 upstream windows vmm_vhost
Windows vmm_vhost differs from linux vmm_vhost mostly on the structures
that it depends on. For example windows uses Tube for linux'
UnixStream.

The patch aliases some of these types in a platform specific file. Rest
of the platform independent code depends on those aliases.

Bug: b:213151429
Test: presubmit, manually run cargo test on windows.
Upstream-Crate: third_party/vmm_vhost

Change-Id: I3f98fbec1ffdd8914dc5befddce3a8483a5fd94f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3496082
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-03-17 01:56:08 +00:00
Dennis Kempin
ef516189db Refactoring: Move common/base into base
Executes the script in https://crrev.com/c/3530502

BUG=b:223206469
TEST=presubmit

Change-Id: Ibeffdc8de0b2270f070e60bb2de8d9fdc78a2a6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3530503
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-03-17 00:01:27 +00:00
Anton Romanov
bed40ad547 crosvm: migrate to Rust 2021 edition
BUG=none
TEST=cq

Change-Id: I0059c970879b78bfd40b6ce58b10debcf154b50f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3508322
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-03-09 01:16:03 +00:00
Keiichi Watanabe
fe6a8ebe90 devices: vhost-user: Exit properly when a vhost-user vmm disconnects
When a client sends 0-sized data, the device regards that the client
closed the connection and will exit properly.

BUG=b:219674197
TEST=check if no error is shown when a vhost-user blk vmm disconnects

Change-Id: Icd84fb241c39b6dc54a8af41a068a6dd95ce4c2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3468235
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-03-01 07:00:04 +00:00
Keiichi Watanabe
b757f0d398 vmm_vhost: vfio: Remove unused File return value
BUG=none
TEST=build

Change-Id: I3f031c9d6488c9380fd328182d8f0ef00bad0c68
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3474158
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-02-22 06:50:11 +00:00
Keiichi Watanabe
90fe105644 vmm_vhost: Remove unused should_reconnect()
Removed `vmm_vhost::Error::should_reconnect()` which we're not using at
all. We don't support reconnect feature at this point.

This function exists even in rust-vmm/vhost, but neither
cloud-hypervisor or rust-vmm/vhost-user-backend is using it.

BUG=none
TEST=cargo check

Change-Id: I4fda22d927573acfedcb189ad786aeb2cf7496e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3468234
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-02-18 04:00:20 +00:00
Vikram Auradkar
ae5118f5c7 Enable windows tests for a few crates
Run tests for sys_util_core, poll_token_derive and balloon_control on
windows.

Using dotfiles to disable/serialize test runs of a subset of crates does
not work well with third party crates as it forces us to commit the dot
file to the crate.

The patch modifies and uses the script that runs linux tests.
This patch also allows us to
- build/test child crate even if parent crate has disabled build/test.
- avoid building crosvm if it is not explicitly specified.

RIP short lived .windows_build_test_skip. You allowed us to run noop
kokoro tests.

Test: py .\tools\impl\test_runner.py --arch x86_64
Bug: b:215610772
Change-Id: Icc6d04ffd7c0c33d4f60aeac16fc7d23881c387d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3459809
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-02-18 03:18:58 +00:00
Vikram Auradkar
7c9b08aae9 Prepare vmm_vhost to be milti-platform 2/2
The patch prepares backend.rs and connection.rs to be platform
independent by
- depending on base instead on sys_util
- using base::Event over sys_util::EventFd
- replacing RawFd usage with RawDescriptor and derivatives

To keep the noise low, the patch
- aliases structs/traits (Event as EventFd)
- does not rename variables (say from fd to rd).

Note: With this patch the crate/files are not completely platform
independent.

Test: Built, clippy and fmt
Bug: b:213151429
Change-Id: Ib57528ef1a951c3d083cf345c878ec1417b7ce3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3460428
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-02-15 20:56:20 +00:00
Vikram Auradkar
15cc292b7e Prepare vmm_vhost to be milti-platform 1/2
The patch prepares backend.rs and connection.rs to be platform
independent by
- depending on base instead on sys_util
- using base::Event over sys_util::EventFd
- replacing RawFd usage with RawDescriptor and derivatives

To keep the noise low, the patch
- aliases structs/traits (Event as EventFd)
- does not rename variables (say from fd to rd).

Note: With this patch the crate/files are not completely platform
independent.

Test: Built, clippy and fmt
Bug: b:213151429

Change-Id: Id93d4a70db627578e6577017f8ca4d69f892d69a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3460427
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-02-14 19:43:17 +00:00
Keiichi Watanabe
6f9c40feee devices: vhost-user: Extend DeviceHandler to support VVU
BUG=b:194137301
TEST=cargo test in devices

Change-Id: I1b5a53eec0114f35421512f374f7cec693520fd7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3149876
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-02-10 11:22:13 +00:00
Anton Romanov
cb3cabe3ba Upgrade rust toolchain version to 1.58.1
Pre 1.58.1 have CVE-2022-21658
Cros toolchain got upgraded to 1.58.1

BUG=None
TEST=cq

Change-Id: I2ce5a08b40bcc4895c4f2ecef83efd4162d67494
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3435385
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-02-04 02:20:36 +00:00
Vikram Auradkar
0108238474 Upstream windows build/test script
The patch also adds files to skip building and testing crates on
windows. When we run
```
tools/windows/build_test.py --skip_file_name .windows_build_test_skip
```

the build/test succeeds without actually doing anything as build/test
for all crates is skipped by creating '.windows_build_test_skip'.

Bug: 213170957
Test: Ran script on downstream repo
Change-Id: Iebd2cea463ee722be4feaed88229e1fb5e9fd6c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3417918
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-01-28 00:55:08 +00:00
Chia-I Wu
7f0f7c1fa0 gpu: add support for shader cache for the render server
BUG=b:213215649
TEST=run some gl and vk apps manually

Change-Id: I9250796f5fc3f086812d425ce2a3903cf3e0c2ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3384232
Reviewed-by: John Bates <jbates@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2022-01-19 18:49:42 +00:00
Anton Romanov
c20f783733 Enable some tests for armhf builds
TEST=./tools/dev_container --hermetic bash -c "./tools/run_tests --target=vm:aarch64 --arch armhf"
BUG=b/203152778

Change-Id: I76da1d029e9b11016b1ed9245c5b09095703fb63
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3328099
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
2021-12-14 18:11:32 +00:00
Abhishek Bhardwaj
8ca1345c02 crosvm: vvu: proxy: Implement activate and forwarding of master messages
This change caches the parameters received in the activate method. It
spawns a Worker thread to process Vhost master communication.
Furthermore, it forwards all non-action messages to the Vhost slave.

BUG=b:194136484
TEST=Compile.

Change-Id: Ie853add605ea4daa1c62ec9ce93cbac083e57de7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3288870
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
2021-12-13 21:57:50 +00:00
Keiichi Watanabe
75da78b21b vmm_vhost: Remove SlaveReqHandler type parameter in SlaveReqHelper
The type parameter `S: SlaveReqHandler` for `SlaveReqHelper` was
introduced to check if it's vvu or not.
Howver, SlaveReqHelper shouldn't take a type parameter of
`SlaveReqHandler` because the helper will be used in the VVU proxy
device which doesn't  have its own req_handler.

So, instead of taking the type parameter, we should have a new bool
field which indicates if it's VVU or not.

BUG=b:194136484
TEST=cargo test --all-features in vmm_vhost
TEST=kokoro

Change-Id: I35f20ef7c42cd74678ab5d87b68bbb58586d2fa5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320122
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-08 14:50:59 +00:00
Keiichi Watanabe
60334439a1 vmm_vhost: Parametrize Endpoint in Master trait
Allow having a Master struct with a backend other than socket. This will
be helpful for multi-platform support.

BUG=b:194137301
TEST=cargo test --all-features in vmm_vhost

Change-Id: Ie1bd8949ddb708c87a964544c6ae2fe7391b1fb5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320904
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-08 07:47:41 +00:00
Keiichi Watanabe
155d01df43 vmm_vhost: Implement From<UnixStream> for socket::Endpoint
Instead of having `from_stream()` method, use `From` trait.

BUG=b:206900656
TEST=cargo test --all-features in vmm_vhost

Change-Id: I8b6f06231c0b28e3e5f7b924221fe51f050c077b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3320903
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-08 07:47:40 +00:00
Keiichi Watanabe
5f5f6afacd vmm_vhost: Add TODO comments about IoSlice::advance_slice()
BUG=b:194137301
TEST=cargo test

Change-Id: I28466597209e4e81dc566d66d69875f59808eb0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3317325
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-08 07:47:39 +00:00
Keiichi Watanabe
7d4d02fc94 vmm_vhost: Expose connection::{socket, vfio} module
Expose connection::{socket, vfio} modules so that we don't need to have
prefix for structs there.
e.g. SocketEndpoint -> connection::socket::Endpoint

BUG=b:194137301
TEST=cargo test --all-features in vmm_vhost
TEST=cargo check in crosvm

Change-Id: I7d992a0df5a838fa6a726f366e9595b20405ec3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3317324
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-08 07:47:38 +00:00
Keiichi Watanabe
9c95cd2f8a vmm_vhost: Add VFIO backend for virtio-vhost-user
BUG=b:194137301
TEST=cargo test --all-features

Change-Id: I899c579779d51b7712ce4030856dfbe683c99df2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3270300
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-06 14:23:20 +00:00
Keiichi Watanabe
91f1262bcf sys_util: sock_ctrl_msg: Use IoSlice when sending buffers
Make `send_bufs_with_fd(s)` take `IoSlice` instead of `&[u8]`.
Note that no Chrome OS-side is needed for this API change because these
methods aren't used in any other Chrome OS projects.

BUG=b:204720423
TEST=cargo test in sys_utils and vmm_vhost

Change-Id: I02701d9c4e964ea95f0746b17254fa029fee7531
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3302696
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-06 14:23:19 +00:00
Abhishek Bhardwaj
1de3b5aef8 vhost_user: Modify signature of send_ack_message
send_ack_message used to take a module local Result as a parameter. It
doesn't make sense for other modules to use this. This change makes the
method take a bool instead of the aforementioned Result.

BUG=b:194136484
TEST=Compile.

Change-Id: I475cc39826db94ef2c686e754e13f478f8109d0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3285629
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-02 13:26:46 +00:00
Abhishek Bhardwaj
2a0b2fe699 vhost_user: Add helper class to abstract socket communication
This change adds a helper class that talks to the Vhost User Master.
This way the communication logic can be used by a Virtio Vhost User
Slave implementation as well as a Vhost Virtio User proxy device.

BUG=b:194136484
TEST=Compile.

Change-Id: I7d675c6739f7c8675320d956175c63c8d1190b79
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3285628
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-02 11:48:02 +00:00
Abhishek Bhardwaj
693396eb41 vhost_user: Expose members to be used by crosvm VVU proxy device
This change exposes members from the vhost_user implementation to be
used by the crosvm virtio-vhost-user proxy device.

BUG=b:194136484
TEST=Compile.

Change-Id: Ib2748f4e19138e08baaa6b2e8ae45f1b44c42cb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3285627
Commit-Queue: Abhishek Bhardwaj <abhishekbh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Abhishek Bhardwaj <abhishekbh@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-02 05:52:11 +00:00
Keiichi Watanabe
b3f4433512 vmm_vhost: Rename features to "vmm" and "device"
Rename feature names:
* vhost-user-master -> vmm
* vhost-user-slave -> devicwe

BUG=b:206900656
TEST=kokoro

Change-Id: I84b627b757421a2ea9f56018ad44e227df20ab8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3295220
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-01 09:45:48 +00:00
Keiichi Watanabe
40327e983a vmm_vhost: Simplify a match for error conversion
BUG=none
TEST=cargo test --all-features

Change-Id: Iec4d46b3d715c1c57a899a8c41df84d6a72e1b41
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3302695
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-01 09:45:47 +00:00
Keiichi Watanabe
6238a54f4a vmm_vhost: Flatten vhost_user module
Since vhost_user is the only module in vmm_vhost now, remove this module
and have everything in the top-level module.

BUG=b:206900656
TEST=cargo check

Change-Id: I6663a93654e5d692efc7d9904fff0d207144c352
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3295219
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-01 09:45:46 +00:00
Keiichi Watanabe
320203dcaa vmm_vhost: Expose vhost_user::Error directly
Remove the previous vmm_vhost::Error enum, as most of its variants are
no longer used. Instead, expose vhost_user::Error as the top-level one.

BUG=b:206900656
TEST=cargo check

Change-Id: Ic5d9f7dcc6e2986d7b51885e2c0f44aa4e012e5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3295218
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-01 09:45:45 +00:00
Keiichi Watanabe
48643234da vmm_vhost: Delete vhost-kern and vhost-vsock
Since we're using vmm_vhost only for vhost-user, we can delete
vmm_vhost's vhost-kern/vhost-vsock parts.
Note that we own vhost crate, which vmm_vhost was copied from.

BUG=b:206900656
TEST=cargo test --all-features in vmm_vhost

Change-Id: I622fbb856fb99fc2cb078d79f79491fa35ede8e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3295217
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-01 09:45:44 +00:00
Keiichi Watanabe
d7db2a7fea vmm_vhost: vhost_user: Drop recv_data() from Endpoint trait
By modifying the interface of `Endpoint::recv_into_bufs()` slightly,
`Endpoint::recv_data()` can be moved to `EndpointExt` trait.
This means a new device struct will be required to implement less
methods.

BUG=none
TEST=run vhost-user block device

Change-Id: I141eed0ff91aded5df5827cbc6965905820dac2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3288735
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-01 09:45:42 +00:00
Keiichi Watanabe
f7db2d5344 vmm_vhost: vhost_user: Change interface of Endpoint::recv_data
Stop returning the number of bytes along with data, as the value should
be obtained by `data.len()`.

BUG=b:204720423
TEST=cargo test --all-features

Change-Id: I0c9d143b2d9e657d61cc2469ba7270a170401b2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3288734
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-01 09:45:41 +00:00
Keiichi Watanabe
580d9f90f1 vmm_vhost: Avoid unnecessary Vec allocation
BUG=none
TEST=cargo test --features=vhost-user

Change-Id: I606a69244a3922a47298e4930732f04e337e1525
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3302694
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-01 09:45:39 +00:00
Keiichi Watanabe
a6da8a5406 vmm_vhost: vhost_user: Use IoSliceMut in recv_into_bufs()
Replace `&mut [u8]` in recv_into_bufs() with IoSliceMut.
Note that recv_into_bufs_all()'s interface is unchanged as it changes
internal cursor with advance().

BUG=none
TEST=cargo test --features=vhost-user-master,vhost-user-slave

Change-Id: I74666cd2472f879a473c07dbe617add79d0ca903
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3302693
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-01 09:45:38 +00:00
Keiichi Watanabe
dc069ba021 vhost_user: Introduce Endpoint trait
Introduce `Endpoint` trait and add `EndpointExt` trait as its blanket
implementation.
This trait generalizes the existing socket-based endpoint struct and
allow us to add a new VFIO device backend later.

BUG=b:194137301
TEST=vhost-user block device worked

Change-Id: I9c276bbbf14570b67d3c55507054f48e1210d019
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3270299
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-01 09:45:37 +00:00
Keiichi Watanabe
91019884bb sys_util: Replace unsafe use of iovecs
`sys_util::recv_iovecs_with_fds` was implemented as a safe function, but
it was actually unsafe because it assumed that the caller would give a
slice of `libc::iovec` where each `iov_base` points a valid memory
region with `iov_len`.

To make the function truly safe, it should take a slice of IoSliceMut
instead.

BUG=none
TEST=cargo test in sys_util/vmm_vhost
TEST=vhost-user block still works

Change-Id: I45458ee4545af13ce7e0955fb67b3703b147e7df
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3288733
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-11-26 14:28:28 +00:00
Daniel Verkamp
e5ada8f4a1 third_party/minijail: update to latest ToT
This matches the crosvm submodule to the version currently used in
Chrome OS: https://crrev.com/c/3230048

BUG=None
TEST=cargo build
TEST=tools/presubmit --quick

Change-Id: I7fadc5b1a4ecc26bd0598642966e088f1890a0d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3290322
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-11-18 08:44:34 +00:00
Keiichi Watanabe
74bfcdba28 vhost_user: Fix cfg for take_single_file
BUG=none
TEST=cargo test --all-features
TEST=cargo test --features=vhost-user passed with no warnings

Change-Id: I98e69309c6ec81ede3e790c9b6b8b79991484cc1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3288732
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-11-18 07:57:32 +00:00