Commit graph

96 commits

Author SHA1 Message Date
Daniel Verkamp
1457967c08 net_util: clean up transmutes in create_sockaddr()
Rewrite create_sockaddr() using only safe type conversions instead of
the unsafe mem::transmute(), and add helper functions to do the sockaddr
to sockaddr_in (and vice versa) conversion safely.

BUG=b:365852007

Change-Id: I79690ebd1d10056800d46e8da1641ad44cb04b62
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5760286
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-11-05 00:09:04 +00:00
Daniel Verkamp
b222eb3351 net_util: add test for create_sockaddr()
Prepare for refactoring the create_sockaddr() function by adding a test
for the existing version.

BUG=b:365852007
TEST=cargo test -p net_util sockaddr

Change-Id: Ibe2d910df93f46702ce96615220a7e8e60cc6dc9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5760285
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-09-24 19:23:05 +00:00
Daniel Verkamp
b06d296a1b base: define ioctls as consts rather than functions
For ioctl numbers that do not require any parameters, make ioctl_io_nr
and related macros generate a constant rather than a function with no
parameters. This makes the code that uses these constants more idiomatic
and also allows using the constants in match statements (see an example
in virtio/fs/passthrough.rs).

BUG=None
TEST=tools/dev_container tools/presubmit

Change-Id: Id52817528d770c5dbbe2ce7928c9f31a15c83d83
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5648647
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2024-06-25 19:17:21 +00:00
Daniel Verkamp
52b8e42869 Cargo.toml: avoid "*" versions for external crates
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>
2024-05-22 01:01:42 +00:00
A. Cody Schuffelen
706b28b357 base: Separate TimerTrait::reset into 2 functions
See prior comment thread:

https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5454793/6..9//COMMIT_MSG#b12

`TimerTrait::reset` offers a very similar API to the `timerfd_settime`
system call, but in practice is almost used to set either a one-shot
timer, or a repeating timer with an initial timeout the same as the
repeating timeout.

`kqueue`'s timer functionality only supports the cases that are actually
used in practice. This change aligns the API with the way it is used,
and makes the distinction between the behavior of the arguments more
obvious.

Test: tools/presubmit
Test: cargo test -p base timer -- --ignored
Bug: 335486579
Change-Id: I1873ab9cccaf7a4b988431839964b1c253f76a34
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5463100
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-04-18 09:23:31 +00:00
Kaiyi Li
c28067d1d9 Reformat comments
Test: presubmit
Change-Id: I39c261d9985989873b698213c5d8b653fc13757b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5299850
Auto-Submit: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-02-15 23:30:13 +00:00
Daniel Verkamp
e9e933ff6f windows: resolve clippy::unnecessary_cast warnings
Change-Id: I07a6c2b2a737721baa202bd41acdc6f3aff4d7bc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5241879
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2024-01-29 19:42:29 +00:00
Vikram Auradkar
2768f223ee clippy: enforce safety block comments
BUG=b:316174930
TEST=none

Change-Id: I5c7811b2c548155aa003e4b71a54bbc16e2f2588
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5120567
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-12-14 18:21:54 +00:00
Vikram Auradkar
96b82c0294 clippy: enforce safety doc comment
BUG=b:316168567
TEST=none

Change-Id: I4e0a74e509ed4ef672fb9f334654a50aa5e257f1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5118513
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2023-12-14 17:46:29 +00:00
Daniel Verkamp
b0406736ed net_util, devices: refactor platform-specific net code
The validate_and_configure_tap() and virtio_features_to_tap_offload()
functions already effectively did nothing on Windows, since the
implementations of these for Slirp were not provided. These functions
are moved to sys so the Linux-specific TAP interfaces are no longer
needed in TapTCommon.

The get_ifreq() function is only called internally inside the
implementation of the Linux Tap struct; it does not need to be part of
the TapT trait at all.

The MacAddress <-> sockaddr interop is only needed on Linux, and the
conversion can be moved into the get_mac_address and set_mac_address
implementations for Linux.

With these changes, net_sys is used only on Linux, so it can be
conditionally compiled and not included in non-Linux builds at all.

BUG=None
TEST=tools/dev_container tools/presubmit

Change-Id: I3419a3bdb1470c4d72588fe19e43fabcdfe4e451
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5046598
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-27 19:23:56 +00:00
A. Cody Schuffelen
4748c54b95 Rename "unix" to "linux" in code and docs
$ for DIR in $(find . -name "unix"); do mv $DIR $(echo $DIR | sed "s/unix/linux/"); done
$ for FILE in $(find . -name "unix.rs"); do mv $FILE $(echo $FILE | sed "s/unix/linux/"); done
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -E -i "s/mod unix/mod linux/g" {}
$ find . -type f -not -path '*/\.git/*' -not -path '*/third_party/perfetto/*' | xargs -I {} sed -E -i "s/([^o][^s])::unix/\1::linux/g" {}
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -E -i "s/use unix::/use linux::/g" {}
$ find . -type f -not -path '*/\.git/*' -not -path '*/third_party/perfetto/*' | xargs -I {} sed -E -i "s/sys::unix/sys::linux/g" {}
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -E -i "s/use unix as platform/use linux as platform/g" {}

Test: ./tools/dev_container ./tools/presubmit
Bug: b/298269162
Change-Id: I2c8acb14d77a5588dab4eae124f4a9afbb9025f5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4909060
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-10-11 01:15:07 +00:00
A. Cody Schuffelen
97dff044f8 Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))]
Updates are made to source and documentation.

This more accurately represents the currently supported platforms of
Android/Linux and Windows, without unexpectedly including other
unix-like operating systems.

Command to reproduce:
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -i 's/cfg(unix)/cfg(any(target_os = "android", target_os = "linux"))/g' {}
$ cargo fmt

md files manually updated to fix line lengths.

Renaming `unix` modules to `linux` will be done in a later CL.

Test: ./tools/dev_container ./tools/presubmit
Bug: b/298269162
Change-Id: I42c1bf0abf80b9a0df25551613910293217c7295
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4909059
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-10-11 00:43:29 +00:00
Zihan Chen
cbba480ebe crosvm: Uprev zerocopy to 0.7.x
zerocopy 0.7.x has finally released as a stable version, uprev it
to allow some remaining structs to be derivable.

TEST=CQ

BUG=b:300969352
FIXED=b:300969352

Change-Id: I90f0dfb09494f875fef1cd11bfcbd48030846092
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4878761
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-10-10 17:34:32 +00:00
Daniel Verkamp
03dd1feab7 Cargo.toml: depend on zerocopy 0.6 explicitly
Previously all of the zerocopy imports just used "*", but there are
API changes in zerocopy 0.7, so ensure we get a compatible version by
depending on 0.6 everywhere.

This is a no-op since Cargo.lock already specifies a 0.6.x version, but
it will prevent accidentally upgrading to 0.7.x without updating to the
new API.

BUG=b:301283548
TEST=cargo build

Change-Id: Ifd702d982a09b5083dddd666dc6f3052cba22214
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4878502
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-09-20 21:28:58 +00:00
Idan Raiter
dde29439a5 net: Make slirp capture optional even if feature is on
Allows to make a prod build capable of capturing if the argument is
passed. But, behaves the same as before if the CLI is not passed.

BUG=b:294419893
TEST=downstream emulator

Change-Id: Iab1dddd30537c6ea61e9d32b240fabdfddd13e22
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4752604
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Idan Raiter <idanr@google.com>
2023-08-14 23:24:19 +00:00
Idan Raiter
09193203cd net: Fix compile error for slirp debugging
Seems we have some outdated code, probably after refactors as the
feature isn't compiled.

- Fixed u32 / usize casting
- argh_helpers::pad_description_for_argh wants the description lowercase

BUG=b:294419893
TEST=downstream run emulator

Change-Id: I5fdf3c5deae59de3c65a32456c35112b60526252
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4748853
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-08-14 23:03:39 +00:00
Daniel Verkamp
ce5a78e83b clippy fixes for Rust 1.70 and 1.71
Change-Id: If86c6cd531b854293a93208de5254664f5ee6bec
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4637612
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-07-13 20:29:05 +00:00
David Stevens
5b031ce8b0 base: Introduce TimerTrait
Introduce a TimerTrait that is implemented by both Timer and FakeTimer.
This trait can be used to write testable code without needing to
condition use statements on cfg(test).

BUG=None
TEST=CQ

Change-Id: I874ffe19fafe73e5c17fd5bb689e5b571e9f5b12
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4664188
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2023-07-05 01:12:35 +00:00
Richard Zhang
84ab00303e e2e_tests: snapshot vhost user tests
This test will spin up block and net vhost user device processes. This
test will be used as a smoke test and won't run during presubmits

Also refactor functions that can be shared into the fixture crate.

BUG=b:281115884
TEST=ran test. Also verified messages get sent to vhost user devices

Change-Id: Ic7e78a8ed71290fd3c42f9e15bf59a238623c49e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4519650
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
2023-05-15 21:11:42 +00:00
Dennis Kempin
01da29a398 net_util/win_audio: Do not use cfg conditional compilation in build.rs
The build.rs file will be compiled for the host platform and cfg()
flags will reflect those of the host platform and not of the build
target.
Use CARGO_CFG_ environment variables instead.

BUG=b:240593511
TEST=CQ

Change-Id: Ib8b6c8e8bfb44ad83212bb2aa40a17a4e16a4adf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4518569
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2023-05-09 20:27:26 +00:00
Noah Gold
7e22d900e0 base: fix unsafe overlapped read/write marked safe.
The overlapped wrappers on PipeConnection are unsafe, but they were
marked as safe. There are no actual unsafe production uses of them
because the conventions for overlapped IO generally make that hard to
do. That being said, these wrappers MUST be marked unsafe. This CL does
so and updates the callers with safety statements.

BUG=b:272812234
TEST=presubmit

Change-Id: I0def7056431d5b3b70eb4ce7c6ac8b44aef0a4cc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4330490
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
2023-03-14 18:42:38 +00:00
Zihan Chen
7cfc97d736 virtio_sys: Update bindgen to derive zerocopy
With uprev-ed bindgen, we can now customize derive directly.

TEST=CQ

BUG=b:204409584

Change-Id: Iba96cdb8329e9254249b247af55e11974620087c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4234067
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-02-09 22:59:10 +00:00
Zihan Chen
28ce4e5423 crosvm: Uprev rust toolchain and dev container
- Rust toolchain is updated to 1.65.0
- Catapult dashboard upload tool is added to dev_container
- Bindgen is updated to latest version to support custom derive
- Derive Eq when PartialEq is derived as required by new Clippy

TEST=CQ, bindgen-all-the-things

FIXED=b:260784028
BUG=b:257303497

Change-Id: I2034cd09e0aed84d4e9b30f2e85d84d94a442ea4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4228427
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-02-08 20:26:30 +00:00
Daniel Verkamp
5c1f06dc81 Fix new Rust 1.65 clippy warnings
A few more needless_borrow and needless_return warnings slipped in since
the last round of Rust 1.65 clippy fixes.

BUG=b:260784028
TEST=tools/clippy # with Rust 1.65

Change-Id: Iefceab6f1ec1c460e92b49f9cd21cfb79569f04a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4133516
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-01-05 23:08:09 +00:00
Daniel Verkamp
ac0fc378a3 Fix remaining Chrome/Chromium OS instances
These should be written as ChromeOS and ChromiumOS (without the space)
to match the updated branding. The copyright headers were already
migrated to the new style (https://crrev.com/c/3894243), but there were
some more instances left over.

BUG=None
TEST=tools/cargo-doc

Change-Id: I8c76aea2eb33b2e370ab71ee9b5cc0a4cfd00585
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4129934
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-01-03 22:14:30 +00:00
Dennis Kempin
b803e3cdcf net_util: Execute tap tests via sudo
These tests require root privileges to run. Check if we can do
a passwordless sudo and run the test process as a child process
with sudo.

This will work in CI or dev_container. For developer workflows,
the test_runner will already ask for sudo credentials before
running tests.

BUG=b:261600801
TEST=Fails: cargo test -p net_util
Passes: sudo true && cargo test -p net_util

Change-Id: I7c18057f7cfb91d5d389f9d9d1bb2d886d7f0149
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4086904
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-12-07 19:22:35 +00:00
Daniel Verkamp
10990c89af Rust 1.65: Fix clippy derive_partial_eq_without_eq lints
BUG=b:260784028
TEST=tools/clippy

Change-Id: Ib2b595385ed04b9480b22549334ce798d980d347
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4064717
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-12-01 01:32:30 +00:00
Daniel Verkamp
dfe9869d6c Rust 1.65: Fix clippy borrow_deref_ref, needless_borrow, and explicit_auto_deref lints
BUG=b:260784028
TEST=tools/clippy

Change-Id: I85cd5e096bc7b977fe1d9b231c08338b65e71780
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4064714
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-11-30 19:33:31 +00:00
Dennis Kempin
b157bda3ee tools/run_tests: Run some tests as root
Testing tap functionality requires root privileges. The crosvmdev
user of our dev_container is set up for passwordless sudo, so we can
seamlessly execute these tests via sudo.

For running on the developer workstation directly, this will prompt
for a password, which is disruptive to workflows. The --no-root
option can be used to prevent this and skip the tests in question.

BUG=None
TEST=tools/run_tests [--no-root]

Change-Id: I731887837affceb76152466f0006c4ee51a19234
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4063237
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-11-29 19:40:36 +00:00
Clarissa Garvey
e2554f1532 LSC: safe removal of needless_returns
Currently, we ignore clippy::needless_return, with many violations in
the code base. This CL fixes trivial, safe-to-fix violations of
needless_return. These were found by removing the needless_return
suppression in .cargo/config.toml and then fixing needless returns.

These are not all needless returns in the code base; it is only the
trivial fixes. This CL is a part of a chain of CLs to fix the
needless_returns in the code base.

BUG=chromium:908640, b:157245930
TEST=cargo clippy + cargo build

Change-Id: I6f8f3a0bed25d774fba7ae4b6e4c021af439ec22
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4014832
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Clarissa Garvey <clarissagarvey@chromium.org>
2022-11-09 18:27:14 +00:00
Dennis Kempin
9d24750e7d net_util: Extract integration_test
The tests require root privileges and have been silently
failing in CI because of that.

We will need a mechanism to run tests as root to enable these.
See b/256221093

BUG=b:244623459
TEST=presubmit

Change-Id: If812c219f44221275eabb2892891fd05b432d2fb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3990012
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-11-03 23:29:15 +00:00
Peter Oskolkov
84edec5323 tap: ensure the tap file is O_NONBLOCK
CrosVM must ensure that the tap file it uses is O_NONBLOCK, otherwise
the networking is very slow. Currently CrosVM uses O_NONBLOCK when
opening the tap file directly in create_tap_with_ifreq, and it must
ensure the same behavior if the tap file is created from a raw
descriptor.

BUG=b:257304931

Change-Id: I32ce42085ba312993dce32c457a8e5376b94c46b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4003798
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Peter Oskolkov <posk@google.com>
2022-11-03 22:45:30 +00:00
Daniel Verkamp
11322f007d tree-wide: use LFS variants of libc functions
Use the off64_t versions of libc file functions.

There is no Rust libc crate equivalent of the C _FILE_OFFSET_BITS and
related defines, so we have to use the Linux-specific *64 variants
explicitly.

This extends the size of file offsets to 64 bits instead of 32 on
platforms with 32-bit userspace.

(It also fixes the recently introduced check for non-LFS functions in
ChromeOS - see b/201531268 for details.)

BUG=b:201531268
TEST=emerge-kevin crosvm
TEST=start Crostini on kevin

Change-Id: Ife42917c8896d4fa1ccd78051c2a0b7dd565b2b3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3979975
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-11-02 22:20:18 +00:00
Dennis Kempin
f8eb24052e Reformat all files with nightly
Run tools/fmt --nightly

BUG=None
TEST=None

Change-Id: Iaccfc5fe141c512f4b508c699f89686a4552bf96
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3988327
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-10-31 21:33:33 +00:00
Frederick Mayle
3d4b4809ba base: cross platform Event API
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>
2022-10-19 20:17:42 +00:00
Koki Ryu
16da55f236 Add --net option to the crosvm run command
Currently, --tap-name, --tap-name, --host-ip...etc commands are all used
to create a vhost-user net device. This CL unifies the command line arguments.

BUG=b:246224081
TEST=run the following tests:
- `cargo test -p devices virtio::net::tests`
- `cargo test -p net_util`

Change-Id: Ie1342f23f0951e5a81e54547bf725c0d9be19f97
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3893869
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Koki Ryu <kokiryu@chromium.org>
2022-10-19 02:18:27 +00:00
Vikram Auradkar
c4a4dc9b23 net_util: Add windows slirp support
BUG=b:237011316
TEST=presubmit and tested in wine

Change-Id: I1b6160142b8161d4b09d3fd98dfacde354e238b4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3934818
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-10-11 15:25:38 +00:00
Daniel Verkamp
b60140b37e tree-wide: use "crosvm" capitalization everywhere
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>
2022-10-07 01:10:12 +00:00
Daniel Verkamp
7c6d8bec3f health-check: enforce blank line after copyright
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>
2022-09-13 22:24:35 +00:00
Dennis Kempin
1dab58a2cf Update all copyright headers to match new style
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>
2022-09-13 18:41:29 +00:00
Stanko Novakovic
c59c68751c Fallback INET6 socket for machines without INET support
Change-Id: Ic826b0c35b85aa638398e34889e630fa087e0429
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3880838
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-09-08 23:21:45 +00:00
Vikram Auradkar
5d264785c8 crosvm: resync with downstream after running clippy
BUG=b:243099012
TEST=presubmit

Change-Id: Ia910932344c58979c6735776797139e3a1ee9428
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3846056
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: Vikram Auradkar <auradkar@google.com>
2022-08-25 20:45:12 +00:00
Noah Gold
05737b5b42 devices & src: add startup info logs.
When debugging, we've repeatedly run into issues where we don't know how
far in the initialization process various devices or the main process
managed to get before it ran into trouble. As a first step, we're
introducing some informational logs at various critical points so we can
tell the difference between a true startup failure and other failure
modes.

BUG=b:242103548
TEST=tested downstream

Change-Id: Ia76c7de3c98ea76943853588f2b9c0e89de056d6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3833643
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Noah Gold <nkgold@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-08-19 22:24:46 +00:00
Daniel Verkamp
600ad38ff8 Remove redundant {self} imports
- 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>
2022-08-01 21:27:54 +00:00
Vikram Auradkar
925ba7a1fb crosvm: Fix clippy related warnings
Ran clippy with features that are enabled downstream. Those features
will be enabled upstream in later cls when crosvm starts building.

BUG=b:213146388
TEST=presubmit

Change-Id: I67cb74127a349b572e573c350d69d1611533d961
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3793690
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: Vikram Auradkar <auradkar@google.com>
2022-07-29 17:49:31 +00:00
Dennis Kempin
4fea399df9 Reformat imports
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>
2022-07-28 00:15:50 +00:00
Vikram Auradkar
2314c4701b crosvm: Fix drift
BUG=b:213146388
TEST=presubmit

Change-Id: I59e6b7ad7aff8d4659c62e310a7955146a10d743
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3777405
Tested-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-07-21 23:13:18 +00:00
Daniel Verkamp
9315d0a741 Use 4-space indent in cfg_if treewide
A few of the cfg_if blocks got misaligned somewhere along the line, and
cargo fmt won't rewrite code inside macro invocations, so we have to fix
them manually.

BUG=None
TEST=stare at whitespace

Change-Id: I1ccf7aff7c7827a2687ab5fa50cc192c79d6400b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3691968
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-07 17:36:51 +00:00
Daniel Verkamp
d4505a7f1c base: replace PollToken with EventToken tree-wide
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>
2022-06-02 22:30:38 +00:00
Noah Gold
1977979fbb net_util: upstream Windows support
Adds the libslirp interface code, as well as the Windows pseudo-tap
device.

BUG=b:213151463

TEST=bots (unix + windows)

Change-Id: I975b27a76c82e25037d4061587fec0c31222a159
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3598234
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-06-02 03:00:36 +00:00