Commit graph

159 commits

Author SHA1 Message Date
Dennis Kempin
0928f91f98 Refactoring: Copy common/io_uring to io_uring
This applies the script from https://crrev.com/c/3534501

BUG=b:22320646
TEST=presubmit

Change-Id: Ib0c5bdb55df2098930fb1c65e9bd59288c44f357
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3534502
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-03-21 19:52:56 +00:00
Dennis Kempin
55c6a3b5cd Refactoring: Move common/cros_async to cros_async
This runs the script added in https://crrev.com/c/3533607

BUG=b:22320646
TEST=presubmit

Change-Id: I2e7efdb35508d45281f046e64c24aa43e27f2000
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3533608
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-03-21 19:52:56 +00:00
Dmytro Maluka
74031b483f x86_64: acpi: support for assigning physical GPEs
Wire up GPE eventfd forwarding and crosvm's GPE emulation.

This patch allows to provide ACPIPMResource with the list of GPEs
which should work as direct physical (passthrough) GPEs rather than
purely emulated ones.

BUG=b:205072342
TEST=see CL:3492224

Change-Id: Idb8ef36299c793f56d73246d15ff89f495bb30ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3492223
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
2022-03-21 09:16:38 +00:00
Dmytro Maluka
121e33246b acpi: vGPE: support direct SCI interrupt passthrough
In order to allow handling physical GPE in the guest, implement
physical SCI interrupts forwarding from the host to the guest.

It uses an eventfd based mechanism similar to how we normaly do
forwarding of other level-triggered interrupts. The difference is that
SCI trigger events from kernel are not injected directly to irqchip.
In order to support injecting both physical and virtual SCI interrupts
(so that some GPEs can be handled as physical while other GPEs can be
emulated), SCI trigger event is intercepted by ACPIPMResource which
injects it to irqchip via another eventfd - the same eventfd which is
used for injecting virtual SCI interrupts.

Similarly, resample event for physical forwarded SCI is received
via the same eventfd as for virtual SCI, then forwarded back to kernel.

BUG=b:205072342
TEST=see CL:3492224

Change-Id: I480a3000d69305aabc777e193d3453c476d2dbbd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3492221
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dmytro Maluka <dmy@semihalf.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
2022-03-21 09:16:35 +00:00
Dennis Kempin
ef516189db Refactoring: Move common/base into base
Executes the script in https://crrev.com/c/3530502

BUG=b:223206469
TEST=presubmit

Change-Id: Ibeffdc8de0b2270f070e60bb2de8d9fdc78a2a6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3530503
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-03-17 00:01:27 +00:00
Daniel Verkamp
052f7df430 x86_64: remove special-case mappings for direct
Now that we can handle file-backed mappings that overlap with guest
memory, we can remove the workarounds for coreboot regions when
compiling with --features=direct.

BUG=b:188011323
TEST=cargo test -p x86_64 --features=direct
TEST=Boot volteer-manatee and brya-manatee

Change-Id: I9ac2a25e1896c5ec61bd302882d4c99d8b36b0dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3498210
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-14 19:57:21 +00:00
Anton Romanov
ee60fe491f crosvm: Change cargo resolver to 1 to fix issues with chromeos and b* builds
BUG=b:223855233,b:223821596
TEST=cq

Change-Id: I9cb84608478a215e6a6768fdc74d383f9334848a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3517908
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Oystein Eftevaag <oysteine@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-03-10 19:43:52 +00:00
Anton Romanov
90922be6d6 crosvm: Enable plugin feature in CI builds
BUG=none
TEST=cq

Change-Id: I201f5090c096912f61f2b461fc2f0be9621389a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3515213
Reviewed-by: Anton Romanov <romanton@google.com>
Auto-Submit: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-10 01:00:39 +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
Dennis Kempin
5f46e21c02 Remove rutabaga_gfx_ffi from workspace
The crate requires special compilation flags that conflict with the
workspace flags.

We may want to consider moving it to common/ so the test runner can
compile it in a separate workspace.

This brings us one step closer to be able to run
`cargo build --workspace` with no excludes.

BUG=b:206689789
TEST=./tools/presubmit

Change-Id: Ice747ced00f81db0a8e05ff2bc43d4d0e323e456
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3453050
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-11 15:58:56 +00:00
Alexandre Courbot
4da0e52ba5 Cargo.toml: add "chromeos" and "lto" build profiles
Add a "chromeos" profile that mimics the flags used when compiling for
Chrome OS. This is useful to determine how much the crosvm binary will
inflate due to a given CL.

Also add an "lto" profile enabling LTO on top of the "chromeos" profile,
so we can easily see how much space we save by enabling LTO.

BUG=b:218473401
BUG=b:218566754
TEST=cargo build --profile chromeos
TEST=cargo build --profile lto

Change-Id: I2fd743b6c980b847af1f3db593a55b683cbb8d57
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3450026
Reviewed-by: Anton Romanov <romanton@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-02-11 05:34:19 +00:00
Vikram Auradkar
323006cf82 Move os independent files under a new crate sys_util_core
sys_util_core won't have OS specific features so that sys_util and
win_sys_util can depend on it.

Test: Presubmit
Bug: b:213149154
Upstream-Crate: common/win_sys_util

Cq-Depend: chromium:3433709
Change-Id: I863f7a6bc7549944b4d114cca6d7be04c3093fc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3426380
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-02-08 20:59:24 +00:00
Junichi Uekawa
8764deb8dd crosvm: Minimal change for manatee memory mapping.
Do not map RAM to where the coreboot regions are.

Shift boot time GDT and IDT a bit to make way for coreboot region at
0..fff.

BUG=b:188011323
TEST=boot volteer-manatee
TEST=tast run rammus-arc-r arc.Boot.vm  # ARCVM still boots.
TEST=tast run rammus-arc-r crostini.Basic.bullseye_stable

volteer-manatee memory map:

after:

localhost ~ # dmesg | grep e820
[    0.000000] BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
[    0.000000] BIOS-e820: [mem 0x0000000000200000-0x00000000cfffffff] usable
[    0.000000] BIOS-e820: [mem 0x00000000f4000000-0x00000000f7ffffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000100000000-0x00000003f05fffff] usable

before:

localhost ~ # dmesg | grep e820
[    0.000000] BIOS-e820: [mem 0x0000000000001000-0x000000000009fbff] usable
[    0.000000] BIOS-e820: [mem 0x0000000000200000-0x000000005fffffff] usable
[    0.000000] BIOS-e820: [mem 0x00000000f4000000-0x00000000f7ffffff] reserved
[    0.000000] BIOS-e820: [mem 0x0000000100000000-0x0000000460600fff] usable

Change-Id: Ifa19988c444d79dc81eb77c59e5b5434abf883fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3405402
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-01-27 02:29:32 +00:00
Alexandre Courbot
580231bda0 Cargo: stop enabling the libvda feature by default
Libvda can only be successfully used and linked against on Chrome OS.
Making the video decoder and encoder depend on it makes it impossible to
use these features on non-Chrome OS platforms. Remove the libvda feature
by default since the Chrome OS builders have been updated to enable it
explicitly.

BUG=b:161774071
TEST="cargo build --feature "video-decoder,video-encoder" fails.
TEST="cargo build --feature "video-decoder,video-encoder,libvda"
     succeeds and embeds the libvda backend.

Cq-Depend: chromium:3023696
Change-Id: I54d31312e87e5d9a8e5c1a39955416bf892270d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026352
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-01-13 11:50:14 +00:00
Dennis Kempin
a5ad6aeb30 cros_asyncv2: Do not add crates.io patch
This patch will cause libcras to be built with the new v2 library,
which it has not been updated for yet.

BUG=None
TEST=None

Change-Id: I4353877aea1e0e611d4b1152733ab40aed2ec3b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3340227
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-12-15 00:40:15 +00:00
ameron Lutes
cde1b5416f crosvm: Rename libcrosvm_control to crosvm_control
The current inclusion of the 'lib' prefix is redundant and results
in 'liblibcrosvm_control' once built.

These changes remove the 'lib' prefix from the source files.

BUG=b:188858559
TEST=cros_run_unit_tests --board ${board} --packages chromeos-base/crosvm

Change-Id: Ic1bcdce9aa5d879f5867232ffec60f40fe57d3a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3321731
Reviewed-by: Hikaru Nishida <hikalium@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Christian Blichmann <cblichmann@google.com>
Commit-Queue: Kameron Lutes <kalutes@chromium.org>
2021-12-14 18:38:42 +00:00
Anton Romanov
c20f783733 Enable some tests for armhf builds
TEST=./tools/dev_container --hermetic bash -c "./tools/run_tests --target=vm:aarch64 --arch armhf"
BUG=b/203152778

Change-Id: I76da1d029e9b11016b1ed9245c5b09095703fb63
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3328099
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
2021-12-14 18:11:32 +00:00
Chirantan Ekbote
520ad43e5b Add scudo as an optional feature
BUG=none
TEST=`cargo build --features scudo`

Change-Id: If670ba1644ff508dfd15d7dd3846672904e0125a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3314441
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-12-10 09:09:17 +00:00
Chirantan Ekbote
7b13ef3ea6 cros_asyncv2: Add crate
Based on the previous proposal in [1].

* The Executor is now completely platform-agnostic and only relies on
  the platform to provide a type that implements the `PlatformState`
  trait.
* The crate provides concrete high-level types rather than forcing users
  to deal with trait objects and async-trait.  Currently, only File and
  Event are supported.  Support for timers, sockets, and pipes will be
  added in subsequent changes.
* Each high-level type delegates the implementation to a
  platform-specific type and exists mainly as a place to hold
  documentation and tests.
* On Unix the io_driver module provides async versions of various
  IO-related syscalls, which are used by the platform-specific File and
  Event types to implement the required behavior.
* io-uring support can be disabled at compile time.  When uring support
  is enabled, we make a runtime check to decide whether or not to use
  it.  The actual io-uring driver is currently unimplemented and will be
  added in a subsequent change.

One non-trivial downside of this change is that the futures returned by
the various async methods are !Send and !Sync, which means that they can
only be awaited from the same thread on which they were started.  In
practice this should be fine since current crosvm (and Chrome OS) code
doesn't really make use of sending futures to different threads. This
can also be mitigated by using `Executor::spawn_local` and a
`oneshot::channel` to isolate the !Send future from the outer async
fn (as long as the output of the future is Send). See the crate
documentation and the `outer_future_is_send` test in `src/executor.rs`
for more details.

[1]: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3062166

BUG=b:195468578
TEST=unit tests

Change-Id: I1aad0885e67a957149e2ec3b4d9df215d9b20d81
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3222223
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-12-09 12:33:02 +00:00
Alexandre Courbot
c02960d6b2 virtio: video: make libvda a selectable feature
For the crosvm externalization project, we want to be able to compile
video support without libvda, which is only supported on Chrome OS.

Add an explicit "libvda" feature to crosvm and make all the libvda code
depend on that feature, so any trace of libvda can effectively be
compiled out.

For compatibility, the "libvda" feature is selected by the
"video-decoder" or "video-encoder" features.

BUG=b:161774071
BUG=b:169295147
TEST=`cargo build --features="video-decoder,video-encoder"` results in a
     crosvm binary with libvda enabled.

Change-Id: Ice3d3089b73b77f6b009400953063f2cf8f385da
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026351
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2021-12-02 02:19:34 +00:00
Daniel Verkamp
d78d1e48e9 devices: refer to vmm_vhost via path dependency
Remove the crates.io patch from the top-level Cargo.toml and make
devices point to the third_party/vmm_vhost location directly, since
vmm_vhost has been forked in crosvm and cannot be replaced by the
crates.io version anymore.

Incidentally fixes this warning from cargo:

  warning: patch for `vmm_vhost` uses the features mechanism.
  default-features and features will not take effect because the
  patch dependency does not support this mechanism

BUG=b:205511695
TEST=cargo build
TEST=tools/presubmit --quick

Change-Id: Id29578b57f7540805cf85a3db9a09542b7b84825
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3299125
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-11-24 19:12:47 +00:00
Daniel Verkamp
c13c0c210b enumn: switch to upstream crates.io version
Developers may need to manually clean up the common/enumn directory - it
will be left behind if there are build artifacts (Cargo.lock, target
directory, etc.):

  rm -rf common/enumn

BUG=b:205344148
TEST=cargo build
TEST=tools/presubmit
TEST=emerge-hatch crosvm # with https://crrev.com/c/3265967

Change-Id: I1af3bdd22f40e87895a78a5cbc8033476058c927
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3278774
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-11-15 21:03:25 +00:00
Dennis Kempin
c8313dc204 crosvm: Use local vmm_vhost when compiling for ebuild
This should fix the current uprev problem.

BUG=b:205997217
TEST=FEATURES=test emerge-amd64-generic crosvm

Change-Id: I0a0bb46fb004a7a057be9b2e4b13878038551e81
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3276714
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-11-11 19:08:32 +00:00
Keiichi Watanabe
3a6ec148d6 third_party/vmm_vhost: Add vmm_vhost code into /third_party/
Move rust-vmm/vhost code from chromiumos's third_party directory to
crosvm's one.

Note that we have crrev.com/c/3269863 for license files in Chrome OS
ebuild.

Changes:
* Copied vmm_vhost files at "7c95b4a2 rust-vmm/vhost: switch to upstream
tempfile", whose latest upstream commit is "488b3adc fix warning:
unaligned_references".
* Remove [patch.crates-io] section from its Cargo.toml.
* Add attributes to skip `clippy::bool_assert_comparison` and
`clippy::needless_borrow`, which will be fixed in following CLs.
* Update crosvm's Cargo.toml and tools/chromeos/setup_cargo

BUG=b:205511695
TEST=tools/chromeos/setup_cargo && cargo build

Change-Id: Icee201b39ff1d352df59469a6c8668fc7cb92ab9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3267912
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-11-10 08:42:11 +00:00
Keiichi Watanabe
3230422d59 cargo: Remove *_stub from workspace member
libcras_stub and system_api_stub are empty replacements for libcras and
system_api respectively. so cargo is happy even if they're missing

BUG=none
TEST=cargo build with CL:3267568

Change-Id: I20ba2ca77a241e354a45816605282d06d26f895f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3267907
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-11-08 18:02:32 +00:00
Daniel Verkamp
6b29858a34 linux.rs: replace Error enum with anyhow
Use the anyhow crate to provide ad-hoc errors with context. This removes
the large, manually-updated enum, which we never use programmatically
anyway (error messages are printed in human-readable form and otherwise
not matched against).

BUG=b:190433480
TEST=cargo build
TEST=./test_all

Change-Id: Ia7b90b33774d4031054b346d650861d3105044ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105436
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-11-05 23:06:09 +00:00
Gurchetan Singh
3059851cd0 rutabaga_gfx: export rutabaga
This change adds FFI bindings to the Rutabaga Virtual Graphics
Interface (VGI).

BUG=b:173630595
TEST= compile
      cp rutabaga_gfx_ffi.so + rutabaga_gfx.so to sysroot
      ./rutabaga_test

Change-Id: Iba99b0ace9f1ad90b6c42d9075038dd9f05b9367
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3230331
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-11-02 15:53:02 +00:00
Dennis Kempin
8a1c50d5cd Refactoring: Move various general purpose crates to common/
This change contains the results of running

./tools/contib/cargo_refactor.py

This will break the next uprev, and needs to be synchronizized
with the corresponding ebuild changes in https://crrev.com/c/3248925

BUG=b:195126527
TEST=./tools/run_tests

Change-Id: Ied15a1841887bb8f59fba65b912b81acf69beb73
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248129
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-29 22:31:43 +00:00
Dennis Kempin
18724772c2 Add test runner ./tools/run_tests
The new runner makes use of the simplified crosvm build and greatly
improves execution speed by gathering test binaries from cargo output
and executes them directly in parallel.

This allows all of our tests to execute in ~5 seconds when run locally.

The new test runner also makes use of the new testvm tools to make it
easy to switch between testing on the host, in a VM or via SSH on a
remote device.

See ./tools/run_tests --help for usage instructions.

To allow more iterative testing with the same test targets, this CL
includes a set_test_target script to write env vars that instruct cargo
to build for the target arch and run on the test target.

Note: The test runner can build for armhf, but we need build file fixed
to allow armhf to build successfully.

BUG=b:199951064
TEST=Inside ./tools/dev_container:
./tools/run_tests --target=host
./tools/run_tests --target=vm:aarch64
./tools/run_tests --aarch=armhf --build-only
./tools/set_test_target vm:aarch64 && source .envrc
cargo test

Change-Id: I60291fa726fb2298f62d1f032e55ed6e7ab1c4ac
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3221779
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-15 22:12:03 +00:00
Daniel Verkamp
7fd815ed22 crosvm: switch to upstream tempfile crate
Use the crates.io implementation of tempfile instead of our own version.

Our reimplementation is kept in the tree for now in case of dependencies
outside of the crosvm tree; it can be removed later once those are fully
switched over to the crates.io implementation.

BUG=b:199204746
TEST=emerge-hatch crosvm

Change-Id: I07d3404239302ab9a17f4ddc82a9479b256e4eb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3209839
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-10-11 18:35:55 +00:00
Keiichi Watanabe
12a694e45e Remove vhost_user_devices crate
BUG=b:195495971
TEST=cargo build

Change-Id: Ib1b43e40fbdcebb7dc66c5a5f349b8de2da25cb5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3070725
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-09-07 13:11:53 +00:00
Ryo Hashimoto
6d9243865b fs: Support setting quota project ID
A new command line parameter to specify privileged UIDs.
If the requester UID is privileged, PassthroughFs uses D-Bus to set
quota project ID.

BUG=b:190791826
TEST=build

Cq-Depend: chromium:3129049,chromium:3129048
Change-Id: Ie27f200e8c651be6a5503f69e7b784c5e8f968ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3014623
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryo Hashimoto <hashimoto@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-09-03 00:47:25 +00:00
Woody Chow
737ff125ca Add virtio-snd device with CRAS backend
Enable with `--cras-snd`.

Verified:
Basic playback and capture

Missing features:
* Getting chmap/jack/stream info from CRAS. They are hardcoded for now.
* Jack connect/disconnect notifications from CRAS
* Reporting latency bytes to the driver. It is currently hardcoded to 0.

BUG=b:179757101
TEST=`aplay` and `arecord` inside a debian img with a 5.10 kernel built
     with virtio snd support. Launched with crosvm on rammus/kukui/hatch

Change-Id: I240000a92418b75b3eb8dcd241ff320214b68739
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2777991
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Woody Chow <woodychow@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2021-09-02 04:29:55 +00:00
Daniel Verkamp
1349c1314c Cargo.toml: make thiserror a required dependency
BUG=b:197143586
TEST=cargo check

Change-Id: Iabb7dfa9ec20774b7c15297b9ef86a9009fb11e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105069
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-08-26 22:28:28 +00:00
Woody Chow
e0f96c5930 Add cros_async to patches.crates-io
to avoid version conflict

BUG=None
TEST=CQ

Change-Id: If640e6288430213c104d95eb00cf0cb01c64b6d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3113245
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Woody Chow <woodychow@google.com>
2021-08-25 07:58:15 +00:00
Joel Galenson
06392aabd4 Migrate to gdbstub 0.5.0.
BUG=b:191784608
TEST=Build and run atest in Android tree

Cq-Depend: chromium:3073700
Change-Id: I5fcfa166caf8c5a5f759a8f62ef78a293db95f1a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3071900
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-08-13 18:30:47 +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
6a584d6f99 Integrate p9 and cros-fuzz into crosvm build
Updates path and includes the libraries in the test runner.

BUG=b:193243281,b:191509642
TEST=./run_tests passes and executes the new tests

Change-Id: If38126fa6bdf2a0a3dca5a79c6e4d76857617fd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3049671
Tested-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-08-03 02:25:02 +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
ba4cf4d985 rand_ish: remove unused crate
BUG=None
TEST=./test_all

Change-Id: Iee374cac5da7e6f4e91b4d0b704c6f4c209bc2f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3017609
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-07-21 23:28:28 +00:00
Vikram Auradkar
f7979867d6 Cargo.toml: Sort features alphabetically
BUG=b:191669804
TEST=cargo test

Change-Id: Ibfddb00c8720b938fdc476dd268f7208492921fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3003923
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Udam Saini <udam@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2021-07-08 21:41:46 +00:00
Dennis Kempin
fa32ced1e0 Crosvm Externalization: Move libvda rust code into crosvm
Long-term libvda will be replaced with an implementation that can
function outside of ChromeOS.

In the meantime thes allows crosvm to be built externally and pass
clippy with all features enabled.

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

Cq-Depend: chromium:2989315, chromium:2986403
Change-Id: Ic37bda4426d69d16cb4bc0d7ba6f81052f6f2f59
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2983505
Tested-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2021-07-08 05:32:04 +00:00
Chirantan Ekbote
5401edf519 Make vhost-user-devices a workspace member
We don't actually need vhost-user-devices when building crosvm so make
it a workspace member instead.

BUG=b:179755651
TEST=cargo test

Change-Id: Id39e37b3d2e59fd040e1c70a58d1b9b7f8380e36
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2987591
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-07-07 19:00:44 +00:00
Allen Webb
9623408e0c Add cras-sys to patches.crates-io to fix cargo workflow.
BUG=None
TEST=cargo build

Change-Id: Id82e23484f45e57c3a9cde5c0d7b1c22dab5220c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2970543
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Allen Webb <allenwebb@google.com>
2021-06-18 14:13:55 +00:00
Hikaru Nishida
a0e381b0d8 Change balloon_stats output format to JSON
This CL changes the output format of `crosvm balloon_stats` command to
JSON to ease parsing the result.

BUG=b:181267848
TEST=built and checked the output of crosvm balloon_stats

Change-Id: I4af40237109efdd02b5b70375ef8aa706cf5de55
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2914247
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Hikaru Nishida <hikalium@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Charles William Dick <cwd@google.com>
2021-06-15 17:29:30 +00:00
Daniel Verkamp
f1439d444b devices: add "usb" feature for emulated xHCI
Add a default-enabled "usb" feature to allow compiling out the emulated
USB controller and host device provider when not needed (e.g. for
crosvm-direct).

This reduces the crosvm-direct binary size by about 400 KiB.

BUG=b:173824333
TEST=cargo build --no-default-features
TEST=cargo build # ensure xhci controller is added

Change-Id: I1fc0eeb09c647854e5df57cd2fe7e92140256853
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2913136
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-24 21:37:22 +00:00
Keiichi Watanabe
8e7bc96616 Add vhost_user_devices crate
Add `vhost_user_devices` crate which will be used to create a vhost-user
device executables.

BUG=b:185089400
TEST=cargo test in /vhost_user_devices

Change-Id: I7256d68316f7763d3ceaa65abc97663975e7608f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2822169
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-05-11 18:34:39 +00:00
Daniel Verkamp
435f608501 Cargo.toml: remove libchromeos dependency
All of the functions that had been in libchromeos-rs are now moved into
sys-util, so drop the dependency from Cargo.toml and update Cargo.lock
to match.

BUG=None
TEST=cargo build

Change-Id: I253a635b37b18a52977b5028c08f311db1cf26cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2862577
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Allen Webb <allenwebb@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Curtis Malainey <cujomalainey@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-05-06 22:06:48 +00:00
Zach Reizner
6d6efb20c0 remove dependencies on syscall_defines
The syscall_defines crate is redundant with an up to date libc. This
change removes any dependency on syscall_defines. A new libc is required
to bring in some new syscall numbers like the ones for io_uring.

TEST=./test_all
BUG=None

Cq-Depend: chromium:2832000
Change-Id: I6df7fb992bacb5efd54cefca08836d52f4bfcd8c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2832001
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Allen Webb <allenwebb@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
2021-04-21 21:01:38 +00:00
Gurchetan Singh
401340ee7f devices: gpu: support creating udmabufs
This patch adds support for creating udmabufs via a guest provided
sg-list.  Ideally, we'd create the udmabuf from a virtio-gpu guest
dedicated heap, but that needs further investigation.

In terms of the protocol, these following prototype items are added:

BLOB_CREATE_GUEST_HANDLE: "create an udmabuf" or an OS-specific
equivalent. This can be used with the guest dedicated heap or system
memory.  Right now, only system memory is used.

We also want to associate the udmabuf with any host side metadata.  For
example, SET_SCANOUT_BLOB doesn't passthrough the modifiers since
virtio-gpu KMS + modifiers is annoying.  Simple solution: just ask the
host for the modifier.  This could also enable different caching types
if the guest blob is mappable (for example, the MSM GPU driver currently
only supports WC mappings.  We might also want cached mappings for
camera).

Incidentals:
  * Add a placeholder for RESOURCE_SYNC

BUG=chromium:892806, b:173630595
TEST=create a bunch of udmabufs from the guest

Change-Id: I4686d9f48938f10e7c265750a931d7d2d2d9611b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2786291
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-04-08 22:53:54 +00:00