Commit graph

63 commits

Author SHA1 Message Date
Dennis Kempin
ccb9014afb Deprecate old dev tooling scripts
All of the developer tooling has moved to ./tools to make them
easier to discover.

BUG=None
TEST=None

Change-Id: I4daf6a0ca08c94a0c35ce8bc52f9d86e4cb15de9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3251781
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-11-02 22:23:03 +00:00
Dennis Kempin
ee56b2ddec Add presubmit script
Consolidates the utility scripts from bin/ into tools/.
Adds a 'presubmit' utility script to run a set of checks and
tests.

This won't be a git hook, but can be manually used to verify
changes before uploading.

BUG=b:199951064
TEST=./tools/presubmit --quick
./tools/dev_container ./tools/presubmit

Change-Id: Iac7c11fca0beaa6d4f214319149ef385fa5ced70
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3225139
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-10-18 20:10:41 +00:00
Daniel Verkamp
ca0aed3daa hypervisor: kvm: replace mem::transmute with safe loops
The conversion code for KVM <-> hypervisor representation of the Local
APIC state used the unsafe mem::transmute() function to view an array of
i8 as u8 instead for use with the Rust endian conversion functions.
Casting between integer types of the same size with `as` is defined in
Rust as a "no-op" (the bitwise representation is preserved), just like
in C, so transmuting at the slice level is not needed. These can instead
be written as simple loops to avoid the unsafe code.

To ensure this does not regress code quality, I have compared the code
generated for the x86-64 release build.  The kvm_lapic_state to
LapicState conversion compiles to identical code, and the reverse
compiles to slightly different code (the compiler decides to emit a loop
instead of unrolling the 64-element copy), but the conversion of each
element still compiles down to a pair of MOV instructions.

The corresponding unit test has also been updated to avoid transmute, as
it was unnecessary there - the individual array element can be cast with
the `as` operator rather than transmuting the whole array.

BUG=None
TEST=cargo test -p hypervisor

Change-Id: I7e792b5507235e5234afe114a1ca744931e047d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2947934
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-08-12 19:27:06 +00:00
Dennis Kempin
42b825f740 Switch to submodules based workflow
Instead of requiring crosvm to be checked out via the chromeos manifest
to access dependencies in the ChromeOS monorepo, this change adds
git submodules to third_party/.

The CI scripts and Cargo.toml are updated to use the new paths.

BUG=b:194336213
TEST=git clone --recursive https://chromium.googlesource.com/chromiumos/platform/crosvm
     cd crosvm
     cargo test
     ./test_all
     ./ci/kokoro/simulate_all

Change-Id: I9859d18176e21909ac3a140976fbd67cc14129bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3049003
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-08-05 18:32:32 +00:00
Dennis Kempin
50a58f9372 Integrate audio_streams into crosvm, add stub libcras implementation
The `# ignored by ebuild` tag will remove the path to libcras_stub and
allows crosvm to be built with the actual libcras implementation.

This allows all other platforms to build without depending on
`third_party/adhd/cras/client/libcras`, which is a prerequisite for
externalizing crosvm.

An empty libcras_stub crate is provided to keep cargo happy in external
builds.

To build with cargo against libcras, the setup_cros_cargo.sh script
can be used.

BUG=b:191511078
TEST=Tests in crosvm and cros_sdk both pass:
  $ ./test_all
  $ cros_run_unit_tests --package=crosvm

Cq-Depend: chromium:2993483
Change-Id: I86aad23a86c78e580c1724fb311f870b25d6b09e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2988154
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2021-07-29 05:59:42 +00:00
Daniel Verkamp
80e69a6c86 clippy: re-enable warnings that don't match anything
Some of the "To be resolved" warnings no longer match any of the current
crosvm code, so remove them from the list so new instances can be
caught.

BUG=None
TEST=bin/clippy

Change-Id: I29de2ef49ba1b84250c46fd41844b45b7a3f79a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2885788
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-25 21:50:49 +00:00
Daniel Verkamp
b792ffdcec devices: vios: remove unnecessary mut reference
The seq_socket_send() function only requires a non-mutable reference;
drop the mut.

Fixes clippy warning "the function `seq_socket_send` doesn't need a
mutable reference".

BUG=None
TEST=bin/clippy

Change-Id: I517a8d782601f33653db33c201666707beddd5ba
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2885787
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2021-05-25 21:50:48 +00:00
Daniel Verkamp
c80319182d tree-wide: replace single-leaf match with if let
Fixes the clippy warning:

  you seem to be trying to use `match` for destructuring a single
  pattern. Consider using `if let`

https://rust-lang.github.io/rust-clippy/master/index.html#single_match

BUG=None
TEST=bin/clippy

Change-Id: I5901a1fa0f487e0f012bad4c21b43ea300348031
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2885786
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2021-05-25 21:50:46 +00:00
Daniel Verkamp
561abaffdb devices: vios: remove redundant map_err closures
Fixes clippy warning "redundant closure found".

https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure

BUG=None
TEST=bin/clippy

Change-Id: Ic87dacb1a60f2125d3eb60aae60ffbcd6a774ada
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2885785
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2021-05-22 00:43:29 +00:00
Daniel Verkamp
34d2b36a42 devices: irqchip: rewrite if-let-else None with ?
Replace an else block that just returns None with the equivalent use of
the question mark operator, and rewrite the comment that used to be in
the else block to match.

Fixes the clippy warning "this if-let-else may be rewritten with the `?`
operator".

https://rust-lang.github.io/rust-clippy/master/index.html#question_mark

BUG=None
TEST=bin/clippy
TEST=cargo test -p devices

Change-Id: Ifda6d55c16e12fc7939343757d7f2843b4df9b27
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2885784
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
2021-05-22 00:43:29 +00:00
Daniel Verkamp
3638ae21f8 Remove needless returns
Fixes clippy warning "unneeded `return` statement".

BUG=None
TEST=bin/clippy

Change-Id: Ib31ce9c31d4edccd9c3a518dfa3a07186124d259
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2885783
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-05-22 00:43:28 +00:00
Daniel Verkamp
15fadba6ea devices: replace .into_iter() on ref with .iter()
Fixes clippy warning:

  this `.into_iter()` call is equivalent to `.iter()` and will not
  consume the `slice`

https://rust-lang.github.io/rust-clippy/master/index.html#into_iter_on_ref

BUG=None
TEST=bin/clippy

Change-Id: Id31c3f6252b86a7f453ab4e6e7dac0ed6654bc52
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2885782
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2021-05-22 00:43:27 +00:00
Daniel Verkamp
358101242a devices: drop redundant clone calls
Fixes clippy warnings like:

  using `clone` on type `...` which implements the `Copy` trait

and

  redundant clone
  note: this value is dropped without further use

BUG=None
TEST=bin/clippy
TEST=cargo test -p devices

Change-Id: I8c13b79b54265e5527cadcb8a2e9f54419044bcf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2885781
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-22 00:43:27 +00:00
Daniel Verkamp
0ee9babf9c rutabaga_gfx: replace u8 cast with byte literal
Fixes clippy warning: "casting a character literal to `u8` truncates"

https://rust-lang.github.io/rust-clippy/master/index.html#char_lit_as_u8

BUG=None
TEST=bin/clippy

Change-Id: I822de805f122ee14cc4856c36c9ef48de6432fa2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2885780
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2021-05-22 00:43:25 +00:00
Daniel Verkamp
34050dc2e1 bin/clippy: temporarily ignore warnings from external crates
These need to be resolved in repositories outside crosvm, so add them to
the ignored list for now.

BUG=None
TEST=bin/clippy

Change-Id: I75b20ff2c84bfc72cd7d3c4421428a82600e6778
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2864371
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 22:06:58 +00:00
Dennis Kempin
d5b4cbe6d9 Remove sync_ebuild_files script
This script was a hack to reduce some manual work we had to do
regularly. A better script has been submitted at:

https://source.corp.google.com/chromeos_public/src/platform/dev/contrib/cargo2ebuild.py

BUG=b:175120466
TEST=None

Change-Id: I8b14ad22576fd80370287bf798f31e6a7b93f04d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2848285
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-04-26 20:37:48 +00:00
Daniel Verkamp
6ded64f192 unblocked_terms.txt: clean up trivial cases
Avoid some easily-replaced non-inclusive words and remove them from the
unblocked_terms.txt list.

Remove a clippy lint with a name matching the list since all affected
warnings have already been removed.

Remove all terms that are already not present in the crosvm
repository from unblocked_terms.txt (including the commented lines).

BUG=b:178821708
TEST=../dev/contrib/search_blocked_words.sh unblocked_terms.txt
TEST=cargo test -p devices
TEST=cargo test -p disk
TEST=bin/clippy

Change-Id: I8261921380decc839f01adb9ad1d4d14d5a85114
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2847462
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-04-26 20:32:38 +00:00
Zach Reizner
d09392e37e uprev rust-toolchain and fix clippy warnings
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>
2021-03-22 21:41:07 +00:00
Dennis Kempin
4f41c7ebc7 crosvm: Remove old test infrastructure
This is replaced by test_all and the new builders for kokoro.
See ci/README.md for details.

BUG=b:178233937
TEST=None

Change-Id: Id8bf721e026e71d9f284f920ef8287beb414c621
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2705292
Tested-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2021-03-03 07:05:03 +00:00
Dennis Kempin
de8c806279 Add script to sync Cargo.lock with ebuild files
This is a simple python script to uprev ebuild files where Cargo.lock
has a newer version, and vice versa.

The script is run to fix up some libraries that got out of sync.
The protobuf dependencies should be upreved, but newer versions
have deprecated some of the methods we use, causing clippy warnings.

BUG=b:175120466
TEST=Tests in Kokoro and CQ pass

Cq-Depend: chromium:2704533
Change-Id: I1485fbffba61e72502f8398320094dfe2c7ffeea
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2705681
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: kokoro <noreply+kokoro@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-02-27 06:44:49 +00:00
Dennis Kempin
0dbb9808a6 Add Kokoro for ci/builders
Adds the crosvm-side infrastructure to build and test
in kokoro.
There is a build script for testing on x86, aarch64
and a separte script for analysis (clippy, fmt).
These will run in parallel on Kokoro. To test the
scripts locally, a simulate script is provided.

Runtime on my workstation:
- aarch64: 10m
- x86: 2:30m
- analysis: 1:40m

BUG=b:177951955
TEST=./ci/kokoro/simulate_all

Change-Id: I2f666ec768e6c3391a258dc7f0cbd999ad9b2fb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2654413
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2021-02-05 03:01:55 +00:00
Dennis Kempin
831b11e869 Add scripts to run code coverage
One script to run coverage for the whole smoke test suite,
the resulting file can be uploaded to codecov.io for consumption:
https://codecov.io/gh/denniskempin/crosvm

Another script to run tests + coverage for a single crate,
which is useful during development to keep track of coverage
while adding tests (IDEs can display the generated lcov.info file)

BUG=b:171082843
TEST=Manual testing of both scripts

Change-Id: I52384762400a146cb0e7deb3d54dccf59b6134db
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2492914
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Dennis Kempin <denniskempin@google.com>
2020-10-27 05:22:32 +00:00
Daniel Verkamp
603548ac4e docker: upgrade to Rust 1.45.2
This is the version that is already being used, since the rust-toolchain
file is just set to 'stable' now. Update the Docker image so that kokoro
does not have to re-download the new Rust toolchain for every build.

Also, explicitly update the default rustup toolchain to 'stable' in the
Dockerfile - this prevents `docker run` from having to re-download the
toolchain.

While we're on a cleanup spree, remove the addition of rustfmt-preview
from the smoke_test script; rustfmt is now included by default when
installing a toolchain via rustup.

BUG=None
TEST=docker/build_crosvm_base.sh && docker/wrapped_smoke_test.sh

Change-Id: I1359bd7b39dd4ebeaf970a001e0002b3699c9771
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2333116
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-08-11 00:50:48 +00:00
Daniel Verkamp
e0d7c8266a clippy: remove set -u to fix errors on older bash
With versions of bash before 4.4 (such as bash 4.3 provided by the cros
sdk), expanding an empty array when `set -u` is in effect causes an
error:

  bin/clippy: line 93: CLIPPY_ARGS[@]: unbound variable

This could be avoided by testing the CLIPPY_ARGS variable before
expanding it, but this is such a small and simple script that removing
`set -u` seems more appropriate.

BUG=chromium:1105466
TEST=`bin/clippy` with no args inside cros_sdk

Change-Id: Id56a99bf23f3d9b97b6b7f8a62dce95f9112caa6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2324061
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2020-07-31 04:30:18 +00:00
Keiichi Watanabe
d9b8c77e85 crosvm: Add a pre-upload hook to run clippy
BUG=chromium:1105466
TEST=repo upload a CL

Cq-Depend: chromium:2297362
Change-Id: Ibbabaf4d8a1180dcbbe2732b07bcd0a8e38de5f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2303129
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
2020-07-28 16:29:06 +00:00
Keiichi Watanabe
29495300de bin/clippy: Add option to skip cleaning cache
Add --use-cache option in bin/clippy to run cargo-clippy without
deleting cache. It is useful when we use bin/clippy for multiple commits
in pre-upload hook.

BUG=chromium:1105466
TEST=bin/clippy w,w/o --use-cache

Change-Id: I386c7e08ad48ea2446a91e99d4b6523673211d6f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2297005
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2020-07-28 16:29:02 +00:00
Keiichi Watanabe
36b2a0df71 crosvm: Fix clippy::needless_doctest_main
We can omit main() function in documantation tests.
cf. https://doc.rust-lang.org/rustdoc/documentation-tests.html#pre-processing-examples

BUG=none
TEST=cargo test
TEST=bin/clippy

Change-Id: Iaad756ac32d106b2b2bcee44c9301244f647f8f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2301675
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2020-07-21 13:18:10 +00:00
Daniel Verkamp
043aaea79b docker: update to rust 1.42 and rustup 1.21.1
Update to the latest rustup release, which (since 1.20.0) installs
rustfmt and clippy by default:
https://blog.rust-lang.org/2019/10/15/Rustup-1.20.0.html

Also update the Rust toolchain version to 1.42.0 to match the version in
the CrOS build environment.

Additionally, add workarounds for sysroot of cargo clippy.

BUG=None
TEST=docker/build_crosvm_base.sh && docker/wrapped_smoke_test.sh
TEST=bin/clippy on workstation

Change-Id: I7ac4db92f4e5f277d77a77fa3c4ffa880f2ae116
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2150988
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2020-04-18 12:01:32 +00:00
Keiichi Watanabe
40af8ee748 crosvm: Enable cargo clippy in smoke_test
Enable cargo clippy in the smoke test script for kokoro with many whitelisted rules
to be resolved. This check will reject compile warnings as well.

Also, this CL removes cargo check in Docker.crosvm as cargo clippy is a superset of
cargo check.

BUG=chromium:908640
TEST=./wrapped_smoke_test.sh

Change-Id: Iaa546fc0166e3d9762c5e91144d036725d38b0f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2145538
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2020-04-15 18:01:34 +00:00
Dylan Reid
7e24a8e759 bin/fmt: Set rustfmt edition to 2018
The default is 2015 and that causes any usage of `async` to cause kokoro
errors.

Change-Id: I9f962b6f578b0d1992377dfefdd724c080a6f1b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2024365
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2020-02-05 09:00:27 +00:00
Lepton Wu
84be74727c Remove render node forward code
We don't use it for ARCVM now.
BUG=None
TEST=`emerge-eve crosvm`
Change-Id: I14343a2eb24c24a0216950b7c4eeb56ac482973e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1958569
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Lepton Wu <lepton@chromium.org>
Auto-Submit: Lepton Wu <lepton@chromium.org>
2019-12-10 19:14:40 +00:00
Daniel Verkamp
3530f2a2bb bin/fmt: ignore generated files in target dir
Don't check formatting for *.rs files generated by the protobuf code
generator.

BUG=None
TEST=bin/fmt --check
TEST=docker/wrapped_smoke_test.sh

Change-Id: I74af762d2758e6106a855f27214646b51f640b11
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1876838
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2019-10-25 23:54:14 +00:00
Daniel Verkamp
1769b63686 bin/fmt: remove use of cargo fmt
This simplifies our formatting script so that it does not need any of
the Cargo metadata to run; the new version just finds all Rust files
(*.rs) and runs `rustfmt` on them individually.

BUG=None
TEST=bin/fmt
TEST=bin/fmt --check

Change-Id: I45aaee497d4f1dfcc03b3e2c5c2f27feb974dc80
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1865371
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-10-21 19:26:04 +00:00
Daniel Verkamp
afef8d7baf usb: clean up clippy unit_arg warning
Fix the last instance of this clippy warning:

  warning: passing a unit value to a function

... and remove this warning from the "To be resolved" list in
bin/clippy.

BUG=None
TEST=bin/clippy passes without warnings

Change-Id: Ic1d558e935366d80eeadb96bf1ff951ce50edd5b
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1766623
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-08-26 19:34:39 +00:00
Jakub Staron
4197d3a3a1 crosvm: add license blurb to bin/clippy and bin/fmt files
bin/clippy and bin/fmt were missing license blurbs at the top,
so update them to include the license blurbs.

BUG=None
TEST=None

Change-Id: Ic6bb5af3885d3735dcad42614aff7ac3dd33d638
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1646736
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jakub Staroń <jstaron@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2019-06-08 04:27:35 +00:00
Zach Reizner
127453d7ec eliminate mut from non-mut references
This manifested itself in a couple places that were turning shared
memory buffers into slices for the purposes of passing these slices to
`Read` and `Write` trait methods.

However, this required the removal of the methods that took `Read` and
`Write` instances. This was a convenient interface but impossible to
implement safely because making slices from raw pointers without
enforcing safety guarantees causes undefined behaviour in Rust. It turns
out lots of code in crosvm was using these interfaces indirectly, which
explains why this CL touches so much.

TEST=crosvm run
BUG=chromium:938767

Change-Id: I4ff40c98da6ed08a4a42f4c31f0717f81b1c5863
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1636685
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
2019-06-04 20:29:25 +00:00
Zach Reizner
6868c0a72f add docker supported builds and tests
BUG=None
TEST=docker/build_crosvm_base.sh
     docker/build_crosvm.sh
     docker/wrapped_smoke_test.sh
     docker/crosvm_wrapper.sh
     kokoro/kokoro_simulator.sh
     bin/smoke_test

Change-Id: I55a805ba6326c3c58973d1fe21172a5e3551c1e2
Reviewed-on: https://chromium-review.googlesource.com/1593723
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2019-05-15 13:36:19 -07:00
David Tolnay
4b292afafc clippy: Resolve cast_ptr_alignment
This CL fixes four cases of what I believe are undefined behavior:

  - In vhost where the original code allocates a Vec<u8> with 1-byte
    alignment and casts the Vec's data pointer to a &mut vhost_memory
    which is required to be 8-byte aligned. Underaligned references of
    type &T or &mut T are always undefined behavior in Rust.

  - Same pattern in x86_64.

  - Same pattern in plugin::vcpu.

  - Code in crosvm_plugin that dereferences a potentially underaligned
    pointer. This is always undefined behavior in Rust.

TEST=bin/clippy
TEST=cargo test sys_util

Change-Id: I926f17b1fe022a798f69d738f9990d548f40c59b
Reviewed-on: https://chromium-review.googlesource.com/1566736
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>
2019-04-18 19:51:29 -07:00
David Tolnay
35ee9d9184 clippy: Resolve useless_format
TEST=bin/clippy

Change-Id: I13fcde5655f9f9c207c9a704fa32b99510946a1e
Reviewed-on: https://chromium-review.googlesource.com/1566893
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>
2019-04-17 17:22:56 -07:00
David Tolnay
d611f27cb1 clippy: Resolve unused_unit
TEST=bin/clippy

Change-Id: I96fe9711d99a999cda706a8b78f79ff5ef8f60de
Reviewed-on: https://chromium-review.googlesource.com/1566892
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>
2019-04-17 17:22:56 -07:00
David Tolnay
2b82fbbeda clippy: Resolve unneeded_field_pattern
TEST=bin/clippy

Change-Id: Ia0e0163441fafd4ce44fef7ebaa18d1cc947e20e
Reviewed-on: https://chromium-review.googlesource.com/1566891
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>
2019-04-17 17:22:55 -07:00
David Tolnay
60ac43971a clippy: Resolve toplevel_ref_arg
TEST=bin/clippy

Change-Id: Iad8145deb3d96eb53ca8109636f2e04bca29f853
Reviewed-on: https://chromium-review.googlesource.com/1566890
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>
2019-04-17 17:22:55 -07:00
David Tolnay
4b74f59c2a clippy: Resolve string_lit_as_bytes
TEST=bin/clippy

Change-Id: Icf56040c26cd67560358d360353d276146a63eca
Reviewed-on: https://chromium-review.googlesource.com/1566749
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>
2019-04-17 17:22:54 -07:00
David Tolnay
9f2929479b clippy: Resolve single_match
TEST=bin/clippy

Change-Id: Iea0d3539b3ab587a2d97f676e1d9c7a239504308
Reviewed-on: https://chromium-review.googlesource.com/1566748
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>
2019-04-17 17:22:54 -07:00
David Tolnay
5e73d9090a clippy: Resolve redundant_pattern_matching
TEST=bin/clippy

Change-Id: I7b8fc90ae5250e7a506b75345a66305653a095ac
Reviewed-on: https://chromium-review.googlesource.com/1566746
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>
2019-04-17 17:22:53 -07:00
David Tolnay
5fb3f51517 clippy: Resolve redundant_closure
TEST=bin/clippy

Change-Id: Id4f38956d788e4402df164df03e80c4b487b1ad6
Reviewed-on: https://chromium-review.googlesource.com/1566745
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>
2019-04-17 17:22:53 -07:00
David Tolnay
56c2d3631c clippy: Resolve option_map_unit_fn
TEST=bin/clippy

Change-Id: I814cfce68c147f63d96fce6d0c465488ad3e336a
Reviewed-on: https://chromium-review.googlesource.com/1566744
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>
2019-04-17 17:22:53 -07:00
David Tolnay
9239602d69 clippy: Resolve needless_return
TEST=bin/clippy

Change-Id: I62eb3f86b01a6000107c54a967689d4e430adf50
Reviewed-on: https://chromium-review.googlesource.com/1566743
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>
2019-04-17 17:22:52 -07:00
David Tolnay
c2d71acc45 clippy: Resolve match_ref_pats
TEST=bin/clippy

Change-Id: I3eceba7418992d453dea9f429d45e4e2a72740fc
Reviewed-on: https://chromium-review.googlesource.com/1566742
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>
2019-04-17 17:22:52 -07:00
David Tolnay
55bc919e69 clippy: Resolve let_and_return
TEST=bin/clippy

Change-Id: I83e7fa6fd9075370854b7c651311642748916dc6
Reviewed-on: https://chromium-review.googlesource.com/1566741
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>
2019-04-17 17:22:51 -07:00