Let's remove the tubes:
1) gpu_device_service_tube - We diverge downstream nearly everywhere due
to other tubes passed just like it. Reducing merge conflicts should
happen maybe via structs, but we are already paying the cost anyway
when code changes next to this tube (due to the other differing args)
2) gpu_main_display_tube - We will be moving this to the wndproc thread
when upstreaming further work on it, so there is no need to keep the
old version around.
BUG=b:243061269
TEST=presubmit, cargo build
Change-Id: I241922952d34a212dcb412bc1f0391f8473d8a61
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4033254
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Pujun Lun <lunpujun@google.com>
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
This helps diagnose problems if the examples don't work (for example,
simple_open requires the `x` feature to be enabled).
BUG=None
TEST=run simple and simple_open examples
Change-Id: Ic115d48d93531bf2313948597a49a003538949cd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4029530
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This will allow them to be build via
cargo build --bin simple
cargo build --bin simple_open
It will also include them in CI builds to ensure the
code will not rot.
BUG=None
TEST=CQ
Change-Id: Id6e73f3d5535141f5b1df0edc07c0f84cd03305b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3997601
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
Makes the async vhost-user backend cross-platform. The next change will
add the plumbing to turn it on. The plan is to create GpuBackendConfig
and GpuVmmConfig in the broker and pass to the relevant processes.
This way, we can also pass GpuBackendConfig to the main process if we
want to use the original non-vhost-user worker. The config changes will
be included with the plumbing CL that follows.
- Split into a sys module.
- Introduce 'platform_workers' that tracks platform-dependent futures.
Reasoning: Windows will need to be able to launch more futures at
runtime due to our input handling, it's useful to have a vector of
workers to append to. This way the specific worker function doesn't
need to leak into the shared file. We can also put the resource
bridge workers here following the same logic.
- Introduce backend and VMM config structures to pass around.
BUG=b:243061269
TEST=downstream / presubmit
Change-Id: I53458c4dd2cf74b9e6bf5d10819533206e47a683
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3963645
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
If crosvm's connection to the host compositor is suddenly broken
(e.g. from a compositor crash), a single POLLHUP is sent on the listened
file descriptor, but it is ignored. Then the VirtioGpu backend is
repeatedly awoken to handle display events, although there are none.
Since the compositor is lost and there is currently no path for
recovery, we can at least prevent runaway CPU usage by removing the
display from VirtioGpu's WaitContext. For VMs that can continue to
function without a guest display (headless crostini), this is
non-lethal. For VMs that require a display (ARCVM), other mechanisms
already exist for shutting down the VM under such unrecoverable
conditions.
BUG=b:250923109
TEST=Run Crostini and trigger a chrome crash; inspect virtio_gpu CPU
usage
Change-Id: I8b2261a093191dfe142697c4c4adc4e9ffab751a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3975942
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
We do receive WM_ENTERSIZEMOVE when the window is about to be resized or
moved, but it doesn't tell us whether resizing or moving should be
expected. We won't know that until later we receive WM_SIZING or
WM_MOVING. There are also corner cases where we don't receive either
WM_SIZING or WM_MOVING in the modal loop, or receive both of them.
This CL adds an enum SizeMoveLoopState to track this state, so that we
can know whether the window is resizing or moving.
One alternative is to use WM_NCHITTEST to test whether the cursor is on
the window title bar (which implies moving the window) or window
borders/corners (which implies resizing) when WM_ENTERSIZEMOVE is
received. However, the user may also trigger resizing/moving from the
system menu (e.g. by right-clicking on the title bar and selecting it
from the drop down list), so this is not always reliable.
BUG=b:254702853
TEST=Tested in the Windows downstream
Change-Id: I8c8d97a7542b291c57dbddb75d785b324ff2776e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3975933
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
The Windows official doc suggests that, "New Windows applications
should use Unicode to avoid the inconsistencies of varied code
pages and for ease of localization".
BUG=b:254702853
TEST=Tested in the Windows downstream
Change-Id: I159263d21ff5e9900c4bb79fe17bd0aa3aedae0d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3971022
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
BUG=b:254702853
TEST=Tested in the Windows downstream
Change-Id: I932bac772acee48179b3d793be0f129c9bfed79e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3969223
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Trying to reconcile the difference between the linux and windows
implementations.
Code relying on the eventfd count must now use the linux specific
`EventExt` interface.
BUG=b:231344063
TEST=presubmits
Change-Id: I14eb50f7a02d766a00f27aca388823309633e193
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3864030
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
This replaces the handwritten arg parser with the serde_keyvalue
based parser. Eventually we will unify the arg parsing with Unix.
BUG=b:233676779
TEST=cargo b --features all-msvc64,gpu --no-default-features
TEST=cargo t -p vm_control --features all-msvc64,gpu
--no-default-features
TEST=cargo t -p crosvm sys::windows::config::
--features all-msvc64,gpu --no-default-features
Change-Id: I36a563be9767c7e5cbd3ab44f6a9ba23cd64cdb6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3939033
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
1. gpu_control_tube is not used on Windows yet. We will make use of
it and test it in the downstream first before removing the Unix
feature flag.
2. In Gpu::keep_rds(), skip appending descriptors of stdout and
stderr since it is hard to find such descriptors on Windows, and
this function won't be called on Windows anyways.
3. Some functions in gpu_display should be guarded with gfxstream
feature flag, since we don't need to link against gfxstream
binary when we are building/tesing without gfxstream.
BUG=b:213149288
TEST=presubmit
Change-Id: I28c3d16d82916e6d4a542aa008dd09015141716c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3947825
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
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>
This function has no call site so we might remove it to simplify
the code.
BUG=b:213150276
TEST=presubmit
Change-Id: I7c74c91de224cbccecd307c7774a15145d12433e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3930937
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Pujun Lun <lunpujun@google.com>
We were busy-waiting on atomic variables for the message loop
state of the WndProc thread. That is to make sure other threads
don't start posting messages to the WndProc thread until the
latter has created the message queue and is about to enter the
message loop. We can use mpsc channels instead. The WndProc
thread notifies other threads that it is ready by sending out its
thread ID.
BUG=b:243184256
TEST=tested in downstream
Change-Id: Ia2a675c083bb6aa9046dd9eab932a95fa06b8709
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3928133
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
We were busy-waiting on atomic variables for surface creation
results. We can use mpsc channels to avoid that, which also
eliminates the need for enum CreateSurfaceResult since we just need
to send booleans.
BUG=b:243184256
TEST=tested in downstream
Change-Id: If4c39c797f9ca9edf3695e44689904066546759f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3928131
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
Notable changes:
1. Use "W" methods during window creation and message dispatching
to ensure unicode characters are sent to the window.
2. In DisplayEventDispatcher::dispatch(), filter() and map() will
be ignored if we don't call collect(). We replace map() with a
for loop to make this clearer.
Other changes are due to linter/formatter warnings, etc.
Bug=b:213150276
TEST=cargo b -p gpu_display --features win64 --no-default-features
Change-Id: I767aec208d8afd7d7cb86039d08ba8ec8369da81
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3913991
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
On Windows, we have to create a GUI thread that creates the window and
retrieves window messages from the thread-specific message queue created
by the system. All host events, such as window resizing and mouse and
keyboard events, are sent in the form of window messages. Hence, we
created these structs/traits to model it:
- `Window`: Owns the handle of one window, and provides helper functions
for operating on this window.
- `HandleWindowMessage`: A trait implemented by the struct that
processes host events. In our case, that is the surface.
- `WindowMessageProcessor`: Holds one `Window` object and one
`HandleWindowMessage` trait object. We only support one window for
now. Once we support multi-windowing, there will be multiple
processors.
- `WindowMessageDispatcher`: A singleton, responsible for dispatching
messages retrieved from the message queue to the targeted processor.
- `WindowProcedureThread`: Wraps the GUI thread, retrieves messages from
the message queue and forwards them to the dispatcher. It also
provides helper functions for other threads to talk to the GUI thread.
- `MessageRelayThread`: Relays service messages to the GUI thread.
Main difference from other platforms: event devices are imported to the
GUI thread, since all host events are processed there.
BUG=b:213150276
TEST=presubmit
Change-Id: I0aabf6adf8a9ff4b24375e9c7df7625b6f761c7a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3834009
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
While we are tweaking all of the copyright headers, let's take the
opportunity to ensure there is always a blank line after the copyright
header for consistency. (Almost all files already follow this style.)
This includes a slightly ugly regex to allow the end of a C-style
comment block after the end of the copyright:
/*
* Example comment block
*/ <-- this line
Change-Id: Idfd0855861e5ecb3d33afae942fdba908af0dcff
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3892521
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
This search/replace updates all copyright notices to drop the
"All rights reserved", Use "ChromiumOS" instead of "Chromium OS"
and drops the trailing dots.
This fulfills the request from legal and unifies our notices.
./tools/health-check has been updated to only accept this style.
BUG=b:246579983
TEST=./tools/health-check
Change-Id: I87a80701dc651f1baf4820e5cc42469d7c5f5bf7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894243
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
generated files and a list of excluded files are skipped.
Others are fixed to include the missing header.
BUG=b:246579983
TEST=./tools/health-check --all copyright_header
Change-Id: I13e9bf79df18789f1ed4b83fc47c0c2e080d70a8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894240
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
The #[cfg(unix)] and #[cfg(windows)] checks in build.rs are testing
properties of the build system, not the target system, which is
inappropriate for cross compilation scenarios. This will matter when
cross compiling from Linux for Windows, as an example.
Use the appropriate Cargo environment variables to test target
properties instead:
https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts
BUG=None
TEST=cargo build
TEST=tools/run_tests --target=host --build-target=mingw64 --build-only
Change-Id: If1ac479ae519fe69168cead68b9ee44bac56f851
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3840955
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Fixes a couple of files that were missing them.
BUG=b:242605601
TEST=./tools/health-check --fix
Change-Id: I620d6a939cb824e014002152584aacfc5dfdf7e8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3835648
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
This reverts commit d98f01af14.
NOTE: we are intentionally keeping the changes to use new tracking IDs
per contact, and the conversion of wayland to send MT events, as those
are not really part of the simulation change, and should be fine to keep.
Following discussion w/ drmasquatch@ offline re comments on the OCL, it
seems like there are other ways we could solve for the original
problem without introducing a simulation layer. Given the complexity
introduced and the fact that not all consumers necessarily want this
compat layer, a revert seems like the best step. Some options for fixing
the original problem in the future:
* Modify gpu_display_wl to produce ST events based on a CLI flag.
This is pretty easy, and involves enhancing
`--display-window-mouse` to take whether the events should be ST
or MT, and then generating the ST events in the display backends
as specified. The same flag also needs to create a ST device
rather than a MT device so that the ST events will be accepted
by the guest kernel.
* Modify the virtio-input kernel driver. This might be the right
place to add a compat layer, if one is needed more broadly. It
will also fix the problem everywhere.
Original CL: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3330723
TEST=builds
BUG=b:191173095
Change-Id: Iad07b6b5a06a3884dc352c49847b2b3c268ee5bd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3814100
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Noah Gold <nkgold@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
- Remove trailing ::{self} on all use statements
- Remove any resulting single-level use statements (e.g. use libc;)
- Reformat with `tools/fmt --nightly`
BUG=b:239937122
TEST=tools/dev_container tools/presubmit --all
Change-Id: I8afd1b0458ca6d08d9b41a24583f7d4148597ccb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3798973
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
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>
The code to manage the EventDevice buffers was a little tricky to
follow. This CL refactors it.
BUG=b:239699447
TEST=builds. Tested downstream.
Change-Id: I979643ed82dc69544d2073d09f55a52a4cc3bb39
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3782777
Tested-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
send_report used to panic if we tried to send more events than would fit
in the buffer. Now overflow is handled gracefully. We've also increased the
buffer size, which was previously quite tiny, so that we're less likely to drop
events if there is a flood of them.
BUG=b:239699447
TEST=builds. tested downstream.
Change-Id: Ie4b9d927bb75c6a3126de17e781d4a3e18551f7c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3780879
Commit-Queue: Noah Gold <nkgold@google.com>
Tested-by: Noah Gold <nkgold@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
This makes it easier to integrate crosvm into Android (which doesn't
have the kernel headers available for all the build targets crosvm is
needed in).
The BTN_LEFT constant is already hardcoded in virtio/input/constants.rs,
so the additional tech debt seems acceptable.
BUG=b:228881829
TEST=cargo build && cargo test
Change-Id: Ia25586e855a29fc5f475904cad028eef30d3f016
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3717525
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Pull the declaration of the `EventToken` enum up to the top level of the
base crate, replacing the identical implementations inside sys/windows
and sys/unix.
Use the `EventToken` name consistently throughout the tree to remove the
unix-flavored "poll" nomenclature.
BUG=b:213153157
TEST=tools/dev_container tools/presubmit --all
Change-Id: I0ba42037b533b796797a7a3f6d8d7e71a5592aba
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3642673
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
When creating shared memory, 'name' can have one of two meanings. It
could either be a debugging tag with no semantic meaning, or it could
uniquely identify a shared memory object within some namespace. Linux
memfd uses name in the first meaning, whereas Windows (and Linux shm)
uses it in the second meaning.
Currently, crosvm has no use cases for the named shared memory of the
second type, so it is not supported. Make it clear that the SharedMemory
APIs treats name as a debugging-only name. Remove the "anon" and "named"
constructors, since they had no semantic meaning. Also require a name
when constructing a SharedMemory, since there's no reason not to provide
one to make debugging easier.
The only semantic change is setting the name of GuestMemory's underlying
shmem to "crosvm_guest", which it was until recently. This fixes some
ManaTEE tests which use the name to determine CrOS guest memory usage.
BUG=None
TEST=compiles
Change-Id: I78d5046df04d6f19640abbbc67af6bd433a177b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3676695
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
This is a reland of commit 2b85d4d1e5
Diff from the original CL:
* Changed the return value of `main()` in power_monitor/build.rs
* Ran cargo-check with all features enabled
Original change's description:
> github: Minimize dependencies for document generation
>
> Instead of install full dependencies with `install-deps` in GitHub
> action, minimize dependencies because we use GitHub only for document
> generation.
>
> - Passed `CARGO_DOC` environment when running cargo-doc command so we
> can skip unnecessary build flow when we just want to generate API docs.
> - Added a new script `install-docs-deps` to install only doc-related
> dependencies.
>
> BUG=none
> TEST=test on GitHub Action at my personal repository
>
> Change-Id: Ibe988ab43215e285d946812bdd6c1536ae87b50e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578144
> Tested-by: kokoro <noreply+kokoro@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Reviewed-by: Anton Romanov <romanton@google.com>
> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Bug=none
TEST=cargo check --all-features
Change-Id: I77ee6543910e3fe7f69be48f8f965eda3433d4e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3584063
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
This reverts commit 2b85d4d1e5.
Reason for revert: breaks powerd compile
Original change's description:
> github: Minimize dependencies for document generation
>
> Instead of install full dependencies with `install-deps` in GitHub
> action, minimize dependencies because we use GitHub only for document
> generation.
>
> - Passed `CARGO_DOC` environment when running cargo-doc command so we
> can skip unnecessary build flow when we just want to generate API docs.
> - Added a new script `install-docs-deps` to install only doc-related
> dependencies.
>
> BUG=none
> TEST=test on GitHub Action at my personal repository
>
> Change-Id: Ibe988ab43215e285d946812bdd6c1536ae87b50e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578144
> Tested-by: kokoro <noreply+kokoro@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Reviewed-by: Anton Romanov <romanton@google.com>
> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Bug: none
Change-Id: Ie16b65235490071ac4e69bf3f09af3ba0c766eab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3581836
Auto-Submit: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Instead of install full dependencies with `install-deps` in GitHub
action, minimize dependencies because we use GitHub only for document
generation.
- Passed `CARGO_DOC` environment when running cargo-doc command so we
can skip unnecessary build flow when we just want to generate API docs.
- Added a new script `install-docs-deps` to install only doc-related
dependencies.
BUG=none
TEST=test on GitHub Action at my personal repository
Change-Id: Ibe988ab43215e285d946812bdd6c1536ae87b50e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578144
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Run tests for sys_util_core, poll_token_derive and balloon_control on
windows.
Using dotfiles to disable/serialize test runs of a subset of crates does
not work well with third party crates as it forces us to commit the dot
file to the crate.
The patch modifies and uses the script that runs linux tests.
This patch also allows us to
- build/test child crate even if parent crate has disabled build/test.
- avoid building crosvm if it is not explicitly specified.
RIP short lived .windows_build_test_skip. You allowed us to run noop
kokoro tests.
Test: py .\tools\impl\test_runner.py --arch x86_64
Bug: b:215610772
Change-Id: Icc6d04ffd7c0c33d4f60aeac16fc7d23881c387d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3459809
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
The patch 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>
Mirroring Linux kernel behavior, we would like to have devices emit
MT (multitouch) events, and have these generate simlated ST events.
BUG=b:201796434
TEST=recreated kernel,virgl etc configuration from @ryanneph to confirm
Change-Id: Iaac625358bddefb7dfe0037c91ababdc30185cdd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3330723
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Maciek Swiech <drmasquatch@google.com>
There were not too many cases here. This fixes:
- comparison_chain
- wrong_self_convention
- upper_case_acronyms
- from_over_into
- let-and-return
The collapsible_if check is moved to the permanently
allowed checks. The cases we do have improve
readability or semantics.
BUG=chromium:908640
TEST=Kokoro
Change-Id: I6e905d08e2a87aa0862d4d1cf5ff57b60e95fa7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3278776
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This change contains the results of running
./tools/contib/cargo_refactor.py
This will break the next uprev, and needs to be synchronizized
with the corresponding ebuild changes in https://crrev.com/c/3248925
BUG=b:195126527
TEST=./tools/run_tests
Change-Id: Ied15a1841887bb8f59fba65b912b81acf69beb73
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248129
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Rust bindgen now supports --allowlist and --blocklist option names as of
https://github.com/rust-lang/rust-bindgen/pull/1990 - use them in the
various bindgen invocations in scripts and comments.
BUG=b:178821708
TEST=../dev/contrib/search_blocked_words.sh unblocked_terms.txt
Change-Id: I9797f049999a01ab2c41617823463236b4d03cbb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3243012
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
If we need descriptor for things that aren't file or other shared_memory objects, we can create a separate descriptor change, but it shouldn't be the default.
This reverts commit 533c5c8258.
Reason for revert: this causes conflicts with other platforms.
Original change's description:
> vm_memory: Add from_desciptor() in MemoryMappingBuilder
>
> MemoryMappingBuilder had `from_file()` and `from_shared_memory`, which
> are almost the same. So, this commit adds `from_descriptor()` to replace
> both of the two.
>
> BUG=b:194137301
> TEST=build
>
> Change-Id: Ia13f5e8e0f95a5c32e47dc9b3be13b7a7fa510bf
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3159881
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Bug: b:194137301
Change-Id: Ie203ee3eb3dcddd41c5e55b6980dc6292eb24f85
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3183183
Auto-Submit: Udam Saini <udam@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Udam Saini <udam@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
MemoryMappingBuilder had `from_file()` and `from_shared_memory`, which
are almost the same. So, this commit adds `from_descriptor()` to replace
both of the two.
BUG=b:194137301
TEST=build
Change-Id: Ia13f5e8e0f95a5c32e47dc9b3be13b7a7fa510bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3159881
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Instead of checking each item for Some/Ok-ness, filter down to just the
desired items using flatten() on the iterator.
BUG=b:197251702
TEST=bin/clippy # with rust-toolchain = 1.54.0
Change-Id: I80db12c36f41e76f5dff6c30299a3f5d3745f578
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3108613
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Allen Webb <allenwebb@google.com>
Tree-wide cleanup of new clippy warning in Rust 1.54 that warns about
needless borrows:
error: this expression borrows a reference (`&...`) that is
immediately dereferenced by the compiler
https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
BUG=b:197251702
TEST=bin/clippy # with rust-toolchain = 1.54.0
Change-Id: Ib702ec524d4623d264a00ec11dbc2150c411a67b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3108321
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Allen Webb <allenwebb@google.com>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Ensures that GpuDisplayImport and GpuDisplaySurfaces
are dropped before DisplayT (changed in crrev.com/c/2852523).
Also, call destroy on the new wayland surface metadata object
on drop.
BUG=b:189933900
TEST=launch Cuttlefish and `adb reboot`
Change-Id: I6718b03dc01e29c9b6e68189cf540a5a5cf93617
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3002149
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
Cuttlefish's streaming server, which acts as a Wayland compositor
in order to receive display framebuffers from Crosvm, needs some
mechanism to tell which Wayland surface corresponds to which display
(a "display" is a "scanout" in virtio-gpu terminology).
Wayland object ids can not be directly used for this as all Wayland
objects share a single global id space (so the first created Wayland
wl_surface surface object may have id = 15).
Previously, the case of unchanging displays was handled by enforcing
the creation order of surfaces within Crosvm so that Cuttlefish's
streaming server (which is a Wayland compositor) could assume the
creation order corresponded to the display order. However, this still
experienced issues (b:186580833) when surfaces were destroyed and
later recreated when handling `set_scanout(..., resource_id = 0)`
commands.
There is also an ongoing effort to support adding and removing
displays at runtime in (see aosp/1671968) which experiences the
same issue. When surfaces are arbitrarily created and destroyed,
Cuttlefish's streaming server has no way to determine which Wayland
surface corresponds to which display.
To solve all of this, this change introduces an extension to allow
Wayland clients (Crosvm) to attach additional metadata (scanout_id)
to Wayland objects (surfaces) so that Wayland compositors (Cuttlefish's
streaming server) can exactly determine which surfaces correspond
to which displays. I will attempt to upstream this protocol (tracked
in b:191901112).
BUG=b:188904670
BUG=b:187351899
BUG=b:191901112
TEST=launch Cuttlefish with single display
TEST=launch Cuttlefish with multiple displays
TEST=launch Cuttlefish and hotplug some displays
Change-Id: I2aa4b714a49e4d85b6a3c705ba0d5bc1720b838e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2909903
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@chromium.org>
Commit-Queue: Jason Macnak <natsu@google.com>
Updates virtio-gpu frontend to track multiple
scanouts and the resources set for those scanouts.
Adds a --gpu-display command line arg to avoid having
to create a very complicated --gpu string.
BUG=b:173523402
TEST=launch Cuttlefish w/ multiple displays
TEST=(see change series at aosp/1652814)
Change-Id: I73174c11f35f865b8b67ae77d8169d6812f85535
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2836265
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@chromium.org>
Commit-Queue: Jason Macnak <natsu@google.com>
Added preliminary version of keyboard and pointing device routine
for wayland implementation. The pointing input is wired as a multi
touch device. Due to the fact that wayland client is callback based,
all the necessary incoming events are serialized and stashed in the
temp circular buffer and then processed afterwards from the main event
loop.
Known issues:
1. Mouse input can't be properly wired inside the guest as a mouse
device without pointer locking, but this is not what we want. The
approach emulates it as a multitouch device, but, of course, it
implies limitations in functionality. Limitations include cursor
in the VM that doesn't move in unison with the host cursor.
2. I kept the mouse cursor surface since it's not decided yet which
approach for handling pointing input device will be used (see #1).
Removing the mouse surface in the guest would remove the lagging
guest cursor. The alternatives to the multi-touch device are:
"- Relative mice (e.g. a typical PC mouse). These are relative
devices, meaning they send deltas from the current cursor
position. Some apps like games rely on these events.
- Touchscreens (multitouch, single touch). These are absolute
devices, and are much easier to implement seamless guest/host
input for.
- Touchpads (these are absolute devices). I'm not sure these are
really compelling for any use case." -nkgold@
3. This code is for POC purpose only, so there are still lot of minor
issues and negligence in it.
Looking forward for your comments and proposals.
BUG=b:177939148
TEST=crosvm $ARGS \
--display-window-keyboard \
--display-window-mouse \
--gpu=3d,glx=false,egl=true \
--wayland-sock=/run/user/1000/wayland-0 \
$OTHER_ARGS
Change-Id: If4a9b73b8da4e0cc52fa619bbd6e5588ccdb7874
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2688439
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
There is a desire for Wayland and possibly other display backends to
reasonably handle input. Move the event device logic inside the X11
backend up to the common layer to prevent duplication.
The common layer also keeps track of surfaces and external memory
objects to make this easier. The GpuDisplaySurface/GpuDisplayMemory
traits are introduced in case the common layer needs to perform
compositor specific operation.
BUG=b:173630595
TEST=compile and run with X11
Change-Id: Ied060a7cc216ac6c084030aad1fc839c022a3395
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2852523
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Promote xdg_shell_v6_unstable to the stable version of xdg shell
protocol.
In addition, we must fix the the build.rs file. It looks for:
/usr/share/wayland-protocols
not
/build/${BOARD}/usr/share/wayland-protocols
Fix this by looking at pkg-config, and not the environment when
looking for the protocol path.
BUG=b:177939148
TEST=Tested on Ubuntu (gnome)
Cq-Depend: chromium:2914164
Change-Id: I7beff3845a3bf9f248171492ffd55ee3991a32ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2666159
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
As new features are about to be added, it only makes sense to
improve error handling first.
Also improve/update naming of errors in other GPU-focused areas.
BUG=b:173630595
TEST=compile and run
Change-Id: If0d4f8b7d548c46f0a15b64699502e0fefeaae3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2844350
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
This CL addresses some minor issues with the existing interface:
1. from_descriptor is too generic for some platforms that require
special handling for file/File backed mappings.
2. Nearly all call sites pass either File or SharedMemory. Now
we just have from_ methods for those types to preserve type
information.
3. Other platforms require additional fields in MemoryMapping, so a
tuple struct no longer makes sense.
4. The mmap syscall error message was misleading as we use it for more
than just the mmap syscall.
BUG=None
TEST=builds
Change-Id: I74c41bad52bb81880a11231cd18f47e233548a24
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2815614
Reviewed-by: Udam Saini <udam@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Previously we restricted the virtio_input_event/input_event's value
field to u32. In actuality, this field is an i32 in the kernel, and the
negative values are used for relative mice (among other things). This CL
switches the value field to be signed.
BUG=None
TEST=builds (also tested on another branch)
Change-Id: Ia2c43e1a8ee21aa618d97b308369ab49c194cab4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2770724
Auto-Submit: Noah Gold <nkgold@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Some judgement calls were made about unnecessary wrapping. Usually they
would get resolved by removing the wrapping or returning a convenient
error, but the ones that returned results for consistency with other
functions were added to the allow list.
The error handling in the usb code had a lot of unit error types which
is now a clippy lint. This was resolved by either removing the result
entirely or returning a convenient error.
The field_reassign_with_default lint is faulty and was added to the list
of supressions. This affected virtio-wayland code.
BUG=b:179277332
TEST=cargo clippy with rustc 1.50+
Change-Id: Ie812cdeaf7c42f4f2b47b1dc87f05a7c87a60f8f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2757510
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Auto-Submit: Zach Reizner <zachr@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
This change is to cleanup some dead_code warnings that appear if certain
features aren't enabled.
This also updates the Cargo.lock when changed due to zeroize being added
to libchromeos-rs.
TEST=cargo check --all-features
BUG=None
Change-Id: I5347b584a7426dc37f3933b1e907b23a71145749
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2753128
Reviewed-by: Allen Webb <allenwebb@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
This error was observed:
wl_surface@5: error 3: buffer committed to unconfigured xdg_surface
Shout out to bugaevc for the diagnosis and fix:
"In addition to setting up the listeners, we have also made two
important changes. First, we call wl_surface.commit right away,
prior to attaching any buffer to it. This causes the compositor to
issue the appropriate configure events. We wait for them to be
received and handled with an additional wl_display_roundtrip() before
we attach the buffer."
https://bugaevc.gitbooks.io/writing-wayland-clients/content/beyond-the-black-square/xdg-shell.html
BUG=b:150239451
TEST=boot VM with wayland display, still doesn't work completely
correctly due to lack of {import, attach, detach}_event_device
implementations
Change-Id: I06fac4f8540ce410c20a367d1e5dbe3fc08c4f10
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2583164
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
This CL transitions most structs to RawDescriptor and the
associated traits if possible.
BUG=b:162363783
TEST=./build_test
Change-Id: Iabae6ac212787836d77de2b9ffb5d451421ab0dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2530911
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Michael Hoyle <mikehoyle@google.com>
Commit-Queue: Michael Hoyle <mikehoyle@google.com>
This is a layer above PollContext with a more generic interface.
As PollContext is used so widely, this is quite a large change
in order to accomodate the interface update, especially with the
use of RawDescriptor. In some cases this has caused an echo
of updates to RawDescriptor, which is fine because of our eventual
goal to move the whole codebase to it regardless.
Note there are a few instances of forcing the RawDescriptor update
chain to stop, ex. ioctl. This is to keep the scope of this CL
concentrated and avoid changing entire other areas.
Note that this CL leaves out a few additional pieces of work:
- The sole usage of EpollContext over PollContext (event_loop),
which poses a bigger challenge for interface changes
- Full PollToken renaming, which is a tiny change turned difficult
due to the unavailability of type aliases for traits.
- Renaming certain methods which have been updated to use
RawDescriptor such as keep_fds. Some have enough dependencies that
they are worth avoiding to keep this CL pointed, but will be
addressed in future CLs to make sure the whole codebase is on the
fd->descriptor train
BUG=b:162363783
TEST=./build_test
Change-Id: Iff2cfe8f90dea55f1388f8e91bdc698e121a8e43
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2455726
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Michael Hoyle <mikehoyle@google.com>
Note the CL size is large entirely due to the rename,
the changes are mostly negligible.
Also making a few small additional changes in sys_util
areas that don't need much attention in base. This includes
typedefing and adding specific imports for areas that don't
require significant interface changes.
BUG=b:162363783
TEST=./build_test
Change-Id: I4a2c9c4cdce7565806ed338e241c6b8c82c855c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2415180
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Michael Hoyle <mikehoyle@google.com>
This is very largely boilerplate, but changes some interfaces
to accept different parameters, esp using Descriptor.
BUG=b:162363783
TEST=./build_test
Change-Id: I81b513c0de9448c2de505fe5d3a61a29f4eccb78
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2342591
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Michael Hoyle <mikehoyle@google.com>
The Wayland context was being destroyed before the surfaces
were destroyed. This is because the drop order for fields
inside a struct is the order in which they are declared
[Rust RFC 1857].
BUG=b:168735942
TEST=boot Cuttlefish and then `adb reboot`
Change-Id: I3581375a0694871ad50945f5c3ce432bb1f65653
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2415511
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
For now, this crate simply re-exports all of sys_util, but it will
be updated to provide new interfaces when needed. This is the
first step to making crosvm not directly depend on sys_util, so
that we can make the interface changes we need without fear of
negatively affecting (i.e. completely breaking) other usages
within chromeos.
BUG=b:162363783
TEST=./build_test
Change-Id: I7d0aa3d8a1f66af1c7fee8fd649723ef17027150
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2325168
Tested-by: Michael Hoyle <mikehoyle@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Michael Hoyle <mikehoyle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
may help with backpressure in high fps situations
It was found that display.flip() can take a long time, at least if
framebuffer_region() is called, which causes dropped frames. The idea is
that if the server is still using the frame we may have to wait $omeTime
to get it back for drawing the next one, and the wait can be long
compared to the time to copy.
BUG=b/153580313
Change-Id: I00c50479b40383d2329d7eb714248a7154a22aba
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2224017
Commit-Queue: Lingfeng Yang <lfy@google.com>
Tested-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
The VolatileSlice API changed, but some callers were not updated to
match. Fix them up so that builds with additional features enabled
(e.g. kokoro) pass again.
BUG=None
TEST=cargo test -p disk --features=composite-disk
TEST=docker/wrapped_smoke_test.sh
Change-Id: I97b3cd04549af30b7dc1515245f025d9439669bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2216399
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Change VolatileSlice so that it is ABI-compatible with iovec. This
allows us to directly pass in a VolatileSlice for a C function that
expects an iovec without having to create temporaries that convert from
one to the other.
Also change all the parameters from u64 to usize. It's not possible to
address more memory than fits into a usize so having u64 here didn't
really provide much benefit and led to a lot of tedious casting back and
forth all over the place.
BUG=none
TEST=unit tests
Cq-Depend: chromium:2206621
Change-Id: I258f9123c603d9a4c6c5e2d4d10eb4aedf74466d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2203998
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
All 3 different virtio gpu backends share the same process of creating
the GpuDisplay instance, so move that process out of their separate
build functions and put it in the shared BackendKind build function.
BUG=None
TEST=build_test
Change-Id: Ie15bae48c8f1b75df49ba066a677020ec5dbf744
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2182041
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
Fixes warnings of the form:
warning: this method call currently resolves to `<&[T; N] as
IntoIterator>::into_iter` (due to autoref coercions), but that might
change in the future when `IntoIterator` impls for arrays are added.
BUG=None
TEST=emerge-nami crosvm
Change-Id: I2b46b55f0e967d985d04678c240604b542e27e07
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2093287
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Previously, all input events in CrosVM were required to be linux
input_events, which have a timestamp field that is actually unused by
when we send/receive from the guest which are of type
virtio_input_event. This CL allows CrosVM to understand both types of input
events in a first class manner. It is a follow up on
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1930405.
This CL also addresses some bugs with window driven input:
1. attach_event_device was being called before the surface was
created, so the devices were never attached.
2. The default touchpad size was not being set to the display window
size.
Additionally, it removes the unused event "filter" feature on event
sources.
Breaking change: from this point forward, CrosVM will treat input events sent
via a socket (e.g. SocketEventSource) to be virtio_input_events.
BUG=None
TEST=builds + manual
Change-Id: I7fec07c582e5a071a6f116975ba70d6e621bb483
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2034046
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
... which does not require virglrenderer (or any renderer).
This will allow the Cuttlefish team to use minigbm as its gralloc
implementation when both hardware acceleration is available and
unavailable.
Adds a GPU `Backend` trait with all of the existing methods of the
current backend and converts the existing `Backend` into
`Virtio3DBackend` which implements the new trait.
Adds a `Virtio2DBackend` which creates resources with byte vectors on
the host and implements transfers via the old code from
gpu_buffer/src/lib.rs.
Adds a runtime flag to select between 2D and 3D mode with 3D mode as
the default.
Moves the process_resource_bridge() function to the `Frontend` and
instead expose a export_resource() function on the `Backend` to avoid
some code duplication.
BUG=b:123764798
TEST=build + launch cuttlefish w/ 2D mode (minigbm + custom hwcomposer)
TEST=built + launch cuttlefish w/ 2D mode (minigbm + drm_hwcomposer)
TEST=built + launch cuttlefish w/ 3D mode (minigbm + drm_hwcomposer)
Change-Id: Ie5b7a6f80f7e0da72a910644ba42d2f34b246be8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1993913
Commit-Queue: Jason Macnak <natsu@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Lingfeng Yang <lfy@google.com>
Adds a stub display that emulates a display without actually
displaying contents anywhere.
This is needed for transitioning Cuttlefish to always using minigbm
as its gralloc implementation. Cuttlefish currently uses a custom
gralloc and hwcomposer implementation when running without hardware
acceleration. The Cuttlefish team would like to start with removing
our custom gralloc implementation and use minigbm. For this, we need
to add a virtio 2D backend to crosvm. Our hwcomposer implementation
currenlly sends framebuffers from the guest to the host via sockets.
The gpu backend still requires a display so we need a stub display
to use with the 2D backend for the period of time while we are
either still using our hwcomposer implementation or until our
hwcomposer implementation is updated to use the virtio backend for
display.
BUG=b:123764798
BUG=chromium:1033787
TEST=built and launched with Cuttlefish locally
Change-Id: I1a7e259d914a53252200c59589c4142e76c6b96b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1993947
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jason Macnak <natsu@google.com>
Adds bindings to the X11 display window to capture keyboard & mouse
input & send it to the guest via an EventDevice.
Original implementation by zachr@chromium.org.
BUG=chromium:1023975
TEST=None
Change-Id: I33156a8ca0b8c610a2080e3b6891cca2a865734b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1971121
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
The keycode translates scancodes into Linux keycodes so they can be sent
to the virtio-input device. The translation is based on Chromium's existing
table, but converted into Rust.
BUG=chromium:1023975
TEST=None
Change-Id: Icd709e40c6d12775fdce0738f3dde3620f6c7da5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1962872
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
This change also includes stubs for the wayland and x11 impls.
TEST=compiles
BUG=chromium:1023975
Change-Id: Ia2bcb5c2ed75ea47071dd77e149e60901a56595c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1930407
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
The EventDevice is a data structure that allows a generic gpu display to
send and receive input events in evdev's format to a generic input
device, such as virtio-input.
BUG=chromium:1023975
TEST=None
Change-Id: Ic663cc8c7a3031aee929e09620c5430c27a25190
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1930406
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
The new constructors are shorter and omit the bare `None` in the `anon`
call sites which gave no clues to the reader what the effect of that
`None` was. This should improve readability.
TEST=./build_test
BUG=None
Change-Id: I2e34e7df9a4ccc5da50edf4e963a6a42e3d84b22
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1797188
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Using .map in the way it was caused the CString to get moved into the closure
and then dropped by that closure. The returned pointer is then used in
dwl_context_setup after it was freed by the drop.
This change fixes that first by using .as_ref() before calling .map to
prevent the move. As an additional safeguard, some optional types were
added to the closure to make sure a reference to the CString was being
handled instead of a moved CString.
TEST=vmc start --enable-gpu termina
BUG=chromium:988082
Change-Id: I58c2c002f08688ecd85715d9cd45085dffb32457
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1721615
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
This change adds an X11 backend to the gpu_display crate. With this
addition, the virtio-gpu device can display to traditional linux
desktops that only have X11 output.
Change-Id: I86c80cac91ca5bdc97588194a44040273ae69385
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1591572
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Zach Reizner <zachr@chromium.org>
If the dwl_context_setup routine fails after creating a wayland
connection succesfully (e.g. if an extension is missing), the fail label
is jumped to in order to disconnect the wayland connection and
deallocate the wl_display structure. That label did not set
self->display to NULL after calling wl_display_disconnect, which would
cause the dwl_context_destroy routine to call wl_display_disconnect again,
which is a double free. This CL fixes that ommission.
TEST=None
BUG=None
Change-Id: I5b6c2d6fadda82dff4130bd4abb0e7764c15e004
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1668528
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
A few files were missing license blurbs at the top, so update them all
to include them.
BUG=none
TEST=none
Change-Id: Ida101be2e5c255b8cffeb15f5b93f63bfd1b130b
Reviewed-on: https://chromium-review.googlesource.com/1577900
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
In Rust 2018 edition, `extern crate` is no longer required for importing
from other crates. Instead of writing:
extern crate dep;
use dep::Thing;
we write:
use dep::Thing;
In this approach, macros are imported individually from the declaring
crate rather than through #[macro_use]. Before:
#[macro_use]
extern crate sys_util;
After:
use sys_util::{debug, error};
The only place that `extern crate` continues to be required is in
importing the compiler's proc_macro API into a procedural macro crate.
This will hopefully be fixed in a future Rust release.
extern crate proc_macro;
TEST=cargo check
TEST=cargo check --all-features
TEST=cargo check --target aarch64-unknown-linux-gnu
TEST=local kokoro
Change-Id: I0b43768c0d81f2a250b1959fb97ba35cbac56293
Reviewed-on: https://chromium-review.googlesource.com/1565302
Commit-Ready: David Tolnay <dtolnay@chromium.org>
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Tolnay <dtolnay@chromium.org>
Separated out of CL:1513058 to make it possible to land parts
individually while the affected crate has no other significant CLs
pending. This avoids repeatedly introducing non-textual conflicts with
new code that adds `use` statements.
TEST=cargo check
TEST=cargo check --all-features
TEST=cargo check --target aarch64-unknown-linux-gnu
Change-Id: I290fc72e5624cf8b4b2bacaf124cc5b654255978
Reviewed-on: https://chromium-review.googlesource.com/1519696
Commit-Ready: David Tolnay <dtolnay@chromium.org>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Tolnay <dtolnay@chromium.org>
This is an easy step toward adopting 2018 edition eventually, and will
make any future CL that sets `edition = "2018"` this much smaller.
The module system changes in Rust 2018 are described here:
https://doc.rust-lang.org/edition-guide/rust-2018/module-system/path-clarity.html
Generated by running:
cargo fix --edition --all
in each workspace, followed by bin/fmt.
TEST=cargo check
TEST=cargo check --all-features
TEST=cargo check --target aarch64-unknown-linux-gnu
Change-Id: I000ab5e69d69aa222c272fae899464bbaf65f6d8
Reviewed-on: https://chromium-review.googlesource.com/1513054
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Tolnay <dtolnay@chromium.org>
I have been running into Debug-printed error messages too often and
needing to look up in the source code each level of nested errors to
find out from the comment on the error variant what the short name of
the variant means in human terms. Worse, many errors (like the one shown
below) already had error strings written but were being printed from the
calling code in the less helpful Debug representation anyway.
Before:
[ERROR:src/main.rs:705] The architecture failed to build the vm: NoVarEmpty
After:
[ERROR:src/main.rs:705] The architecture failed to build the vm: /var/empty doesn't exist, can't jail devices.
TEST=cargo check --all-features
TEST=FEATURES=test emerge-amd64-generic crosvm
Change-Id: I77122c7d6861b2d610de2fff718896918ab21e10
Reviewed-on: https://chromium-review.googlesource.com/1469225
Commit-Ready: David Tolnay <dtolnay@chromium.org>
Tested-by: David Tolnay <dtolnay@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>