Commit graph

93 commits

Author SHA1 Message Date
Keiichi Watanabe
0ea1263f71 vmm_vhost: Remove unnecessary cfg
BUG=none
TEST=`cargo check` in vmm_vhost succeeded without any warnings

Change-Id: I3adede28406a930bc54c5b0b0fd288fc42a4de89
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3932450
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-10-05 02:35:33 +00:00
Keiichi Watanabe
07c9bdf352 vmm_vhost: sys: Align platform-specific code with style guide
Update /third_party/vmm_vhost/stc/sys.rs to align it with the code
organization described in
https://crosvm.dev/book/contributing/style_guide_platform_specific_code.html#code-organization

BUG=none
TEST=cargo check in /devices
TEST=cargo check --target=x86_64-pc-windows-gnu in /devices

Change-Id: I4f4035aadcd800335ceb035ab9645c2e6c6b0732
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3932449
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2022-10-05 00:39:19 +00:00
Keita Suzuki
50181346e6 devices: vhost-user: block: Add hot-resizing feature in vhost-user block
Current implementation does not allow hot-resizing feature to be used in
vhost-user block devices because the backend device cannot notify the
frontend that the device configuration has changed. Fix this by adding
and establishing the backend to frontend vhost-user message connection to
the vhost-user block backend, send the HANDLE_CONFIG_CHANGE_MSG to the
frontend, and send interrupt to the guest kernel from the frontend
device when receiving the message.

BUG=b:191845881
TEST=cargo run devices -s /path/to/socket.sock --block ...
cargo run run --vhost-user-blk /path/to/vhost-sock,
cargo run disk resize 0 $SIZE /path/to/socket.sock

Change-Id: Ifab75d65c429dfcea5e632b899f014278a6e6750
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3859218
Commit-Queue: Keita Suzuki <suzukikeita@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Morg <morg@chromium.org>
2022-10-04 12:50:16 +00:00
Keita Suzuki
24630fe1e4 devices: vhost-user: allow backend device to send vhost-user message
Current implementation of vhost-user backend devices cannot directly
send vhost-user messages from the backend to the frontend since the
established connection is stored directly to `VhostShmemMapper`. This
limits the messages that could be sent to memory share-related messages.

To overcome this limitation, introduce struct `VhostBackendReqConnection`
which exposes the required backend to frontend requests and keeps track of
the underlying transport (struct `Slave`), and refactor `Slave` out from
current VhostShmemMapper.The state of the connection is managed using enum
`VhostBackendReqConnectionState`.

This patch also moves the timing of when `BackendReqHandler` is created in
the frontend to when `VhostUserProtocolFeatures::SLAVE_REQ` is negotiated
when creating VhostUserHandler.

BUG=b:191845881
TEST=run ./tools/run_tests

Change-Id: I90235a527d58067f73a509907b4cefc09516f562
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3856036
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-10-04 12:50:16 +00:00
Idan Raiter
73cd3e24fa devices: Implement MasterReqHandler for Windows
Brings up the master request handler on Windows. To stay within the
existing protocol, PackedTube was introduced, which is able to transmit
a Tube via a RawDescriptor.

BUG=b:221882601
TEST=presubmit & cargo test & tested downstream

Change-Id: Ibd4c2f55c42738392beed5b15b8d445e47890627
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3856828
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-09-12 16:09:34 +00:00
Keiichi Watanabe
c8e21ca15c vmm_vhost: Replace super:: with crate::
Since specifying module with absolute paths (`crate::`) is preferred over
relative path (`super::`), replace all of them except `super::*` in
`tests` modules.

BUG=none
TEST=cargo test --all-features in vmm_vhost

Change-Id: I90d4906c02505395358c8722bcbb7d0bb3024733
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3863044
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-09-01 15:05:40 +00:00
Keiichi Watanabe
53e745078a vmm_vhost: Enable health-check for third_party/vmm_vhost
Make tools/health-check cover third_party/vmm_vhost, as we are
maintaining vmm_vhost by ourselves and we don't pull the upstream
changes so frequently unlike other third_party components.

This CL includes:
* updates in scripts under /tools, and
* the auto-gerated changes by `./tools/fmt --nightly`

BUG=b:239937122
TEST=cargo check

Change-Id: I12956a60bb24764ffb541261c7fb3f09eb974dd8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3863043
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
2022-09-01 15:05:31 +00:00
Idan Raiter
5419f1907b vmm_vhost: make shared memory protection flags cross-platform
The existing flags assume unix libc read = 1, write = 2. On Windows we
have read = 4, write = 2. We can implement the conversion between
base::Protection and VhostUserShmemMapMsgFlags to keep the protocol
itself separate from the platform flags.

BUG=b:221882601
TEST=presubmit & tested downstream

Change-Id: I6fe69df679926b240f7d02dfbbf0704bbca5a5b0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3860646
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
Tested-by: Idan Raiter <idanr@google.com>
2022-08-31 19:06:48 +00:00
Daniel Verkamp
209151ebea vmm_vhost: eliminate unnecessary collect() into a Vec
The `buf_lens` vector was created only to be destroyed in the next line.
Just use `sum()` on the buf iterator.

BUG=None
TEST=tools/presubmit --all

Change-Id: Iddfa4f783b6eda326b9dbb9c6a1f443b7976ca2c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3858688
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-30 21:59:15 +00:00
Dennis Kempin
38b9268cb8 health-check: Add infra checks
Adds presubmit checks for both lucicfg files and python recipes.

Both can "fix" issues by re-generating configs / test expectations.

This adds depot_tools as a submodule to crosvm, which contains the
required tools for luci.

Does not validate the infra config. Unfortunately this is only
possible with luci authentication which we do not have inside
Docker.

BUG=b:242605601
TEST=./tools/health-check with changes to config and recipes.

Change-Id: I1bf18ebac698e44df7d6a0d6c8e9c26bcfde364b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3832783
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-08-18 00:17:04 +00:00
Dennis Kempin
5237c0773f Revert "third_party/minijail: update to latest main"
This reverts commit edbce26cc8.

Reason for revert: git seems to be unable to find the new sha for some
reason. 

Original change's description:
> third_party/minijail: update to latest main
>
> This advances the minijail submodule to the current state of main,
> commit b8e916498f3a ("minijail: update README to reflect new Chromium
> location.").
>
> BUG=None
> TEST=tools/presubmit --all
>
> Change-Id: Id9b240aedc80c72b28fc82a5076de5e92b0dc93b
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3820347
> Reviewed-by: Dennis Kempin <denniskempin@google.com>
> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
> Tested-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: Dennis Kempin <denniskempin@google.com>
> Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>

Bug: None
Change-Id: I322a598300658b2eaf4a1f8d6b5ad6637d40ecc0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3821462
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-09 23:00:30 +00:00
Daniel Verkamp
edbce26cc8 third_party/minijail: update to latest main
This advances the minijail submodule to the current state of main,
commit b8e916498f3a ("minijail: update README to reflect new Chromium
location.").

BUG=None
TEST=tools/presubmit --all

Change-Id: Id9b240aedc80c72b28fc82a5076de5e92b0dc93b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3820347
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
2022-08-09 22:22:16 +00:00
Vikram Auradkar
925ba7a1fb crosvm: Fix clippy related warnings
Ran clippy with features that are enabled downstream. Those features
will be enabled upstream in later cls when crosvm starts building.

BUG=b:213146388
TEST=presubmit

Change-Id: I67cb74127a349b572e573c350d69d1611533d961
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3793690
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: Vikram Auradkar <auradkar@google.com>
2022-07-29 17:49:31 +00:00
David Stevens
bf7058d434 devices: vvu: support backend request channel
Support backend request channels (i.e. slave_req_fd) with vvu. The
backend channel is proxied with the same virtqueue as the frontend
channel, so this requires muxing and demuxing the messages in the proxy
and device handler respectively. Supporting this in the device handler
requires making the backend channel a vmm_vhost Endpoint rather than a
plain File, to allow the platform-specific Connection to construct the
proper Endpoint.

BUG=b:201745804
TEST=launch sibling VM on manatee

Change-Id: Ibada1764fc74ed759f59fc5f483bb17e1b269abd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3765017
Commit-Queue: David Stevens <stevensd@chromium.org>
Tested-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-07-28 04:54:40 +00:00
Dennis Kempin
4fea399df9 Reformat imports
crosvm is switching the import style to use one import per line.
While more verbose, this will greatly reduce the occurence of merge
conflicts going forward.

Note: This is using a nightly feature of rustfmt. So it's a one-off
re-format only. We are considering adding a nightly toolchain to
enable the feature permanently.

BUG=b:239937122
TEST=CQ

Change-Id: Id2dd4dbdc0adfc4f8f3dd1d09da1daafa2a39992
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3784345
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-07-28 00:15:50 +00:00
Alexandre Courbot
eb9e563e4d virtio: vhost: user: allow listener to yield resources for parent process
A listener is responsible for managing and cleaning up its own
resources, but this can cause problems when jailing device processes.

Typically, the listener is created in the parent thread and then passed
to the device thread so the device thread does not require the
capabilities to allocate the listener's resources. However, when cleanup
time comes, the listener in the child is still responsible for
destroying the resources created by the parent, which may require extra
capabilities. For instance, for a vhost-user socket the listener is
expected to remove the socket file, but we don't necessarily want the
child to be able to remove files from the filesystem...

Fix this by adding a new method, take_parent_process_resources(), that
can be called prior to creating the child process by the parent in order
to obtain the resources that the parent needs to cleanup when the child
process exits. The resources are presented in the form of an opaque box
and must be kept by the parent until the child process exits. After
that, dropping the box will free the resources that we don't want the
child to clean up.

If we are not creating a child process, then the method is simply not
called and the listener will cleanup the resources itself.

BUG=b:218223240
TEST=vhost-user console device gets properly cleaned up.

Change-Id: I7b8c4b700a868f4fd100c45f0e577fddfe8bb216
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3762972
Reviewed-by: Morg <morg@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-07-22 04:57:58 +00:00
David Stevens
f436e27060 vmm_vhost: add shared memory region support
Add support for shared memory regions to vhost-user. This is adding
support for a front-end message to query for necessary shared memory
regions plus back-end message to support mapping/unmapping files from
the shared memory region.

go/vvu-shared-memory

BUG=b:201745804
TEST=compiles

Change-Id: I35c5d260ee09175b68f6778b81883e0070ee0265
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3716344
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-07-12 01:13:14 +00:00
David Stevens
e0293591f4 vmm_vhost: switch listener and endpoint relationship
Make Listener type depend on Endpoint, instead of Endpoint type
depending on Listener. This will allow Endpoints to be used for the
slave_req_fd.

BUG=b:201745804
TEST=compiles

Change-Id: I1a0732bf7477a4e768f348f78e352a3b53607633
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3716342
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-07-07 00:58:11 +00:00
David Stevens
31f04e9270 vmm_vhost: fix receiving reply payloads
The existing code confuses the length of the request with the length of
the reply in recv_reply_with_payload. This makes it impossible to use
for any requests where the reply differs in size. Fix this by
determining payload size after reading the reply header.

BUG=b:201745804
TEST=compiles

Change-Id: Iec21918e45b81d299f3178e7893e146cbd4c7db7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3716343
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-07-01 08:13:52 +00:00
David Stevens
540872395e vmm_vhost: add Send trait to Endpoints
BUG=b:201745804
TEST=compiles

Change-Id: I8cca96a54bce0aa74f43dc1ff82e3af199118414
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3716345
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-07-01 05:51:19 +00:00
Alexandre Courbot
da0025851c devices: vhost-user: handler: make run_with_listener() generic
The run_with_listener() method can now be made generic and be used for
both the socket and VVU handlers.

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

Change-Id: Ic1ae286e573383d6b66c8a406227d6cf51cbd578
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3592633
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-06-08 02:29:21 +00:00
Alexandre Courbot
d60bf43903 devices: vhost-user: handler: stop spawning a thread for the socket listener
The async methods of the socket VVU handler were calling the non-async
accept() on a dedicated thread so the async method does not get blocked
awaiting for a connection. This socket-specific behavior forces us to
have dedicated code for the socket and VVU handlers.

Fix this by adding a poll_descriptor() method to vmm_vhost's Listener
trait that returns a descriptor that callers can poll on if a call to
accept() can block. This way we can wait for the connection
asynchronously and avoid using a thread for that. It also opens the way
towards factorizing the socket and VVU specific code.

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

Change-Id: I3fbc96d3904f777c6165b04564f577c553ce55d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3592632
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-06-08 02:29:20 +00:00
Noah Gold
a89e65beb1 third_party: libslirp-rs: remove unused files.
These files are not used, and libslirp-rs is not a functional crate.
Only context.rs is used in heavily forked form as a part of crosvm's `net_util`.

BUG=b:213151463
TEST=n/a

Change-Id: I6536cde7ff2beed655e83c3d920c6940ed4969a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3650467
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-06-02 03:00:37 +00:00
Noah Gold
1977979fbb net_util: upstream Windows support
Adds the libslirp interface code, as well as the Windows pseudo-tap
device.

BUG=b:213151463

TEST=bots (unix + windows)

Change-Id: I975b27a76c82e25037d4061587fec0c31222a159
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3598234
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-06-02 03:00:36 +00:00
Noah Gold
465479699b third_party: clone libslirp-rs
libslirp-rs cloned from 19553209436ae7b9e036641f4013246111192d5c.

BUG=b:213151463
TEST=n/a

Change-Id: I560bb39ca96e68b3cf2654690bb3feb3af0325a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3650466
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-06-02 03:00:35 +00:00
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