As described in:
https://doc.rust-lang.org/edition-guide/rust-2018/ownership-and-lifetimes/default-match-bindings.html
which also covers the new mental model that the Rust Book will use for
teaching binding modes and has been found to be more friendly for both
beginners and experienced users.
Before:
match *opt {
Some(ref v) => ...,
None => ...,
}
After:
match opt {
Some(v) => ...,
None => ...,
}
TEST=cargo check --all-features
TEST=local kokoro
Change-Id: I3c5800a9be36aaf5d3290ae3bd3116f699cb00b7
Reviewed-on: https://chromium-review.googlesource.com/1566669
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>
Protoc_rust emits this into every file it generates:
#![cfg_attr(feature = "cargo-clippy", allow(clippy))]
which is the old style of tool attribute. It is deprecated in favor of
actual tool attributes that stabilized in rust 1.31.
#![allow(clippy::all)]
Without this PR, the warning when running bin/clippy looks like:
warning: lint name `clippy` is deprecated and may not have an effect in the future.
--> /chromiumos/src/platform/crosvm/target/debug/build/protos/out/trunks/interface.rs:6:10
|
6 | #![cfg_attr(feature = "cargo-clippy", allow(clippy))]
| ^^^^^^
|
= note: #[warn(renamed_and_removed_lints)] on by default
TEST=bin/clippy
Change-Id: I1a484379a8f53d76d3667590cd8458588492d2b1
Reviewed-on: https://chromium-review.googlesource.com/1567849
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>
Still TODO: Interrupt routing (and tests for that).
BUG=chromium:908689
TEST=Unit tests in file. Integration testing is blocked on rest of split-irqchip being implemented.
Change-Id: I08c187c44e49889ffc47322ede0f1223c6265757
Reviewed-on: https://chromium-review.googlesource.com/1565306
Commit-Ready: Miriam Zimmerman <mutexlox@chromium.org>
Tested-by: Miriam Zimmerman <mutexlox@chromium.org>
Reviewed-by: David Tolnay <dtolnay@chromium.org>
AddressRanges' name doesn't suggest that it's a SystemAllocator builder.
This CL renames it to SystemAllocatorBuilder, and adds a
SystemAllocator::builder() that removes the need to have a separate
import for the Builder.
A minor change, but it cleans up the interface a bit.
BUG=chromium:936567
TEST=cargo test -p resources && cargo build
Change-Id: I6d14368490c0d3c4018858f541e4ae5390995878
Reviewed-on: https://chromium-review.googlesource.com/1540398
Commit-Ready: Daniel Prilik <prilik@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Only allocate using minigbm if scanout bind is request (which can
indicate that the buffer is to be shared until a proper virgl bind flag
for shared is available), but if that fails because the format is not
supported for scanout, retry the minigbm allocation with the scanout
flag.
BUG=chromium:945033
TEST=None
Change-Id: Ib99bf01c8b9c2a98b1c0d1a8592d5f7c6e1aa859
Reviewed-on: https://chromium-review.googlesource.com/1569025
Commit-Ready: David Riley <davidriley@chromium.org>
Tested-by: David Riley <davidriley@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
We have:
unsafe trait AlignedNew: Sized + DataInit {...}
unsafe trait DataInit: Copy + Send + Sync {...}
trait Copy: Clone {...}
trait Clone: Sized {...}
Since Sized is already indirectly a supertrait of DataInit, including it
again as a supertrait of AlignedNew has no effect. This CL removes the
redundant Sized bound.
TEST=cargo check
Change-Id: I8ee2a9ee8892c95e6b0dd4bac1b662cd97441984
Reviewed-on: https://chromium-review.googlesource.com/1568077
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>
Before the new borrow checker in the 2018 edition, we sometimes used to
have to manually insert curly braced blocks to limit the scope of
borrows. These are no longer needed.
Details in:
https://doc.rust-lang.org/edition-guide/rust-2018/ownership-and-lifetimes/non-lexical-lifetimes.html
TEST=cargo check --all-features
TEST=local kokoro
Change-Id: I59f9f98dcc03c8790c53e080a527ad9b68c8d6f3
Reviewed-on: https://chromium-review.googlesource.com/1568075
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>
This one was triggering in libcras; fixed in CL:1566799.
TEST=bin/clippy
Change-Id: Ibcb554b71df3add04840576f404f744a66dfc18d
Reviewed-on: https://chromium-review.googlesource.com/1566663
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>
Suppressing the lint locally because by the author's and reviewers'
judgement this was the clearest way to write this code. The lint is
still valuable for catching mistakes in copied and pasted code
elsewhere.
TEST=bin/clippy
Change-Id: I77477fce51571220fd6259072519b31764a15aeb
Reviewed-on: https://chromium-review.googlesource.com/1566737
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>
The script suppresses all currently failing lints. I broke this down
into lints that I believe are worth addressing and lints that I wouldn't
mind keeping suppressed indefinitely.
TEST=bin/clippy
Change-Id: I967f3292ce2f790907619e87fe9f5a23bfef4cf4
Reviewed-on: https://chromium-review.googlesource.com/1566652
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>
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>
Macros were previously imported through `#[macro_use] extern crate`,
which is basically a glob import of all macros from the crate. As of
2018 edition of Rust, `extern crate` is no longer required and macros
are imported individually like any other item from a dependency. This CL
fills in all the appropriate macro imports that will allow us to remove
our use of `extern crate` in a subsequent CL.
TEST=cargo check --all-features --tests
TEST=kokoro
Change-Id: If2ec08b06b743abf5f62677c6a9927c3d5d90a54
Reviewed-on: https://chromium-review.googlesource.com/1565546
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>
The derive(MsgOnSocket) macro used to expand to something like:
const __MSG_ON_SOCKET_IMPL_Typename: () = {
extern crate msg_socket as _msg_socket;
impl _msg_socket::MsgOnSocket for Typename {
...
}
};
This was helpful in 2015 edition code by allowing callers to invoke the
derive without also writing `use msg_socket` at the top of the file to
bring the crate into scope.
In 2018 edition, paths beginning with a crate name do not need to be
otherwise imported, so this derive can simply expand to:
impl msg_socket::MsgOnSocket for Typename {
...
}
TEST=cargo test msg_socket
TEST=cargo test msg_on_socket_derive
Change-Id: I61b672b64404523f601de1d538ebe554985a0905
Reviewed-on: https://chromium-review.googlesource.com/1565545
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>
I find that imports get disorienting when they refer to super::super or
beyond and are better written as relative to the crate root.
TEST=cargo check --all-features --tests
Change-Id: I96dfd09a2784046669ae57a05f83582203a9c29d
Reviewed-on: https://chromium-review.googlesource.com/1565727
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: Daniel Verkamp <dverkamp@chromium.org>
The gpu_buffer, gpu_display, and gpu_renderer refer to crates outside of
the devices crate. Typically importing from other crates is written as:
use name_of_crate::path::to::ThingToImport;
TEST=cargo check --features gpu
Change-Id: Ic7b1a3fa6b4a06fca7f3e9ed09cbd2a9982279cc
Reviewed-on: https://chromium-review.googlesource.com/1565726
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: Daniel Verkamp <dverkamp@chromium.org>
The devices crate imports things from usb_util which is a separate
crate. Importing from a crate normally looks like:
use name_of_crate::path::to::ThingToImport;
In the case it would be e.g.:
use usb_util::hotplug::UsbHotplugHandler;
Importing these things through crate::usb::usb_util is unnecessary.
TEST=cargo check
Change-Id: I70554639a71b2423c1e13a30361d5f9d92e9d9a9
Reviewed-on: https://chromium-review.googlesource.com/1565725
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: Jingkui Wang <jkwang@google.com>
The syslog and ioctl macros in sys_util were originally written to be
imported through `#[macro_use] extern crate sys_util` which is
essentially a glob import of all macros from the crate.
In 2018 edition, extern crate is deprecated and macros are imported the
same as any other item. As these sys_util macros are currently written,
importing an individual macro requires the caller to also import any
other sys_util macros that the invocation internally expands to.
Example:
use sys_util::{error, log};
fn main() {
error!("...");
}
This CL adjusts all sys_util macros to invoke helper macros through a
`$crate::` prefix so that the caller is not required to have the helper
macros in scope themselves.
use sys_util::error;
fn main() {
error!("...");
}
TEST=kokoro
Change-Id: I2d9f16dca8e7a4a4c0e63d9f10ead9f7413d9c3c
Reviewed-on: https://chromium-review.googlesource.com/1565544
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: Daniel Verkamp <dverkamp@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: I964a198b54dfa7b98fa2f49a404fda3d09c0f44f
Reviewed-on: https://chromium-review.googlesource.com/1519693
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>
To avoid wasting time re-sorting these things (CL:1492612).
https://docs.rs/remain
Disclaimer: I wrote the macro.
This CL adds #[sorted] attributes to those Error enums that seemed to
have made some effort to be in sorted order.
TEST=cargo check
TEST=cargo check --all-features
TEST=cargo check --target aarch64-unknown-linux-gnu
TEST=emerge-nami crosvm
TEST=local kokoro
CQ-DEPEND=CL:1524247
Change-Id: I89685ced05e2f149fa189ca509bc14c70aebb531
Reviewed-on: https://chromium-review.googlesource.com/1515998
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>
There is a hard-limit to the number of MemoryMaps that can be added to a
KVM VM, a arch-dependent number defined as KVM_USER_MEM_SLOTS. e.g: on
x86 this is 509 (512 - 3 internal slots).
For most purposes, this isn't too much of an issue, but there are some
cases where one might want to share a lot of mmaps with a Guest. e.g:
virtio-fs uses a large cache region for mapping in slices of file fds
directly into guest memory. If one tries to add a new KVM memory region
for each mmap, the number of available slots is quickly exhausted.
MemoryMappingArena is a way to work around this limitation by allocating
a single KVM memory region for a large slice of memory, and then using
mmap with MAP_FIXED to override slices of this "arena" hostside, thereby
achieving the same effect without quickly exhausting the number of KVM
memory region slots.
BUG=chromium:936567
TEST=cargo test -p sys_util
Change-Id: I89cc3b22cdba6756b2d76689176d7147cf238f07
Reviewed-on: https://chromium-review.googlesource.com/1546600
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
This change implements service_irq, end_of_interrupt, and just enough to
add some basic tests for those.
Still TODO: Interrupt routing (and tests for that) and tests that
require additional functionality.
BUG=chromium:908689
TEST=Unit tests in file. Integration testing is blocked on rest of split-irqchip being implemented.
Change-Id: Ia8418f9a8bec92b53d99cdafb92f05f82eafa2b1
Reviewed-on: https://chromium-review.googlesource.com/1558935
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Miriam Zimmerman <mutexlox@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Tolnay <dtolnay@chromium.org>
This de-duplicates the two separate build.rs files dealing with proto
compilation. The trunks interface.proto will be exposed under
protos::trunks and the plugin proto will be exposed under protos::plugin.
BUG=none
TEST=cargo check
TEST=cargo check --features tpm
TEST=cargo check --features plugin
TEST=cargo check --features tpm,plugin
TEST=FEATURES=test emerge-nami crosvm
TEST=FEATURES=test USE=crosvm-tpm emerge-nami crosvm
TEST=FEATURES=test USE=crosvm-plugin emerge-nami crosvm
TEST=FEATURES=test USE='crosvm-tpm crosvm-plugin' emerge-nami crosvm
TEST=local kokoro
CQ-DEPEND=CL:1553971
Change-Id: I203b654a38e9d671a508156ae06dfb6f70047c4f
Reviewed-on: https://chromium-review.googlesource.com/1556417
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: Daniel Verkamp <dverkamp@chromium.org>
This matches the version already used by crostini_client.
The newer protobuf version depends on the tempfile crate rather than
tempdir, the latter being now deprecated. So I replaced our immitation
tempdir crate with one that matches the API of tempfile instead. As a
reminder, we use this crate as a patch to avoid pulling in all of the
rand crate and its many dependencies.
TEST=cargo check --features plugin
CQ-DEPEND=CL:1553971
Change-Id: I28eed3ceadb1013f015400b4c582aaf8dc89eee1
Reviewed-on: https://chromium-review.googlesource.com/1562924
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: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>