Use rand::random() or rand::Rng::fill() in place of the now-removed
OsRng.fill_bytes(), note that the generic function now supports arrays
of any length.
Replace the deprecated rand::thread_rng() with its new name rand::rng()
or with new alternatives such as rand::random_range() where appropriate.
In fuzz/, update the impl of rand_core::RndCore which now does not
require implementing try_fill_bytes() (moved to TryRndCore) so remove it
as the function was only used by unit tests (which can also be removed).
As a result, CrosVM now follow the clean split of all client code only
depending on rand::Rnd (no imports of RndCore left) and the one provided
(FuzzRng) uses the rand_core crate, as recommended by the crate docs.
BUG=b:460349550
TEST=tools/presubmit
Change-Id: Icf0121297efcb0388e8aab17394c21457edbb119
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/7253053
Auto-Submit: Pierre-Clément Tosi <ptosi@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Pierre-Clément Tosi <ptosi@google.com>
To support AHB as rutabaga resource, extend RutabagaHandle to an enum of
MesaHandle or AhbInfo. MesaHandle isn't enough to store every
information which AHB needs.
And RutabagaHandle(especially AhbInfo) is expected to be used for blob,
not fence, so make blob-related function use RutabagaHandle instead of
MesaHandle.
And restore ag/34872403 behavior about zero-copy with new
RutabagaHandle(AhbInfo)
Refer to https://github.com/magma-gpu/rutabaga_gfx/pull/37
Bug: b:453989233
Test: build && the buffer for screen is zero-copied
Change-Id: Iad490c6127f9998570e7b7dbab903b88f089373b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/7262326
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Jeongik Cha <jeongik@google.com>
To prepare for Rust toolchain uprev, ran `tools/clippy --fix` with
Rust 1.88 for each platform.
To build with the current Rust version 1.81, some changes with unstable
features were manually reverted.
BUG=b:455879436
TEST=CQ
Change-Id: I4a91460d4fc2de5d7afbc2da04b7f7765219bb2e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/7089630
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Recently, all the "gfxstream" feature usage in the "devices" crate was
removed. This commit goes a step farther by remove the "gfxtream"
feature from the "devices" crate entirely. Instead, the top level
"gfxsteam" feature only enables gfxstream in the "rutabaga_gfx"
dependency. The Windows specific gfxstream integration in the
"gpu_display" crate is control with a separate, new "gfxstream_display"
feature.
Previously, "gfxstream" would implicitly enable "devices/gpu", but build
that enables the top level "gfxstream" without the top level "gpu"
feature was and is broken because "vm_control/gpu" and "gpu_display"
would be off. So, I've removed the implict "gfxstream => devices/gpu"
edge to avoid confusion.
Change-Id: I36d3185c85220a795a6bdc72f2e568cfcc0c67e3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/7017494
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
... so that all the needed protocols for Cuttlefish's wayland
server are included in the single Crosvm project.
Bug: b/402245771
Test: n/a
Change-Id: I778e0035688b53b1066f1a72bd7e06653ac1af23
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/6379563
Commit-Queue: Jason Macnak <natsu@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This was requested to fix some issues in mesa CI.
This is also the version that ChromeOS vendors.
BUG=b:397464790
TEST=None
Change-Id: I50313c3b24d7cb098523c7f96b0ad0fbc28f0905
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/6299710
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Fix doc comments that were detached from the items they were intended to
describe or malformed in other ways.
Change-Id: I1d53f58554a4061e69b05b712a98c2c6137354fe
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/6195236
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Add the minimal allow(dead_code) and feature declarations to allow the
clippy checks to pass for Windows with Rust 1.81.
BUG=b:365852007
TEST=tools/presubmit clippy_mingw64
Change-Id: I9ab776b07d8e9e14fe380d9b5ef1fa332788ff63
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/6013080
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This reverts commit 2744e5fef6.
Reason for revert: This cmd line param is no longer being used
BUG=b:364906315
Original change's description:
> gpu: Add parameter for a custom cursor file
>
> This will be used to display a custom mouse cursor for Surfaces. This CL
> won't change any functionality
>
> BUG=b:362814745
> TEST=builds and presubmits
>
> Change-Id: If4e5a41bdaa92fecf680aa09fe8e2ca154946d07
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5825087
> Reviewed-by: Noah Gold <nkgold@google.com>
> Commit-Queue: Richard Zhang <rizhang@google.com>
> Reviewed-by: Pujun Lun <lunpujun@google.com>
Bug: b:362814745
Change-Id: Ib975f92e96e3adb07e1fa27d1a5e6c870e76881a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5876365
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Android guest doesn't work if there is no touch event.
BUG=b:364360076
TEST=manual - run crosvm with Android guest and mouse click works.
Change-Id: Ia678854d469e56bfa24f60721677222455ab1500
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5832986
Commit-Queue: Lepton Wu <lepton@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Some doc comments were being incorrectly interpreted due to missing
indentation (for intentional line contintuations) or line breaks (for
new lines that were intended to be separate paragraphs).
Clippy warns about these as of Rust 1.80:
<https://rust-lang.github.io/rust-clippy/master/index.html#/doc_lazy_continuation>
Fix them along with some other nearby minor formatting cleanups.
TEST=tools/cargo-doc
TEST=tools/clippy # with rust-toolchain 1.80
Change-Id: Ice0b7cc3bd75d9ab08c10107a13f95ca9f87a0a3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5758934
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This will be used to display a custom mouse cursor for Surfaces. This CL
won't change any functionality
BUG=b:362814745
TEST=builds and presubmits
Change-Id: If4e5a41bdaa92fecf680aa09fe8e2ca154946d07
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5825087
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Pujun Lun <lunpujun@google.com>
... to reflect changes from aosp/3127803 where an internal struct
is now used to allow for updates to the underlying ANativeWindow
when the viewer app is stopped/resumed.
Bug: b/334903567
Test: presubmit
Change-Id: I96e258e864e2265a66e253af400afba9e5c50073
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5637775
Reviewed-by: Jiyong Park <jiyong@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Jason Macnak <natsu@google.com>
dwl_context_new() did not check if the allocation failed before using
the returned pointer.
BUG=None
TEST=tools/dev_container tools/presubmit
Change-Id: Ibeb0fb0b0a6e434657f09f8c24a7bd6ff7f8c21a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5634619
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
1. Handle cursor scanout as well
2. Add set_android_surface_position to handle cursor move event
Bug: 327559087
Test: check cursor in vm
Change-Id: I5429cb88a0f7983df015e05745070bf71f7c15ad
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5569432
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Jiyong Park <jiyong@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Ensure that every Cargo.toml dependency on a third-party crates.io crate
specifies at least a major version, or a minor version for 0.x crates,
to ensure that if a new major version is published, it cannot cause API
breaks.
The versions are selected to match the ones already in Cargo.lock, so
this should have no functional change, but it will help prevent new "*"
versions from being introduced via copy-and-paste.
For rationale, see the Cargo FAQ:
<https://doc.rust-lang.org/cargo/faq.html#can-libraries-use--as-a-version-for-their-dependencies>
`minijail`, `audio_streams`, and `cras` are left as "*" for now, since
they have unusual situations (imported from a submodule and/or replaced
at build time with ebuild magic).
BUG=None
TEST=tools/dev_container tools/presubmit
TEST=verify Cargo.lock is unchanged
Change-Id: Ifa18199f812f01d2d10bfb4146b3353c1a76527c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5555656
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
GFX work often requires review from domain expers, but until now we have
not formally enumerated this list.
BUG=b:328338772
TEST=n/a
Change-Id: If71c03270df675d43049c95491f91a5229ca05b5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5437463
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
This parameter specifies the max number of concurrent crosvm
displays we support. By default, it will be VIRTIO_GPU_MAX_SCANOUTS
(i.e. 16). Different products may choose different upper bounds,
but it should never exceed VIRTIO_GPU_MAX_SCANOUTS. For Windows,
this defines the max number of concurrent windows.
BUG=b:332910955
Change-Id: I9127133e444063f791bc01715ef9a383fc8b9ee6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5426762
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
This change refactors the C interface between crosvm and the android
display backend which is designed to be implemented outside of crosvm.
The below is a few important changes:
* The new interface allows crosvm to draw directly on Android surface.
Previously, we allocated a framebuffer in crosvm, let crosvm draw on
it, and passed it to the Android-side backend where the framebuffer
is copied to Android surface using CPU.
* Respect stride set by Android. When a buffer is created on the Android
side, the stride is usually set to a multiple of 16 for maximum
performance. This change reports that stride back to crosvm so that it
can respect the stride. Previously, we used a stride value that is equal
to the screen width which may not be multiple of 16.
* The error callback function pointer is passed to the Android side only
when the context is created. The Android side is expected to keep the
pointer along with the context and use it when something goes wrong.
Bug: 331900473
TEST=./tools/presubmit
Change-Id: I3e5b05407c41413ea55bba37cb7f34f504799734
(cherry picked from commit 4e5494276d9736fa697bcd3e62207f8708b1c0a4)
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5446565
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
"width" and "height" are removed from the interface since they can
be derived from DisplayParameters.
Windows implementation was assuming only one display, so
DisplayParameters was passed in with GpuDisplay::open_winapi() and
assumed not to change. To support multi-display, it needs to be
passed in every time we create a new surface. This should make no
functional change to other platforms.
BUG=b:332910955
Change-Id: I32767a37c8a1f50716190e13aa94c9c159db3d04
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5041413
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Previously, the X display window did not have a title. Set it to
"crosvm" to match the Wayland display and make it easier to find when
switching windows.
BUG=None
TEST=tools/examples/example_desktop
Change-Id: I4fc2b2bfdb6e4dd008b3a1f274a6c0b4eb6d020d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5402949
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
This change introduces two features:
* android_display and
* android_display_stub
The android_display feature adds a new GPU display backend for Android
which emits the display output to an Android surface. The surface is not
created by the backend itself, but by an external entity (ex: Android
app) by creating a SurfaceView. This allows us to display a VM anywhere
the app is shown.
The owner of the surface (the app) is expected to share the surface with
the new backend by calling an AIDL method that the backend will
implement. The AIDL service implementing the method will be registered
to the service manager using the name set via the cmdline option
--android-display-service NAME.
This CL however doesn't include the implementation of the AIDL service
because upstream crosvm doesn't support building an AIDL service and
Android-specific libraries like libnativewindow. Instead, the
android_display_stub feature provides a no-op stub for the AIDL service,
so that we can at least build the rest of the new display backend.
TEST=cargo build
TEST=cargo build -F android_display,android_display_stub
TEST=./tools/run_tests
TEST=./tools/run_tests -F android_display,android_display_stub
TEST=./tools/presubmit
Bug: 325929966
Change-Id: I24f672beaa4a28253f150306a64df34f4962361e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5390926
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Jiyong Park <jiyong@google.com>
Use zerocopy functions directly instead. This is a step toward replacing
our data_model crate with standard crates.io functionality where
possible.
BUG=b:312312646
TEST=tools/dev_container tools/presubmit
Change-Id: I9717edce6fe2b4ca53ad9043db61de2e9bc55b78
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5046345
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Add a new vulkan interface to GpuDisplay and GpuDisplaySurface, and
implement the new interface for GpuDisplayWin using VulkanDisplay.
Test: ran emulatorNexusHwcTest
Change-Id: I241af4edaae7c5d5d99f6b27fb2a7448b9a1b321
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5214575
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
The event device type was missing, which makes it a hassle to determine
the type (it can be done from the index). Our path for reading events
also threw away the underlying error, which makes debugging pretty
tricky. This CL fixes both issues.
BUG=b:324486429
TEST=builds
Change-Id: Ie42c065fc6b35c9195db136b94e8831d82c8a23e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5351358
Reviewed-by: Pujun Lun <lunpujun@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
The lazy_static crate should not be used in crosvm (it has been replaced
with once_cell in https://crrev.com/c/3707624), and sync::Mutex can be
statically initialized now (https://crrev.com/c/5318701), so the lazy
initialization is not even necessary.
Additionally, the once_cell dependency was unnecessarily reintroduced;
it is unused, so it can be removed from Cargo.toml (again).
Change-Id: I263d856e72dbf531ab25595c60f9e88aba9e321f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5342656
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Implementation of PostResource and the vulkan calls that blit the image
to the swapchain image.
Test: build
Change-Id: Ib76043ee30e1ef4ff5f1da77bbb2d2548e7af681
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5214573
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Mateusz Przybylski <mprzybyl@google.com>
The post worker is responsible for actually posting images to the
display when `post` is called. The image supplied to `post` is copied to
the swapchain image (via a blit operation) and then the swapchain image
is queued for presentation to the display.
Test: build
Change-Id: Ief7bb4aed9b33d3fab48696193d6a3bb438dbf24
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5214572
Reviewed-by: Mateusz Przybylski <mprzybyl@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Implement the top level types of vulkan display, including
VulkanDisplay and VulkanState and VulkanStateBuilder.
Test: build
Change-Id: I8bf7113d14219500f7a1388bc8ebb73f89bc8d09
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5214570
Reviewed-by: Mateusz Przybylski <mprzybyl@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
This is a new display path for creating vulkan-based surfaces.
Test: build
Change-Id: I28e3b455ed265b615c4f8fe7c6ac28e2da81ec2e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5214569
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Example command:
crosvm gpu set-mouse-mode <control_socket_path> \
--display-id=0 \
--mouse-mode=relative
This enables the Windows implementation to toggle mouse capture
mode (touchscreen <-> relative). It will have no effect if the
specified "display-id" doesn't point to an existing guest display
associated with an in-use host display.
BUG=b:324087519
TEST=presubmit
Change-Id: I9e513eb692d4b9cba66eb1e629ab8f7018645059
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5319794
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
MouseInputManager supports touchscreen mode and relative mode (i.e.
captured mouse cursor). The relative mode uses Windows raw input
events. Since only one window in an application can receive those
events, we register the raw input device with the MessageOnlyWindow
and reroute the raw input events to the current foreground GUI
window.
BUG=b:254702853
TEST=presubmit
Change-Id: I18e4d62777bdf0e7d39267426d1301fa6211af31
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5318692
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Pujun Lun <lunpujun@google.com>
We will create per-scanout touchscreen devices to support multi-window.
DisplayEventDispatcher is updated to manage multiple device ids for one
kind of event devices, and GuiWindow needs to be passed around in
KeyboardInputManager and MouseInputManager to provide the scanout id
when we need to dispatch events to the guest.
BUG=b:254702853
TEST=presubmit
Change-Id: Ie40d2e67bab3a564b17c41555f4ba235993b0e19
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5318691
Reviewed-by: Richard Zhang <rizhang@google.com>
Commit-Queue: Pujun Lun <lunpujun@google.com>
Missed these since they used the fully qualified sync::Mutex instead of
just Mutex.
Change-Id: I20748fa4a1271ce3b89e576e9c0925ab894104bc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5321445
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>