Commit graph

39 commits

Author SHA1 Message Date
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
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
Daniel Verkamp
41f57f8f89 Apply nightly rustfmt import style
As usual, some unsorted and grouped imports have appeared.

Change-Id: I79b51e4c52cee38f5b8c238e46dfe3193c753554
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4847980
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-09-06 22:13:26 +00:00
Daniel Verkamp
4be56406b6 Remove target_arch = "x86" checks
crosvm has never actually supported running on a 32-bit x86 host, only
x86-64. Remove the cfg(target_arch = "x86") checks throughout the tree
to make this clear (and to simplify the code).

This doesn't affect the code running inside the guest, which can still
be a 32-bit x86 operating system if launched via --bios, for example.

BUG=None
TEST=tools/dev_container tools/presubmit

Change-Id: Ifd888db54c58ec8a5fcf840871ef564771d9066b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4794387
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-08-18 23:36:47 +00:00
maciek swiech
32f8711cf7 Reland "Reland "balloon: rename WSS to WS""
This reverts commit 2aea504a65.

Reason for revert: missed run-time flag migration, fixed this time around and tested more thoroughly

BUG=b/288432539
TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
TEST=patch in to chromeos; emerge-volteer crosvm && emerge-volteer vm_host_tools
TEST=cros deploy && restart vm_concierge on DUT
TEST=cros deploy && vmc start borealis && (borealis) DISPLAY=:0 steam

Original change's description:
> Revert "Reland "balloon: rename WSS to WS""
>
> This reverts commit cf1c3cd755.
>
> Reason for revert: The command line change will break existing
> usage of the CLI flag
>
> Original change's description:
> > Reland "balloon: rename WSS to WS"
> >
> > This reverts commit 94dc10b57c.
> >
> > Reason for revert: relanding changes with fully implemented types
> >
> > BUG=b/288432539
> > TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
> > TEST=patch in to chromeos; emerge-volteer crosvm && emerge-volteer vm_host_tools
> >
> > Original change's description:
> > > Revert "balloon: rename WSS to WS"
> > >
> > > This reverts commit 1eb1106537.
> > >
> > > Reason for revert: headers generated by cbindgen do not compile as expected downstream
> > >
> > > Original change's description:
> > > > balloon: rename WSS to WS
> > > >
> > > > as the working set feature approaches acceptance at the spec-level, we
> > > > are keeping up with nomenclature changes.
> > > >
> > > > BUG=b/288432539
> > > > TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
> > > >
> > > > Change-Id: I323a2c5402cb8008f8c912b0849e8e3501f9e1f3
> > > > Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4702340
> > > > Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> > > > Commit-Queue: maciek swiech <drmasquatch@google.com>
> > >
> > > BUG=b/288432539
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > >
> > > Change-Id: I46459b4afd428c67436a754b3e62a104a680c68f
> > > Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722468
> > > Commit-Queue: maciek swiech <drmasquatch@google.com>
> > > Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> >
> > BUG=b/288432539
> >
> > Change-Id: Ifb78acf2914b96306a2d1104e21eff6e67ed45df
> > Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722288
> > Commit-Queue: maciek swiech <drmasquatch@google.com>
> > Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
>
> BUG=b/288432539
>
> Change-Id: I3bcb26699fd1d15eab594143490f863941d3eceb
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4730438
> Commit-Queue: Dennis Kempin <denniskempin@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>

BUG=b/288432539

Change-Id: I657f648aec0fc4f4551cf3c109c5ecedcdddbcb2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4733877
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: maciek swiech <drmasquatch@google.com>
2023-08-01 20:26:39 +00:00
Dennis Kempin
2aea504a65 Revert "Reland "balloon: rename WSS to WS""
This reverts commit cf1c3cd755.

Reason for revert: The command line change will break existing
usage of the CLI flag

Original change's description:
> Reland "balloon: rename WSS to WS"
>
> This reverts commit 94dc10b57c.
>
> Reason for revert: relanding changes with fully implemented types
>
> BUG=b/288432539
> TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
> TEST=patch in to chromeos; emerge-volteer crosvm && emerge-volteer vm_host_tools
>
> Original change's description:
> > Revert "balloon: rename WSS to WS"
> >
> > This reverts commit 1eb1106537.
> >
> > Reason for revert: headers generated by cbindgen do not compile as expected downstream
> >
> > Original change's description:
> > > balloon: rename WSS to WS
> > >
> > > as the working set feature approaches acceptance at the spec-level, we
> > > are keeping up with nomenclature changes.
> > >
> > > BUG=b/288432539
> > > TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
> > >
> > > Change-Id: I323a2c5402cb8008f8c912b0849e8e3501f9e1f3
> > > Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4702340
> > > Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> > > Commit-Queue: maciek swiech <drmasquatch@google.com>
> >
> > BUG=b/288432539
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> >
> > Change-Id: I46459b4afd428c67436a754b3e62a104a680c68f
> > Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722468
> > Commit-Queue: maciek swiech <drmasquatch@google.com>
> > Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
>
> BUG=b/288432539
>
> Change-Id: Ifb78acf2914b96306a2d1104e21eff6e67ed45df
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722288
> Commit-Queue: maciek swiech <drmasquatch@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>

BUG=b/288432539

Change-Id: I3bcb26699fd1d15eab594143490f863941d3eceb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4730438
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-07-28 22:34:54 +00:00
maciek swiech
cf1c3cd755 Reland "balloon: rename WSS to WS"
This reverts commit 94dc10b57c.

Reason for revert: relanding changes with fully implemented types

BUG=b/288432539
TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
TEST=patch in to chromeos; emerge-volteer crosvm && emerge-volteer vm_host_tools

Original change's description:
> Revert "balloon: rename WSS to WS"
>
> This reverts commit 1eb1106537.
>
> Reason for revert: headers generated by cbindgen do not compile as expected downstream
>
> Original change's description:
> > balloon: rename WSS to WS
> >
> > as the working set feature approaches acceptance at the spec-level, we
> > are keeping up with nomenclature changes.
> >
> > BUG=b/288432539
> > TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
> >
> > Change-Id: I323a2c5402cb8008f8c912b0849e8e3501f9e1f3
> > Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4702340
> > Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> > Commit-Queue: maciek swiech <drmasquatch@google.com>
>
> BUG=b/288432539
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
>
> Change-Id: I46459b4afd428c67436a754b3e62a104a680c68f
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722468
> Commit-Queue: maciek swiech <drmasquatch@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>

BUG=b/288432539

Change-Id: Ifb78acf2914b96306a2d1104e21eff6e67ed45df
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722288
Commit-Queue: maciek swiech <drmasquatch@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-07-26 21:48:44 +00:00
maciek swiech
94dc10b57c Revert "balloon: rename WSS to WS"
This reverts commit 1eb1106537.

Reason for revert: headers generated by cbindgen do not compile as expected downstream

Original change's description:
> balloon: rename WSS to WS
>
> as the working set feature approaches acceptance at the spec-level, we
> are keeping up with nomenclature changes.
>
> BUG=b/288432539
> TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events
>
> Change-Id: I323a2c5402cb8008f8c912b0849e8e3501f9e1f3
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4702340
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: maciek swiech <drmasquatch@google.com>

BUG=b/288432539
No-Presubmit: true
No-Tree-Checks: true
No-Try: true

Change-Id: I46459b4afd428c67436a754b3e62a104a680c68f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4722468
Commit-Queue: maciek swiech <drmasquatch@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-07-26 19:55:38 +00:00
maciek swiech
1eb1106537 balloon: rename WSS to WS
as the working set feature approaches acceptance at the spec-level, we
are keeping up with nomenclature changes.

BUG=b/288432539
TEST=cargo build, cargo build --no-default-features, cargo build --features registered_events

Change-Id: I323a2c5402cb8008f8c912b0849e8e3501f9e1f3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4702340
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: maciek swiech <drmasquatch@google.com>
2023-07-25 21:27:03 +00:00
maciek swiech
fac9000051 balloon: use protos for registered events
since the RegisteredEvent model is effectively an external API, switch
to using protobuf as a more formal/stable means of communicating
messages. also introduces exporting the registered_events.proto file as
part of crosvm_control build, alongside the currently existing header
file.

this patch also introduces feature-gating for registered_events and
protos so as not to bring in too many third party dependencies for a
base build.

BUG=b/278117550
TEST=run bzImage locally
TEST=sidecar program available at https://x20.corp.google.com/users/dr/drmasquatch/socket-pinger-proto

Change-Id: I5d91d87f7807effc125352caf5c75eee2593f70d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4521604
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: maciek swiech <drmasquatch@google.com>
2023-05-22 19:28:45 +00:00
Daniel Verkamp
a360baa819 Cargo.toml: upgrade protobuf 2.x -> 3.x
system_api bindings have been regenerated with protobuf 3.2; this should
be okay to land before the full ChromeOS system_api migration, since
crosvm always uses its own copy of the bindings rather than the ones
provided by the dev-rust/system_api package.

The protoc-rust crate is replaced with protobuf_codegen in 3.x.

BUG=b:277243607
BUG=b:279834784
TEST=tools/dev_container tools/presubmit

Change-Id: I6aad45ded2639d7506a7238800584bebab196455
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4405309
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-04-28 19:32:01 +00:00
Dennis Kempin
acc162000f Add conditional compilation for unix-only crates
Instead of configuring which crates to --exclude in
test_config.py, we can use conditional compilation to
exclude code that is not supported on windows.

This allows more fine-grained control and also allows
us to use plain cargo for building without complicated
configuration and exclusions.

BUG=b:265829867
TEST=cargo test --lib --bins --workspace
	--target=x86_64-pc-windows-gnu
	--features=all-mingw64

Change-Id: I8422c3f08053bc27d9896b220876a56bd25543d6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4165868
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-01-19 21:21:59 +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
Noah Gold
2131a614e5 protos: migrate to new build tool & cleanup.
As part of migrating to proto_build_tools, we've cleaned up some old
code that was unused:
* All of the ExternalProto tooling that was unused.
* The vsock proto doesn't exist.

BUG=b:256951877
TEST=builds

Change-Id: I647395b4900d487179139050ab6750a464b528e7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4021592
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-11-12 01:02:36 +00:00
Daniel Verkamp
1ea13674fa protos: delete unused test helper function
This was previously only referenced by the trunks test code, which was
removed in commit 62770b484a ("Remove trunks proto from crosvm
build").

BUG=None
TEST=tools/presubmit

Change-Id: I8883e805037f0da3feb999d685d722cb182bf585
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4010558
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-11-07 22:12:32 +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
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
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
Daniel Verkamp
45b0920767 doc: add a top-level comment to all crates
This provides at least a minimal one-line description to show what each
crate is about.

BUG=None
TEST=tools/cargo-doc

Change-Id: I26732e8c29062e622d5be09bdc120a49d564b9fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630422
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-06 20:46:57 +00:00
Anton Romanov
bed40ad547 crosvm: migrate to Rust 2021 edition
BUG=none
TEST=cq

Change-Id: I0059c970879b78bfd40b6ce58b10debcf154b50f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3508322
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-03-09 01:16:03 +00:00
Vikram Auradkar
ae5118f5c7 Enable windows tests for a few crates
Run tests for sys_util_core, poll_token_derive and balloon_control on
windows.

Using dotfiles to disable/serialize test runs of a subset of crates does
not work well with third party crates as it forces us to commit the dot
file to the crate.

The patch modifies and uses the script that runs linux tests.
This patch also allows us to
- build/test child crate even if parent crate has disabled build/test.
- avoid building crosvm if it is not explicitly specified.

RIP short lived .windows_build_test_skip. You allowed us to run noop
kokoro tests.

Test: py .\tools\impl\test_runner.py --arch x86_64
Bug: b:215610772
Change-Id: Icc6d04ffd7c0c33d4f60aeac16fc7d23881c387d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3459809
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-02-18 03:18:58 +00:00
Vikram Auradkar
0108238474 Upstream windows build/test script
The patch also adds files to skip building and testing crates on
windows. When we run
```
tools/windows/build_test.py --skip_file_name .windows_build_test_skip
```

the build/test succeeds without actually doing anything as build/test
for all crates is skipped by creating '.windows_build_test_skip'.

Bug: 213170957
Test: Ran script on downstream repo
Change-Id: Iebd2cea463ee722be4feaed88229e1fb5e9fd6c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3417918
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-01-28 00:55:08 +00:00
Dennis Kempin
62770b484a Remove trunks proto from crosvm build
The feature was never finished (crbug.com/911799), but adds a
build-time dependency on the trunks proto in platform2.

BUG=b:193267897
TEST=cargo build with and without tpm feature

Change-Id: I7299ba0779bb04ebca6284cfd11873e99500c993
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3043491
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-31 03:01:21 +00:00
Domen Su
c25cb1441e crosvm: Rename trunks interface.proto
`trunks/interface.proto` was renamed to `trunks/trunks_interface.proto`.

Rename `interface.proto` in crosvm accordingly.

BUG=b:193096536
TEST=./build_packages --board=amd64-generic crosvm

Cq-Depend: chromium:3013439
Change-Id: I9c2d1d70e81e60a73daa26fded92746591210ae7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3016218
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Yi Chou <yich@google.com>
Reviewed-by: John L Chen <zuan@chromium.org>
Reviewed-by: Leo Lai <cylai@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Domen Su <domen@google.com>
2021-07-29 07:24:56 +00:00
Allen Webb
c6fa73d76f Fix clippy warnings and Cargo.lock
This fixes:
* version mismatches in Cargo.lock
* style issues
* implementations of Into that should be From
* deprecated protobuf APIs

It also adds RUST_BACKTRACE=1 to the kokoro tests.

BUG=None
TEST=./bin/preupload-clippy

Change-Id: I8e9157c903f2080a5fdcc4d3e4ed72fbad41c64f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3024427
Auto-Submit: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Allen Webb <allenwebb@google.com>
2021-07-15 03:33:17 +00:00
Daniel Verkamp
1972b6855a protos: add arch = x86 guards around CPUID helpers
The CPUID-related KVM structs are only available on x86; don't try to
compile the helper functions that use these structs on other platforms.

This is slightly nonsensical, since plugin is already only compiled on a
few specific x86 platforms, but it allows the unit tests to build on
other platforms (e.g. when using `cargo test --all-features`).

BUG=chromium:1112839
TEST=FEATURES=test emerge-kevin crosvm

Change-Id: I413ac757f27c987133bdb265f203f0d6eb3a0b21
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2347077
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-08-18 05:30:38 +00:00
Matt Delco
d2a862b41f crosvm: add handling for hyperv exits
When features for Hyper-V are enabled there's a another type of exit
that can be triggered.  This change attempts to add support for those
types of exits.

BUG=b:150151095
TEST=ran build_test

Change-Id: I3131a2c8d9c610576ac177dbfe82f78e8d5dbfb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2073254
Reviewed-by: Matt Delco <delco@chromium.org>
Tested-by: Matt Delco <delco@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Matt Delco <delco@chromium.org>
Auto-Submit: Matt Delco <delco@chromium.org>
2020-03-05 19:01:24 +00:00
Matt Delco
e73414db48 crosvm: add ability to enable caps on vcpu
This change primarily adds functionality to allow kvm features to be
enabled on a vcpu (most of the current infra only supporst the ioctl for
the vm fd).

BUG=b:144746965
TEST=ran 'build_test' and verified that the added tests passed.

Change-Id: I30c00b6f462377c21d477602ceba5853df953b37
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2055883
Tested-by: Matt Delco <delco@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Matt Delco <delco@chromium.org>
2020-02-20 02:12:03 +00:00
Matt Delco
c469580e6c crosvm: support kvm's hyper-v cpuid ioctl
Kvm can emulate the hyper-v paravirt interface.  Newer versions of kvm
can advertise the features they support via an ioctl() that reports the
cpuid leafs for this interface.  This change adds some support for the
ioctl() and plumbs it through the plugin interface so that plugins can
determine the level of support available in kvm.

BUG=b:144746965
TEST=Ran build_test on kernel that supports the ioctl.  Added temporary
code to print the cpuid leafs and verified that the output is as
expected.  Instrumented failure as expected from older kernels and
verified that results still passed.

Change-Id: I6cd7dade1793e4edb52b331d5b960685541f7ba3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2037919
Tested-by: Matt Delco <delco@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Matt Delco <delco@chromium.org>
2020-02-20 02:12:01 +00:00
Matt Delco
a52b2a6c81 crosvm: add plugin API for async writes
A plugin might care to be immediately notified when a write
is made to a port, but it doesn't care to have the VM stopped
while the plugin calls back to resume the VM.

Unfortunately this means that multiple messages can be queued up in the
pipe and read() together by the plugin API.  Protobuf's parsing function
doesn't report how many bytes it read, so I've resorted to having crosvm
prefix every message with a length and then have the plugin lib parse
this number.  Impact on performance has not been measured.

BUG=b:143294496
TEST=Local build and run of build_test.  Verified that new unit
test was executed, exercised the case where multiple msgs are
received together, and completed successfully.

Change-Id: If6ef463e7b4d2e688e649f832a764fa644bf2d36
Signed-off-by: Matt Delco <delco@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1896376
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2019-11-06 23:01:15 +00:00
Matt Delco
ac0b9b71d1 crosvm: pre-cache answers to plugin get calls
This change tries to improve the performance of a plugin-based VM
by adding a hint API that allows crosvm to proactively push cpu
state to the plugin when certain ports for hypercalls are accessed
by the VM.

BUG=None
TEST=build and run. See performance increase significantly.

Change-Id: I71af24ebc034095ffea42eedb9ffda0afc719cd6
Signed-off-by: Matt Delco <delco@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1873005
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-10-31 06:18:09 +00:00
Matt Delco
893c1200dd crosvm: defer IPC on set calls
If a plugin makes a set call on vcpu registers then we
can improve performance by deferring the IPC and instead
conbining the request with the next resume call.

BUG=None
TEST=build and run.

Change-Id: I4eb54a3f6eb30c98971aa2f099e3ea5899767eed
Signed-off-by: Matt Delco <delco@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1825262
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-10-23 06:22:00 +00:00
Matt Delco
3156937410 crosvm: delete resume response from protobuf
The resume response was deleted in a earlier change.  This change
removes the message type from the proto file and adjusts crosvm
so it can still build after this removal.

BUG=None
TEST=build and run.

Change-Id: I27d36a51b1e7eb59258d23da38199b86d7cb3659
Signed-off-by: Matt Delco <delco@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1825260
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2019-10-23 06:21:58 +00:00
Cody Schuffelen
f9b035d50c Support composite disks.
This adds a new disk file type next to raw files and qcow images that
represent an indirection to further raw disk files. The disk file
itself is a proto file with references to file paths for other disks to
open and their virtual offsets and lengths.

The intention is to make it easy to assemble a single virtual hard disk
out of several distinct partition files. In the particular case of
Cuttlefish running Android in a VM, this is relevant as the Android
build system distributes partitions as separate raw files. While the
simple solution is to pass each partition as a separate raw disk, some
functionality (like the bootloader) assumes there is a partition table
with multiple distinct partitions on a single disk.

Implementing composite disk support in the VMM bridges this gap through
supporting the general-purpose case of a disk built out of multiple
component files.

If desired, this can be extended to support qcow files to support
unusual configurations like a mixed qcow/raw disk.

Enabled with the "composite-disk" feature.

Bug: b/133432409
Change-Id: I2b0c47d92fab13b5dc0ca5a960c7cfd2b7145b87
Signed-off-by: Cody Schuffelen <schuffelen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1667767
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-10-03 00:59:14 +00:00
Stephen Barber
d6945a09b8 crosvm: add license blurb to all files
A few files were missing license blurbs at the top, so update them all
to include them.

BUG=none
TEST=none

Change-Id: Ida101be2e5c255b8cffeb15f5b93f63bfd1b130b
Reviewed-on: https://chromium-review.googlesource.com/1577900
Commit-Ready: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2019-04-24 15:51:38 -07:00
Matt Delco
e3fdadb8e1 crosvm: use pipe instead of socket for vcpu communication
Pipes have better performance than sockets, so switch the vcpu
communication over to pipes.  The vm communication channels will
continue to use sockets since that communication isn't performance
critical (and those messages sometimes exchange file descriptors, and
that functionality requires sockets).

TEST=local compile and confirmed that my diagnostic plugin is still
happy. The time it takes to run my benchmark plugin has decreased by
20%.  This combined with my prior commit results in a net wall-clock
time reduction of 32%.
BUG=None

Change-Id: I44c198d62a3bbe3b539ff6ac79707d02488876e3
Signed-off-by: Matt Delco <delco@google.com>
Reviewed-on: https://chromium-review.googlesource.com/1572873
Commit-Ready: Matt Delco <delco@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-04-24 15:51:11 -07:00
David Tolnay
b1de6323ab clippy: Suppress warning from protoc_rust generated code
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>
2019-04-17 17:23:11 -07:00
David Tolnay
65928af6c9 protos: Merge plugin_proto crate under protos::plugin
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>
2019-04-12 14:49:57 -07:00
David Tolnay
1aca8b7269 protos: Compile protos for trunks daemon
The TPM device will need these protos to communicate TPM commands to the
Trunks daemon and receive TPM responses.

BUG=chromium:911799
TEST=cargo check
TEST=cargo check --features tpm
TEST=FEATURES=test emerge-nami crosvm
TEST=FEATURES=test USE=crosvm-tpm emerge-nami crosvm
TEST=local kokoro
CQ-DEPEND=CL:1553610
CQ-DEPEND=CL:1553971

Change-Id: I1a67a7b4a3714236b20a790068ca19129446f71c
Reviewed-on: https://chromium-review.googlesource.com/1554982
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>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2019-04-12 14:49:56 -07:00