Commit graph

215 commits

Author SHA1 Message Date
Frederick Mayle
78a0f3d042 vmm_vhost: mark Endpoint as !Sync
It isn't safe to send or recv messages concurrently. The byte stream
could get mixed up.

Change-Id: I27039d3f44d5d8ec609ce7974c6f2f3fcbd9768c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5068397
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-28 23:26:47 +00:00
Frederick Mayle
6bfa3f6ce9 vmm_vhost: simplify header reads in Endpoint
Change-Id: Ic287525c91d5890bb5a09fcbe6c872ea427cb677
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5066132
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-28 23:26:47 +00:00
Frederick Mayle
e44284f9de vmm_vhost: tidy up Endpoint API
`Endpoint` has mixture of raw socket methods and vhost-user message
framing methods. This CL hides all of the raw socket methods so that the
type is focused on message framing.

The recv methods' names were changed to more closely match the send
method names. The documentation for returned errors has been deleted
because much of it was out of date.

Change-Id: I55a4f8bea5902fafd8b52468e140de5aa61c5539
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5066131
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-28 23:26:47 +00:00
Frederick Mayle
620687c9dc vmm_vhost: remove more unnecessary &mut self
Follow up to https://crrev.com/c/5064382.

Change-Id: I0d723f765be4b846b0feb679d8e86d423d56345a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5068396
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-11-28 23:26:47 +00:00
Daniel Verkamp
93bb2d9058 vmm_vhost: remove unused SystemListenerExt
This was only implemented for unix and is never called anywhere. The
listener code just calls SocketListener.accept() directly, and Windows
does not implement a Listener anyway, so this doesn't help abstract
anything.

Change-Id: I44503e37bccfd180101a91879abc592242187979
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5068395
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-28 23:08:33 +00:00
Frederick Mayle
d63f9eea7c vmm_vhost: fix type complexity clippy warning
Change-Id: I0522ac1143f35f9045af6f9489d77ca6e47a19b1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5066130
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-11-28 22:30:56 +00:00
Frederick Mayle
50cbe0cade vmm_vhost: inline Endpoint::recv_data
Convenience methods like this aren't worth the mental overhead IMO.

Change-Id: I2c08cf64b781328f515b88373170c4506058814c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5066129
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-28 22:30:56 +00:00
Frederick Mayle
98e465673b vmm_vhost: inline Endpoint::recv_body_into_buf
It isn't well differentiate from the other methods and inlining it is a
net win in lines-of-code.

Change-Id: I829a96dc4de5f4ee579b1a5beb9b09efddfdcd53
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5066128
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-28 22:30:56 +00:00
Frederick Mayle
bc9058e05f vmm_vhost: move unexpected EOF check into Endpoint::recv_into_bufs_all
This changes the behavior of `Endpoint::recv_body_into_buf` a bit, but
it is only used by a test and the new behavior within the test is
equivalent (if something goes wrong, the `Result::unwrap` will fail
instead of an `assert_eq!`). I'll try to delete that method in a follow
up.

Change-Id: I6a25fb1329575fb641720a43bbb29b53f0996a6d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5065427
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-28 22:30:56 +00:00
Frederick Mayle
f7d5f0b401 vmm_vhost: move unexpected EOF check into Endpoint::send_iovec_all
Change-Id: I53fa9af5c2ff7c5515092c467943688aaaba5230
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5065426
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-11-28 22:30:56 +00:00
Daniel Verkamp
cc6191d72c vmm_vhost: remove dead code in frontend
protocol_features and protocol_features_ready were set but never read.

hdr_flags could only be set via set_hdr_flags(), which was never called.

as_raw_descriptor() was only needed for a unit test, which can peek into
the innards of the struct instead, resolving a TODO about its purpose.

BUG=b:221882601

Change-Id: Ic5fbe9353aa3de92b8413b04bfbe16fdc7e5dd0a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5065409
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-28 19:38:11 +00:00
Daniel Verkamp
eab655cc92 vmm_vhost: remove Master lock
The Master struct previously contained an Arc<Mutex<MasterInner>>, but
the only user (VhostUserVirtioDevice) did not need the thread safety
guarantees of a mutex (neither Sync nor Send is necessary). A few
functions on Master used the mutex for inner mutability, but these can
be fixed by just making the functions in question take &mut self instead
of only &self.

Change-Id: I09f344b15c172f4bb671ab3bbd76b2be4614de6d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5064382
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-11-28 19:33:29 +00:00
Daniel Verkamp
d34b36c693 vmm_vhost: VhostUserMemoryRegionInfo cleanup
The mmap_handle and mmap_offset fields are not optional, so the comments
are adjusted to match reality.

Only one test function needed the Copy, Clone, and Default impls, which
can be avoided by tweaking the test (while also making it more useful,
since it tests exactly one failure instead of multiple).

BUG=b:221882601

Change-Id: Icc45577435aa27b18384cd10cb273c5152ad55ac
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5063681
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-11-28 01:26:48 +00:00
Daniel Verkamp
f28c1d3bc8 vmm_vhost: rename linux modules back to unix
The "Linux" code depends only on AF_UNIX sockets, which should be
available on any unix-like platform.

Change-Id: Icced9594bf61215fce39e2702cf2aeed86ea42a4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5063680
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-28 01:26:48 +00:00
Daniel Verkamp
fca49a3980 vmm_vhost: remove vmm and device features
crosvm always enables both of these features, and the crate doesn't
build properly without them enabled anymore due to our local changes, so
just drop the features and all cfg checks for them.

TEST=(cd third_party/vmm_vhost/; cargo test)

Change-Id: I02f9caca387846dd24d9486284b064897f275205
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5063679
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-28 01:21:42 +00:00
Frederick Mayle
24bfd9a07b vmm_vhost: delete unused associated type Listener::Connection
Change-Id: Icb5e24959d0ed12fe8c06072b20d8b72ebd11a25
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4844143
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-27 23:04:14 +00:00
Frederick Mayle
526e886f98 vmm_vhost: rename unix Listener impl to SocketListener
Also, switch `run_with_handler` to use the concrete type since it is in
a unix only file already.

Change-Id: I512d582ee5407f2e3b830ac8c5caaae12c714c15
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4844142
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-27 23:04:14 +00:00
Frederick Mayle
4fa985cf0a vmm_vhost: turn Endpoint into a concrete type
Since VVU support was dropped, there is now only one Endpoint
implementation (per platform) and so we can remove the related
generics.

Change-Id: Ica35a93dc43326ecb182e0ddeb80cba98f68fb2d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4844141
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-27 23:04:14 +00:00
Frederick Mayle
0419cd9401 vmm_vhost: rename unix Endpoint impl to SocketEndpoint
This matches the Windows Endpoint naming (TubeEndpoint) and helps avoid
confusion with `trait Endpoint`.

Change-Id: Idd3d8c84e995e38dad68848c8bd5b2188f619485
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4844140
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-27 23:04:14 +00:00
A. Cody Schuffelen
3210820847 Convert ScmSocket to a struct
On MacOS there is no MSG_NOSIGNAL, but there is SO_NOSIGPIPE which is
set as a socket option. This changes ScmSocket from a trait to a wrapper
type that can guarantee SO_NOSIGPIPE is set once on every relevant
socket before it is used in situations that can produce signals.

The biggest wrinkle is that setsockopt can produce errors, which makes
the conversion into ScmSocket a case that can possibly error. Not all
places that accept sockets were prepared to return errors.

Bug: b/309020556
Change-Id: I079bbaf8803e137ca7c0e0ebe60e63de5df59cc0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5021438
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
2023-11-22 05:47:15 +00:00
Dmitry Osipenko
571c94478e virglrenderer: Uprev submodule
Uprev virglrenderer submodule to version 1.0, which brings new APIs needed
for enabling new features in crosvm. In particular this allows to enable
fence passing feature in crosvm.

TEST=none
BUG=b:253779836
Link: https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1138
Change-Id: I831a75eaa8056f2fef3f3bf6d68e005002ac93cb
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4890314
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2023-11-17 03:15:47 +00:00
dawnhan
6804b12009 third_party: Update third_party/minigbm submodule
BUG=b/265199561
TEST=CQ

Change-Id: I3fdd393d50b7805aedbe7cfeec55a7652b71e552
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5003371
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Dawn Han <dawnhan@google.com>
2023-11-14 19:51:21 +00:00
Daniel Verkamp
5c43797eb7 base: change Protection representation to bools
This makes the generic Protection code more portable and allows removal
of the unix-specific PROT_READ and PROT_WRITE constants from the base
public API.

Users of base should not need to change anything if they were already
using the Protection pub APIs (read(), write(), etc.)

BUG=None
TEST=tools/dev_container tools/presubmit

Change-Id: I4100e333e1a2133d54942780ddd79f722194f487
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5013638
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-10 20:37:59 +00:00
Vikram Auradkar
8dacb2ed64 config: force lf as line endings
this allows sharing repo on windows running a linux container

BUG=b:308883445
TEST=on windows ran
       py .\tools\dev_container tools/presubmit line_endings

Change-Id: Ief73f1ad2da201dac0337711d0c4f706a936f7a6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5008193
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2023-11-07 17:38:58 +00:00
Daniel Verkamp
3c1d96ac07 Fix unnecessary vec![]
Change-Id: I8df666fbd1df47c0ca3231091aff0aab2c663106
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5005515
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-11-06 21:08:56 +00:00
A. Cody Schuffelen
4748c54b95 Rename "unix" to "linux" in code and docs
$ for DIR in $(find . -name "unix"); do mv $DIR $(echo $DIR | sed "s/unix/linux/"); done
$ for FILE in $(find . -name "unix.rs"); do mv $FILE $(echo $FILE | sed "s/unix/linux/"); done
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -E -i "s/mod unix/mod linux/g" {}
$ find . -type f -not -path '*/\.git/*' -not -path '*/third_party/perfetto/*' | xargs -I {} sed -E -i "s/([^o][^s])::unix/\1::linux/g" {}
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -E -i "s/use unix::/use linux::/g" {}
$ find . -type f -not -path '*/\.git/*' -not -path '*/third_party/perfetto/*' | xargs -I {} sed -E -i "s/sys::unix/sys::linux/g" {}
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -E -i "s/use unix as platform/use linux as platform/g" {}

Test: ./tools/dev_container ./tools/presubmit
Bug: b/298269162
Change-Id: I2c8acb14d77a5588dab4eae124f4a9afbb9025f5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4909060
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-10-11 01:15:07 +00:00
A. Cody Schuffelen
97dff044f8 Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))]
Updates are made to source and documentation.

This more accurately represents the currently supported platforms of
Android/Linux and Windows, without unexpectedly including other
unix-like operating systems.

Command to reproduce:
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -i 's/cfg(unix)/cfg(any(target_os = "android", target_os = "linux"))/g' {}
$ cargo fmt

md files manually updated to fix line lengths.

Renaming `unix` modules to `linux` will be done in a later CL.

Test: ./tools/dev_container ./tools/presubmit
Bug: b/298269162
Change-Id: I42c1bf0abf80b9a0df25551613910293217c7295
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4909059
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-10-11 00:43:29 +00:00
Zihan Chen
a5e63d4474 crosvm: Remove DataInit
DataInit type is finally completely eliminated from crosvm. No
traces, not even in comments, were left.

BUG=b:300969352
BUG=b:204409584

Change-Id: I79742f8e06b90afd53fab338d9052b25ae0af84e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4878508
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-10-10 19:40:48 +00:00
Zihan Chen
cbba480ebe crosvm: Uprev zerocopy to 0.7.x
zerocopy 0.7.x has finally released as a stable version, uprev it
to allow some remaining structs to be derivable.

TEST=CQ

BUG=b:300969352
FIXED=b:300969352

Change-Id: I90f0dfb09494f875fef1cd11bfcbd48030846092
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4878761
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-10-10 17:34:32 +00:00
Daniel Verkamp
03dd1feab7 Cargo.toml: depend on zerocopy 0.6 explicitly
Previously all of the zerocopy imports just used "*", but there are
API changes in zerocopy 0.7, so ensure we get a compatible version by
depending on 0.6 everywhere.

This is a no-op since Cargo.lock already specifies a 0.6.x version, but
it will prevent accidentally upgrading to 0.7.x without updating to the
new API.

BUG=b:301283548
TEST=cargo build

Change-Id: Ifd702d982a09b5083dddd666dc6f3052cba22214
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4878502
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-09-20 21:28:58 +00:00
Daniel Verkamp
f5182d3e81 vmm_vhost: normalize disconnect error for Tube connections
Make the vmm_vhost Tube connection (used on Windows) match the behavior
of the Socket connection (used on Linux) by returning the specific
VhostError::Disconnect type rather than a generic TubeError when the
client disconnects. This also propagates into the special handling in
recv_header() that translates a VhostError::Disconnect into a
VhostError::ClientExit when the client exits at a clean point in the
connection.

Change-Id: If22e319f1e3657d95610601eb00eaab237aabd2f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4854945
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-09-14 18:36:14 +00:00
Daniel Verkamp
b90ea46b74 vmm_vhost: replace more unsafe casts with zerocopy
The zerocopy LayoutVerified functions validate the alignment and length,
which helps clean up the code a bit. Additionally, it means we can
remove some more unsafe blocks, which is always nice.

BUG=b:204409584
TEST=tools/dev_container tools/presubmit

Change-Id: Ie5b3c78cd0710a409c6ba097ed16c2a974cffbb8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4860830
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2023-09-13 21:29:47 +00:00
Daniel Verkamp
fe0d321efd vmm_vhost: rename PROTOCOL_FEATURES to match the spec
Use the full VHOST_USER_F_PROTOCOL_FEATURES name and define it as a
shift count rather than a bitfield!() macro invocation to match every
other virtio feature.

No functional change.

BUG=None
TEST=tools/dev_container tools/presubmit

Change-Id: I115b223ae3e5096af147324ad142afb592a5ca2c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4697476
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-09-11 20:14:39 +00:00
Daniel Verkamp
40114fd26e Remove virtio-vhost-user (VVU) support
This code is unused and untested, while simultaneously making the rest
of the virtio device code more complex. Remove it.

BUG=b:276993009
TEST=tools/dev_container tools/presubmit

Change-Id: I9d44f92419c6912d1735043404d4f64efc95bba4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4676076
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
2023-09-05 17:59:33 +00:00
Frederick Mayle
54bacb2a2c vmm_vhost: avoid redundant iovec alloc in recv_into_bufs
Change-Id: I05d437eb14197bf81496070427f1b2029761cbd3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4834118
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-09-01 21:21:56 +00:00
Frederick Mayle
b19ed52184 vmm_vhost: fix clippy::unnecessary_unwrap warning
Change-Id: Ia4b1b31d67fe24a62896358b35105378074090c5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4553725
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2023-09-01 21:21:56 +00:00
Frederick Mayle
d297f766d4 vmm_vhost: delete VhostBackend and VhostUserMaster traits
There is only one implementor right now and it seems unlikely we'll need
to support multiple vhost-user frontend implementations in the future.

Note that there are a few other very similar looking traits like
VhostUserSlaveReqHandler (used for backend implementations) and
VhostUserBackend (also used for backend implementations, but at a
different abstraction level).

The documentation of the traits was moved to the implementations. In
some cases there were redundant docs and so I made a judgement call on
which to keep.

Change-Id: Ib69270160c375c900fd9e3356cb387b78e4983be
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4553724
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-09-01 21:21:56 +00:00
Frederick Mayle
2c0a9c21a9 vmm_vhost: delete unused trait VhostBackendMut
Change-Id: Idc2591ca1785f8c769225864112d0e30ee642209
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4553723
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2023-09-01 21:21:56 +00:00
Frederick Mayle
f77cb5c104 vmm_vhost: dissolve SlaveListener
This abstraction doesn't add much value and makes the `accept` call
dangerous (if `accept` is called after it returns `Some`, then it will
panic).

Change-Id: I0c749fccef582128bb66eb95132103427e2abf58
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4827925
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2023-09-01 21:21:56 +00:00
Daniel Verkamp
f76f4230af vmm_vhost: remove unsafe u32 -> enum transmutes
The Req trait and related code relied on transmuting arbitrary u32
values into an enum that might not be one of the valid enum branches;
this has always been undefined behavior in Rust, and now it is actually
causing failures at runtime (tests compiled with Rust 1.71.1 in release
mode crash, since the compiler intentionally emits an illegal
instruction for the transmute in a test).

Rework the code so instead of transmuting it first and checking for the
is_valid() function later, we require Req to implement TryFrom<u32> and
make VhostUserMsgHeader::get_code() return a Result so that callers must
check that the code is indeed valid.

Ideally, this code should be refactored so that the VhostUserMsgHeader
is checked once when it is received rather than each time get_code() is
called, but that would be a larger change, so it is left as a potential
future cleanup.

BUG=b:297923761
TEST=cargo test --release -p vmm_vhost # w/rust-toolchain = 1.71.1
TEST=tools/dev_container tools/presubmit

Change-Id: I8d24dd9d81ee107f9ab43ea7bf68145c380364db
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4824412
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-08-29 23:38:03 +00:00
Alyssa Ross
6795b3edf3 vmm_vhost: renumber SHARED_MEMORY_REGIONS
0x0002_0000 is now standardized as VHOST_USER_PROTOCOL_F_XEN_MMAP[1].
Renumber SHARED_MEMORY_REGIONS to an available value to avoid
interoperability problems with other vhost-user implementations.

(It would be nice if VHOST_USER_PROTOCOL_F_SHARED_MEMORY was
standardised, to avoid this problem in future!)

[1]: f21e95ee97

TEST=run crosvm vhost-user-gpu device with cross domain

Change-Id: I56c36e5ef75b68fd4244dee1206a2cd1bee7c452
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4727935
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-08-07 17:41:47 +00:00
Daniel Verkamp
6540c7e29d devices: vhost-user: vmm: remove max_queue_num
The vmm handler code does not need to check that the queue index is in
range. This is already checked in two places already: the generic
VirtioDevice code will not produce invalid indexes, and the backend
vhost-user device must be prepared to handle invalid indexes by
returning an error.

Removing the max_queue_num parameter will help in cleaning up the
VhostUserVirtioDevice QueueSizes mechanism.

BUG=b:262291811
TEST=tools/presubmit --all
TEST=boot x86_64 Linux from a vhost-user block device

Change-Id: Ia44cb916aedadf0fbdecec8f0bf0d0299cc5816b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4103911
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-08-02 20:14:27 +00:00
Federico 'Morg' Pareschi
69eaeacde3 third_party: Add crosvm/perfetto submodule
This CL is just adding the already-commited perfetto repository as a
third_party submodule to crosvm.

BUG=b:277837670
TEST=None

Change-Id: Ia5c6e41e0a770bb7b4d55558c36331f66f97a81d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4705405
Auto-Submit: Morg <morg@google.com>
Commit-Queue: Morg <morg@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-07-21 05:01:47 +00:00
Daniel Verkamp
ce5a78e83b clippy fixes for Rust 1.70 and 1.71
Change-Id: If86c6cd531b854293a93208de5254664f5ee6bec
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4637612
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-07-13 20:29:05 +00:00
Zihan Chen
c244741015 crosvm: Deprecate DataInit
- The remaning DataInit are all left due to limitations of the
current stable version of zerocopy
- Only 5 files still use DataInit
- DataInit is marked as deprecated to prevent future introduction
- Other mentions of DataInit across the repository are cleaned up

TEST=CQ

BUG=b:204409584
FIXED=b:204409584

Change-Id: Id7126e58cff63eaa67138de429375382a3ffbc55
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4680289
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-07-12 21:34:20 +00:00
Zihan Chen
7b0b071cba third_party/vmm_vhost: Remove all DataInit besides VhostUserMsgHeader
VhostUserMsgHeader is a generic type and requires updated zerocopy
to be able to derive AsBytes. Everything else in this folder is
cleaned up.

TEST=CQ

BUG=b:204409584

Change-Id: Ic86dd577969cb79648898fa3071a262824faeef7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4679845
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Zihan Chen <zihanchen@google.com>
2023-07-12 20:45:13 +00:00
Daniel Verkamp
0c29eac704 devices: virtio: factor Queue into QueueConfig+Queue
This change creates a new type (QueueConfig) that represents a queue
configuration before it has been activated. The QueueConfig::activate
function serves the same purpose as the previous Queue::activate, but
now it also returns the Queue type, which now always represents an
actively running queue.

BUG=b:290268617
TEST=tools/dev_container tools/presubmit

Change-Id: I502ac6b29bf9f0cfc33ef15f6fb7fe482214eafd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4111872
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Yuan Yao <yuanyaogoog@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
2023-07-12 20:21:02 +00:00
Zihan Chen
39df0a2550 thirdparty/vmm_vhost: Partially convert DataInit to zerocopy
Previously this effort is blocked by VhostUserInflight having
different type layout (padding) on different bit length archs.
However, unlike i686, armv7 have same data layout and padding
as aarch64 and x86_64, so it's not an issue for our supported
architectures.

bitflags crate is upreved to 2.3.2. New version is already
vendored in cros cargo vet.

TEST=CQ

BUG=b:204409584

Change-Id: I51701550a4cf297dc739344d2895972a9c6f6cc6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4679841
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-07-11 23:47:55 +00:00
Richard Zhang
dd9cc546ae vmm_vhost: Remove MAX_MSG_SIZE
The size check didn't seem more useful than a sanity check. This limit
is being removed because new IPC messages for snapshotting will exceed
this limit signficantly.

BUG=b:287515956
TEST=e2e_tests and presubmits

Change-Id: I8246d1ee0e7815d2b1950d1f78a2b93579e59f86
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4646712
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
2023-06-26 20:57:29 +00:00
Richard Zhang
102c2b6592 vhost-user: Implement restore in device process
* Creates a RESTORE message that the vmm sends to the device
* Starts up the worker on the vhost user VMM side if the device is
  activated
* Rewires up irqfds and doorbell events (ie. queue_evts)
* Restore vrings on the device process side
* Log error from restoring devices, which will making debugging
  e2e_tests easier

Unlike non-vhost user virtio devices, vhost user devices won't have
their queues and fds rewired on "wake". Instead it will happen on
"restore".

BUG=b:280607404
TEST=e2e_tests snapshot_vhost_user pass. presubmits

Change-Id: I0221dff1448e33d8b82bda48a151f94f90c691d4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4618095
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-06-23 20:49:48 +00:00
Richard Zhang
1a0a8c26e2 vhost-user: Implement snapshot for device process handler
This CL also:
* re-hooked up wake and sleep calls
* Introduce VirtioDevice::is_vhost_user so we can easily branch logic
  between vhost user and non-vhost user devices
* Fixed a conflict resolution mistake where "wake" would stop non-queue
  workers

BUG=b:280607404
TEST=ran snapshot_vhost_user_root e2e_tests

Change-Id: I5abee92a0445c9575c0775502930ea16ead2fb83
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4607767
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-06-14 21:50:13 +00:00
Richard Zhang
e796e6c642 vhost_user: Implement wake and utilize Suspendable trait
* Worker will return a struct used to help restart the Worker
* Extend unit test for sleep and wake
* replace VirtioDevice::stop call with Suspendable::sleep in
  VirtioPciDevice

BUG=b:280607609
TEST=e2e_test, presbumits
TEST=with e2e_test, added println! around the code to make sure it works
as expected

Change-Id: I0372f01b70a79693607435d3b6d9e60fb479e3e8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4522150
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-06-05 21:20:50 +00:00
Richard Zhang
d6f30da376 vhost-user-block: Stop non-queue futures on sleep
TEST=e2e_tests
BUG=b:284187992

Change-Id: Ic5ca7f874b8b96494dde144a360d57147d94e107
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4569484
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
2023-05-31 19:25:37 +00:00
Richard Zhang
152b16832a vhost_user: Implement sleep for vhost user devices
* Created IPC message for sleep in vmm_vhost
* Save active virtqueue states in the device process
* Removed unused queues field in Worker

BUG=b:280607608
TEST=presubmits and e2e_test

Change-Id: I18350d8e687e4e46d812679d45b90e54d098abf9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4522139
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-05-19 18:40:39 +00:00
Andrew Walbran
1661dfca89 Update bitflags dependency to 2.2.1.
This is a new major version, and requires some code changes.

Change-Id: I294ce3604aad6e6dc5f50e33246b690e883c1e36
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4481294
Auto-Submit: Andrew Walbran <qwandor@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-04-27 17:22:36 +00:00
Zihan Chen
bbc4f68ebb crosvm: Convert DataInit to zerocopy 10/n
We are down to only 30 `unsafe impl DataInit` across our repo now!

TEST=CQ

BUG=b:204409584

Change-Id: I1b6cf95b2a15eac194f3b464330009fd898a0bfa
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4356907
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-03-24 18:12:38 +00:00
Ryan Beltran
1801f6fd1c third_party/minijail: Update to latest main
This CL updates minijail to the latest version in order to update
bindgen to 0.63 which came in http://crrev.com/c/4246598 in minijail.

BUG=b:274724137
TEST=CQ

Change-Id: Ifb6a385aca4f5133ef4bece010dfa8fb318cfe43
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4363328
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Commit-Queue: Ryan Beltran <ryanbeltran@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-03-22 23:17:43 +00:00
Alexandre Courbot
d0ccdc38b3 devices: vhost: user: make run_with_handler take a request handler trait object
This will be necessary for the next CL, which introduces a closure that
cannot be make generic. Additionally the handler is used at a low
frequency and this limits the amount of generated code (2 generic
parameter leads to a potential explosion of monomorphized methods).

BUG=b:217480043
TEST=send data between the host and a VM connected to a vhost-user vsock device using socat.
TEST=send data between a VVU vsock device inside a device VM and another guest using socat.

Change-Id: Ie5946772a5f21f2c0dd289875a562abbccff6db4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4222843
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Ryuichiro Chiba <chibar@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2023-03-13 09:36:51 +00:00
Zihan Chen
8a7550c40a crosvm: Partially convert DataInit to zerocopy (1/n)
Thie effort is splitted into multiple CLs, to reduce change size
and also make bisecing breakages easier.

TESTED=CQ only

BUG=b:204409584

Change-Id: Ie90f171bd5f74b732df3129e94733f3b34621092
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4210751
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-02-02 19:28:57 +00:00
Gurchetan Singh
32ec615426 crosvm: pre-release alpha for data_model
data_model is probably going away in the future, but
until we can release it as pre-release alpha for internal
efforts.

(context: https://fxbug.dev/114169)

BUG=b:173630595
TEST=compile

Change-Id: Ie13ec3ab9083d315c78a035b532132296a8fb651
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4082333
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-01-13 17:23:23 +00:00
Daniel Verkamp
8811136ed7 third_party/minijail: update to latest main
Update minijail submodule to commit 4b0a832 ("rust: update bindgen
dependency to 0.60").

BUG=None
TEST=tools/dev_container tools/presubmit --all

Change-Id: I3312ae173dda92a7dd5cf74ee6f40be3918dbd87
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4133824
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-01-12 22:07:31 +00:00
Daniel Verkamp
2ddb12f0e2 Rust 1.65: Fix clippy bool_to_int_with_if lints
BUG=b:260784028
TEST=tools/clippy

Change-Id: Icacaff64624a925ad89ccf042d63d297b1bc855b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4064716
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-11-30 19:46:59 +00:00
Daniel Verkamp
dfe9869d6c Rust 1.65: Fix clippy borrow_deref_ref, needless_borrow, and explicit_auto_deref lints
BUG=b:260784028
TEST=tools/clippy

Change-Id: I85cd5e096bc7b977fe1d9b231c08338b65e71780
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4064714
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-11-30 19:33:31 +00:00
Daniel Verkamp
39fdc374fd vmm_vhost: remove unnecessary clippy allow
This lint has been renamed (identity_conversion -> useless_conversion),
but the original reason for allowing the lint is gone now, so we can
just remove the line entirely.

BUG=b:260784028
TEST=tools/clippy

Change-Id: If673848eaaa989970d5f18d2e0b3dac3c55abd23
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4064708
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-11-30 19:07:05 +00:00
Keiichi Watanabe
5b456d31f9 vmm_vhost: slave_req_hander: Wait before vhost-user message body
When vhost-user front-end send a vhost-user message via Unix domain
socket, a message header is sent first with optional attached files.
Then, a message body is sent as a separate packet if necessary.
However, the existing implementation blocks only before a
message header coming and assumed that the message body is ready when
the header comes. So, there was a race and `handle_request` could return
`EAGAIN`.

This CL splits SlaveReqHandler::handle_request() into recv_header() and
process_message() so a caller can wait between the header and the
additional payload.

On VVU, we shouldn't wait before receiving the payloads because the
proxy device forwards a header and its message body together. So we
check the protocol in needs_wait_for_payload().

BUG=b:237891754
TEST=Run vhost-user block on Linux
TEST=Run vhost-user block on Windows
TEST=Run VVU block on Linux

Change-Id: I35af3eb0e706cb005bf697397698e01e272b0704
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3863050
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-11-24 04:21:56 +00:00
David Stevens
60aa43629a devices: vhost-user: add protocol flag for shmem
Add a vhost protocol feature flag for shared memory region support. This
is necessary to avoid sending the GET_SHARED_MEMORY_REGIONS message to
backends which don't support it.

BUG=b:252901073
TEST=crosvm device wl

Change-Id: I044926e982526c3c76063b5386cab0db72524707
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3951472
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-10-21 01:09:07 +00:00
Vikram Auradkar
c4a4dc9b23 net_util: Add windows slirp support
BUG=b:237011316
TEST=presubmit and tested in wine

Change-Id: I1b6160142b8161d4b09d3fd98dfacde354e238b4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3934818
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-10-11 15:25:38 +00:00
Vikram Auradkar
06a3bef29c libslirp: Add a script and a doc on how to build libslirp
BUG=b:237011316
TEST=presubmit and ran the script to ensure that it installs and builds
     the binaries.

Change-Id: I5109eda6795ad2710df495afb99846c052afbf15
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3936734
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-10-10 20:01:33 +00:00
Keiichi Watanabe
d4ec52642a vmm_vhost: Remove SlaveReqHandler::connect()
Remove unused method.

BUG=none
TEST=cargo test --all-features in vmm_vhost for both Linux and Windows

Change-Id: I7fb7fb343f1742c2bea80b4031d43821f7437db6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3863048
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-10-09 09:24:21 +00:00
Keiichi Watanabe
bbb45a8e72 vmm_vhost: Remove unused state management methods
Some structs in vmm_vhost have `error` field and expose `set_failed` to
allow callers to invalidate an instance. However, `set_failed` is not
used in crosvm at all. In addition, the `error` field cannot be modified
any private methods in vmm_vhost. This means that the callers can manage
the error states entirely.
So this CL removes the `error` fields and `set_failed` methods to make
it clearer that the callers have responsibilities of error handling.

BUG=none
TEST=cargo test --all-features in vmm_vhost
TEST=cargo test --all-features --target=x86_64-pc-windows-gnu in vmm_vhost

Change-Id: Idf478790a0a75282a4c504456d93604f7369c015
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3863046
Reviewed-by: Noah Gold <nkgold@google.com>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-10-09 09:22:33 +00:00
Daniel Verkamp
b60140b37e tree-wide: use "crosvm" capitalization everywhere
Fix a few stray references to "CrosVM" and "CrosVm" so that we refer to
the crosvm project with consistent capitalization.

BUG=None
TEST=None

Change-Id: If5c3c131774d6e5da1d27466810642aec3cb42ac
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3938640
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-10-07 01:10:12 +00:00
Idan Raiter
a55eea9cc8 vmm_vhost: Introduce GPU_MAP
Adds a new message that can be used to map GPU memory via Vulkano.

BUG=b:244622199
TEST=presubmit & downstream

Change-Id: I4018cfda7573d4df2d89225060d5d61c8ac5d3d9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3924935
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
2022-10-06 20:41:57 +00:00
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