This fixes "unused return value of `std::result::Result::<T, E>::map_or`
that must be used" warnings with Rust 1.73 and also makes the code
easier to understand.
Change-Id: Id028a0859db6a7b6670e1ed6f9c9cc443a2e7c61
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5007729
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Add test for the device tree overlay mechanism.
Bug: b/296796644
Test: cd cros_fdt && cargo test
Change-Id: I8e8d129344e1ad4ddf0d7af7b3f21c0c9d9ca038
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4855966
Commit-Queue: Jakob Vukalović <jakobvukalovic@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This change adds support for applying device tree overlays onto existing
Fdt instances. It ensures overlay phandles do not overlap with base
phandles.
The algorithm is roughly:
- Find the maximum phandle node property value used in the base FDT
(delta)
- Increment all phandle property values in the overlay by delta to avoid
phandle collisions
- For every property in the overlay where a phandle value pointing to a
node inside the overlay is used, increment the value by delta so the
references are once again correct
- For every property in the overlay where a phandle value points to a
node outside the overlay, update that location with phandle values
from base, so that the value points to a correct node in base FDT
- Update nodes and properties in base FDT with nodes and properties from
the overlay
Bug: b/296796644
Test: cd cros_fdt && cargo test
Change-Id: Ibff3c6dc3a9a1201c10da9004b295140d47929cd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4855965
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Jakob Vukalović <jakobvukalovic@google.com>
Align with the uAPI documentation, which states that
/**
* VFIO_CHECK_EXTENSION - _IOW(VFIO_TYPE, VFIO_BASE + 1, __u32)
*
* Check whether an extension is supported.
* Return: 0 if not supported, 1 (or some other positive integer) if supported.
* [...]
*/
TEST=tools/run_tests
BUG=b:306110430
Change-Id: Ifab1a55991a725653a8dc06a433f62ac841ec97c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5010356
Auto-Submit: Pierre-Clément Tosi <ptosi@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Some users of *.googlesource.com access the platform through the
internal Single Sign-On authentication mechanism so consider the sso://
remote as valid.
TEST=tools/cl upload
Change-Id: Ie7ebe4c9e165241645fddcdf1884b7e9e7a7d83d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5009550
Auto-Submit: Pierre-Clément Tosi <ptosi@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Avoid passing the file to Podman/Docker if it isn't present as that
prevents the container from running:
Error: stat /dev/kvm: no such file or directory
Even though the script may be used in cases where KVM isn't necessary.
Remove the check for POSIX as non-POSIX OSes are very unlikely to have a
file at that path.
TEST=tools/dev_container tools/run_tests --platform=aarch64
Change-Id: If46bb42076c79adfeab4baceb01913a9179ac00d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5010772
Auto-Submit: Pierre-Clément Tosi <ptosi@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
monitor_process() returns anyhow::Result, so print it with the alternate
format specifier to get the full chain of context messages in the panic
handler if it fails.
BUG=b:309463106
TEST=cargo build --features=swap
Change-Id: Id50b35dad980fc6e1d3c02ba4a85a598cc34ba8c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5006707
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Shin Kawamura <kawasin@google.com>
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>
We can't currently walk the page tables used when 5-level paging is
enabled. Previously, this was just an empty block, which causes a clippy
warning now. Add a log statement so the user can tell it won't work.
Change-Id: If7a3b635af8b5c95280cd23c142d764c6b6656a7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5005518
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Use the default AudioStreamsExecutor::wait_fd_readable implementation
instead, which just returns Ok(()).
Fixes a build error when trying to run clippy with Rust 1.72, which
seems to be related to the async_trait usage.
BUG=None
TEST=cd common/audio_streams; cargo test
Change-Id: I415cff6e7dbd2fdfee43693a04f8ce74da3eeb7a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5005516
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Remove pointer casts where the target type is the same as the original.
Change-Id: Ibb7bda2e4afcb5df2cd7c0bd9a075d0288b69f67
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5005512
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Remove unnecessary type casts and unnecessary .into_iter() for something
that is already an Iterator.
Also remove `let x = x;` local variable initializations where x is a
parameter with the same type.
BUG=None
TEST=tools/clippy # with rust-toolchain 1.73.0
Change-Id: Id18380b1cb617cc384e9944c2a48344dcafc6519
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5005511
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
With a fix in libtracemd-rs v0.2.1 [1], we no longer need to rebuild
libtracecmd-rs every time.
[1]: https://github.com/google/libtracecmd-rs/pull/6
BUG=none
TEST=cargo build
Change-Id: Ica1342c9b23ed778fff2c0677717e3953b42dbd9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5000825
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Ryuichiro Chiba <chibar@chromium.org>
Reviewed-by: Morg <morg@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
This commit modifies `check_lba_range` to return Result<(),
ExecuteError> instead of bool, which is more idiomatic. Also the
`max_lba` field in LogicalUnit is currently the size of the disk, so
this commit also changes the field to hold the lba.
TEST=tools/presubmit
BUG=b:300042376
Change-Id: I6c55fabbae9cbf53047d52435f16f1c3510f2d38
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4995951
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Commit-Queue: Joe Hattori <hattorij@google.com>
Currently crosvm allows only one SCSI device. This commit enables crosvm
to handle multiple SCSI devices. Each LogicalUnit contains a disk image,
and each controller contains all the LogicalUnits.
BUG=b:300042376
TEST=guest with multiple SCSI devices boots and FIO works on all
devices
TEST=./tools/run_tests2 --dut=vm -E 'test(test_scsi)'
Change-Id: I67653e9b7656e867277afbea24987cdefa9da0fb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4964673
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Rust API style usually omits the "get" from getters. Rename
get_max_open_files() to max_open_files() for consistency.
BUG=None
TEST=tools/dev_container tools/presubmit
Change-Id: Id272d56b6eb3d40d740644ec5e509ab85d00624a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5005638
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
These were only present on Linux and not used anywhere in the current
crosvm source code.
BUG=None
TEST=tools/dev_container tools/presubmit
Change-Id: I21a3211c7d678f093fc75e9fe8329c9365ed767a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5005637
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
This function can be implemented the same way on all platforms, so move
it out of the sys/ files.
BUG=b:309011910
TEST=tools/dev_container tools/presubmit
TEST=cargo build --target=aarch64-apple-darwin -p base
Change-Id: Ia894e3719c9ccc1c31f86d80e0c822bad81cd418
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5005633
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
`descriptor.rs` for `unix` loses the `PartialEq` implementation for
SafeDescriptor because the implementation for it relies on
linux-specific features, i.e. `kcmp`. It would be possible to
implement this differently using something based on `fstat` in the
future for other platforms like MacOS.
Bug: b/309020556
Test: cd base && cargo build --target=aarch64-apple-darwin
Test: tools/presubmit
Change-Id: I09560874d8876decfc4a492da206d42a4768a2c7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4834121
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
We should be using the builder-provided vpython to be able to
reliably testing recipes in the right environment.
Let's remove these to unblock the recipe roller, then add them
as a seprate step in the health check build recipe.
BUG=None
TEST=CQ
Change-Id: I14fa4d744ab83c01c54f9618854e5e5f657d9f60
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5005627
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This allows defining `platform` out of a composite of symbols from
different platforms, which is relevant for multi-platform pieces like
`unix`.
Bug: b/309011910
Change-Id: Iccdc7927dba6ecf4dd45c58ae0f6caa698b94c86
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4997936
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
The vhost kernel interface is specific to Linux; factor it out to a
separate file so it can be more easily controlled with a cfg check.
The rest of the virtio_sys bindings are generated from Linux uapi
headers, but they are valid for all platforms, so update the file-level
doc comment to match.
BUG=None
TEST=tools/dev_container tools/presubmit
TEST=cargo build --target=aarch64-apple-darwin -p virtio_sys
Change-Id: I1c7e1b6816993499ebf4431095e9308f7611a4d4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5005276
Reviewed-by: Cody Schuffelen <schuffelen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Refactor the build.rs platform detection to explicitly select the
Wayland support code when building for Linux (instead of skipping it
only for Windows).
BUG=None
TEST=tools/dev_container tools/presubmit
TEST=cargo build -p gpu_display --target=aarch64-apple-darwin
Change-Id: I9437acdc2e2439d0da094887a5a8f520f3279399
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5005295
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Cody Schuffelen <schuffelen@google.com>
the script may need a few other changes as my dev box already had
podman and potentially other dependencies. I uninstalled podman to test.
BUG=b:308883445
TEST=used script install on a dev box.
Change-Id: Ieb44587cc79b22952bc0c8154c9001f608e51769
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4998699
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
To make querying device tree node paths in device tree easier, implement
a `Path` struct. Node paths are used extensively in overlay "metadata"
which makes it possible to find phandle references stored as plain u32
property values.
Furthermore, node paths exported by an overlay will be used to resolve
device tree symbols (node labels) once overlay filtering is implemented.
Bug: b/296796644
Test: cd cros_fdt && cargo test
Change-Id: I9bae0a5643c054731c9d3b4cd92bb69de2b807d4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4855962
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Jakob Vukalović <jakobvukalovic@google.com>
Implement additional property APIs on FdtNodes. Beside the generic
property getter method, implement special getter and setter for phandle
values with an offset parameter. These will be used for updating phandle
references stored inside larger property values. Also, each FDT property type
now implements a new `AsFdtPropval` trait for parsing a binary property
value into a supported type.
Bug: b/296796644
Test: cd cros_fdt && cargo test
Change-Id: I2d9e2259e49f8a88e99d67b25672b1add7c0b6b5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4855961
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Jakob Vukalović <jakobvukalovic@google.com>
This is yet another refactoring to the USB backend code to support
future virtual USB devices. It replaces the dyn trait implementation
with a backend device enum type. This enum type will support different
backends in later CLs but here we start with a just host device
backend.
The backend device state is also split among DeviceState and
ControlTransferState which each holds stateful operations like endpoint
allocation and control transfer packet protocol handling. This in turns
also gives us more fine-grained locking control for read/write
operations on them individually.
BUG=b:297957754
TEST=presubmit and tested USB behavior on a DUT
Change-Id: Id500d158b68a584c4b71c0e044a22cae1909e8ed
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4938324
Reviewed-by: Ryuichiro Chiba <chibar@chromium.org>
Commit-Queue: Ryuichiro Chiba <chibar@chromium.org>
Auto-Submit: Morg <morg@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
We've been following most of these practices already, but it seems worth
writing them down especially for new contributors. Something new
here is `unsafe_op_in_unsafe_fn` which I saw in one of kawasin@'s swap
CLs. It seems like a really useful tool to help us convey more subtle
safety situations.
BUG=none
TEST=build mdbook & verified the page looks reasonable.
Change-Id: I4151d0cff9969900abbbe5832bb61c9a04327d8b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4996510
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Shin Kawamura <kawasin@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>