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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
`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>
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>
This won't actually build as-is if the vhost-kern feature was enabled,
but since we don't use that feature currently, this unblocks building
crosvm without the rust-vmm vm-memory crate.
BUG=b:205511695
TEST=emerge-hatch -C vm-memory && emerge-hatch crosvm
Change-Id: I614616b38e796e28f13f0bb867e97c3be532305b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3290311
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
More SocketListener code to socket.rs so that we can easily add a new
file for a new VFIO backend. No behavior will be changed by this CL.
BUG=b:194137301
TEST=cargo test --all-features
Change-Id: I8d987f85a63ba666619882559e5cceddd91814bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3268268
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Rename Listener struct to SocketListener and introduce Listener trait.
This is a preparation for adding VFIO backend for virtio-vhost-user.
BUG=b:194137301
TEST=cargo test --all-features --all-targets
Change-Id: Iea1e5b4378606b696c4022e3e2e6f4bbf80be55f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3268267
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Implement DataInit for message structs and use `.as_slice()` when
sending them.
This change makes `trait Req` require `Send + Sync`. This is needed to
implement `DataInit` for `VhostUserMsgHeader<R> where `R: Req`.
BUG=b:204720423
TEST=cargo test --all-features
Change-Id: Icd32861b8d4fef16606a35b387c35271aebe061a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3268265
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Fix clippy::bool_assert_comparison and clippy::needless_borrow, which
were temporally added at crrev.com/c/3267912.
Most changes are trivial.
`test_should_reconnect` in vhost_user/mod.rs was deleted because the
test doesn't make much sense as a unit test, because it just copies and
pastes the logic of `Error::should_reconnect()`.
BUG=b:205511695, b:204720423
TEST=./tools/clippy
TEST=cargo test --all-features in third_party/vmm_vhost
Change-Id: I664b3aa7df054871d7e127b6dffd0315f9d4c48c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3267918
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Remove vmm-vhost's OWNERS file because it became a part of the crosvm
repository now.
BUG=b:205511695
TEST=kokoro
Change-Id: Iba9f64e647d905a4bdd4580b0115bb79085c9a9c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3267921
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Move rust-vmm/vhost code from chromiumos's third_party directory to
crosvm's one.
Note that we have crrev.com/c/3269863 for license files in Chrome OS
ebuild.
Changes:
* Copied vmm_vhost files at "7c95b4a2 rust-vmm/vhost: switch to upstream
tempfile", whose latest upstream commit is "488b3adc fix warning:
unaligned_references".
* Remove [patch.crates-io] section from its Cargo.toml.
* Add attributes to skip `clippy::bool_assert_comparison` and
`clippy::needless_borrow`, which will be fixed in following CLs.
* Update crosvm's Cargo.toml and tools/chromeos/setup_cargo
BUG=b:205511695
TEST=tools/chromeos/setup_cargo && cargo build
Change-Id: Icee201b39ff1d352df59469a6c8668fc7cb92ab9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3267912
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
This fixes the annoying __pycache__ files virglrenderer used to
create.
BUG=b:200554399
TEST=./tools/presubmit passes
Change-Id: Ib5bfa5205f0b1432243ef53ec1b5a14d6cdd10d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3232278
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
This includes https://r.android.com/1835176 in order to prevent bindgen
from modifying libminijail.rs on every build, causing the submodule to
be marked as dirty.
BUG=None
TEST=cargo build
TEST=./test_all
Change-Id: I73e97231c37ef49bff463b7cc282a1cb42d7bc84
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3209926
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>