Commit graph

126 commits

Author SHA1 Message Date
Richard Zhang
ac6c68a9fc virtio-snd: Upstream Window's virtio-snd Playback impl
TEST=presubmits and this code works downstream
BUG=b:258298873

Change-Id: I7369fb08af474d107d056da8538de86bbc03eeb8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4015562
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Richard Zhang <rizhang@google.com>
2022-12-07 21:33:49 +00:00
Keiichi Watanabe
20863a3c36 devices: Enable net_util/slirp if slirp is enabled
This is needed to build the `devices` crate only for the windows target.

BUG=none
TEST=cargo test --target=x86_64-pc-windows-gnu --features=slirp in devices

Change-Id: I781def962a716e4ee2ea80f3c6d1a426fc92e2e8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4028759
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-11-19 07:13:20 +00:00
Vikram Auradkar
2c6e960de3 win_audio: build and test win_audio
BUG=b:253494168
TEST=presubmit

Change-Id: Icb729671a0dcfbc4b6251c69732784de32f6318d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3988069
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-11-01 20:40:09 +00:00
Daniel Almeida
3399026503 video: decoder: vaapi: port the VAAPI backend to cros-codecs
Port the VAAPI backend to the new cros-codecs crate. This crate now
contains all codec related code and is independent from the rest of the
CrosVM code.

BUG=b:214478588
TEST="cargo test --package devices --lib --features video-decoder --features vaapi -- virtio::video::decoder::backend::vaapi::tests::test_get_capabilities --include-ignored"

Change-Id: Id207c53c0c4200e03ce8793d7c37cb5fbe808829
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3875044
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-10-28 03:23:31 +00:00
Alexandre Courbot
839577a796 media: libvda: allow to build without linking to libvda
libvda is only available on ChromeOS, and being unable to link to it
with regular builds reduces our build coverage.

Add a "libvda-stub" feature that, if enabled, results in dummy C stubs
being build for all the exported libvda functions. This allows builds
with the "libvda" feature to pass, although of course the resulting
video device would immediately crash and thus should not be used.

BUG=b:244619291
TEST=`cargo build --features="video-decoder,video-encoder,libvda-stub"`
completes.
TEST=`cargo build --features="video-decoder,video-encoder,libvda"`
reports link errors against libvda.
TEST=`cargo build --features all-x86_64` builds libvda and completes
without error.

Change-Id: I9bb60f6caf670081d67c91275727f3888272d64b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3947844
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-10-21 13:57:31 +00:00
Noah Gold
81549b21d9 devices: add err code for disk image open failed.
Adds a new error code for when we fail to open a disk image. Also adds
an exit code we were missing upstream.

BUG=b:253348635
TEST=intentionally messed up the disk image path and verified we get
this error.

Change-Id: I197b4c5d80682dd1ee2a42d02df852276d204c17
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3961530
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-10-20 20:27:58 +00:00
Pujun Lun
b849ebd0e1 crosvm: GPU and display arg parsing for Windows.
This replaces the handwritten arg parser with the serde_keyvalue
based parser. Eventually we will unify the arg parsing with Unix.

BUG=b:233676779
TEST=cargo b --features all-msvc64,gpu --no-default-features
TEST=cargo t -p vm_control --features all-msvc64,gpu
     --no-default-features
TEST=cargo t -p crosvm sys::windows::config::
     --features all-msvc64,gpu --no-default-features

Change-Id: I36a563be9767c7e5cbd3ab44f6a9ba23cd64cdb6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3939033
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-10-18 05:17:53 +00:00
Noah Gold
cb55cd0394 tracing: rename tracing to cros_tracing.
`tracing` conflicts with a crates.io crate. Since we may support tokio
tracing in the future, and want to submit some benchmarks against it
right now, we should rename our crate.

BUG=b:253517247
TEST=presubmit

Change-Id: I32bf64a7ce1830e881bd582e4606932782df65c6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3957598
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-10-17 20:49:16 +00:00
Idan Raiter
a55eea9cc8 vmm_vhost: Introduce GPU_MAP
Adds a new message that can be used to map GPU memory via Vulkano.

BUG=b:244622199
TEST=presubmit & downstream

Change-Id: I4018cfda7573d4df2d89225060d5d61c8ac5d3d9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3924935
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
2022-10-06 20:41:57 +00:00
Dennis Kempin
4c211a4d41 Extract vtpm out of the chromeos feature
And enable it in upstream all-linux builds.
The feature is enabled for chromeos by default, so should
be a no-op for chromeos builds.

We can probably simplify the cfg() attributes further by
only enabling the feature for x86, so we do not need the
extra check each time. But that'll require ebuild changes.

BUG=b:244618505
TEST=presubmit
TEST=cargo build --no-default-features --features=vtpm

Change-Id: Ibb33c04ab5e6486969fefc6f3e57503be4eccdf3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3924741
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-10-04 21:11:30 +00:00
Dennis Kempin
d6cd312571 Split arc_quota out of the chromeos feature
This allows us to enable the feature in upstream builds.

The feature is automatically enabled for the chromeos feature,
so it should be a noop for ChromeOS builds.

BUG=b:244618505
TEST=presubmit / build_packages implicit-system crosvm

Change-Id: I2ea2d668a0f8c2faa92aad5452df0bf660d85e0e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3919815
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-09-28 18:13:00 +00:00
Dennis Kempin
891455563b system_api: Add copy of ChromeOS's system_api
Adds a script that copies the bindings we need upstream. We cannot
use the original repository, as it's part of the large platform2 git
repository, and the original build.rs depends on ChromeOS tooling to
generate these bindings.

So instead, this change adds a script that can be called from a
chromiumos checkout of crosvm to update the upstream bindings.

This allows us to enable certain features that talk to ChromeOS
dbus services. They won't be functional upstream, but at least we
can compile and test the code.

To make things more consistent, we no longer replace the crate
with the ChromeOS version when building for ChromeOS.

BUG=b:244618505
TEST=presubmit

Change-Id: I504cbf6d12b0cb50d9935f5e49b7fa72b692d45c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3919814
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-09-28 18:13:00 +00:00
Pujun Lun
698d2dcc3a devices: add feature flags to render_server_fd.
We want to hide this variable from platforms that don't use it.

BUG=b:213149288
TEST=presubmit

Change-Id: I0d44d2bc50843b86d82b4084f95c8d1a1f750aa6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3895401
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
2022-09-22 20:21:59 +00:00
Daniel Verkamp
a00ad77d21 devices: cmos: use chrono crate to get time
We already depend on chrono elsewhere, so we might as well use it rather
than rolling our own unsafe wrapper around gmtime_r.

BUG=None
TEST=tools/presubmit --all

Change-Id: I46e4a75ca74f8a02875814f6cb21031db58e1e3a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3795009
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-08-03 18:19:31 +00:00
Zihan Chen
11812a5bf9 crosvm: Make ballooning a compile time feature
Balloon support can not be compiled out, and don't need to be
disabled at run time.

BUG=b:235887451
TEST=Guest has balloon device by default, does not have balloon
device when disabled. Ballooning via cli functions by default,
return not supported when running vm has ballooning compiled out.

Change-Id: I737851496fe4c14cdbb69c48e6edf1ca9186c15a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3786928
Tested-by: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2022-07-27 19:21:50 +00:00
Vikram Auradkar
02028483bc devices: resync with downstream
This closes the deltas between some of the files of the crate. The
changes include
- Enables building/testing balloon module on windows.
- Suppressing dead-code warnings on windows in cross platform files.
- u16 to enum fix.
- Organizing imports.
- Using Descriptor(windows friendly) over RawDescriptor.
- Using Option<Tube> instead of Tube.
- Fix some args parsing on windows.

BUG=213149155
TEST=presubmit and built on windows downstream

Change-Id: Idd2ee81384bc5fade610aa864b2c712ea0a0e0d2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3783010
Tested-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
2022-07-25 17:24:15 +00:00
Vikram Auradkar
33974789a7 devices: add bus statistics
Collect stats for read and write functions.

BUG=b:213149155
TEST=presubmit

Change-Id: Ia9d6a5fe006d2377dadde7215a9bf6ecd7966b13
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3773173
Tested-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-07-21 15:14:50 +00:00
Richard
d569281cc6 devices: Upstream Windows implementation for Serial
This adds a sync thread that will call `fsync` once a second. This is a
safety measure since Window OS handles flushing automatically, but has been
proven to be somewhat unreliable.

TEST=built and presubmits
BUG=b:233951530

Change-Id: I7f5922da09fd95999bf8a7a40abc3b6ae796eafc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764466
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Richard Zhang <rizhang@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
2022-07-15 20:50:16 +00:00
Daniel Almeida
863e827451 devices: video: decoder: Add a VP8 VAAPI decoder
Add a VAAPI VP8 backend. It uses the VAAPI driver in the system to
decode vp8 frames.

BUG=b:214478588
TEST=virtio::video::decoder::backend::vaapi::vp8::tests::test_25fps_vp8
passes on Hatch.

Change-Id: I5173a1761d98f0d0b3e4d4fb73c27eb8de87fb42
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3514628
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-07-13 07:11:59 +00:00
Daniel Almeida
6fb485c5a1 devices: video: decoder: Add a VAAPI decoder backend
Add a VAAPI video decoder backend. This backend is able to decode frames
by calling into the VAAPI driver in the system. It does so by making use
of a libva wrapper crate that exposes a subset of the VA C code in safe
Rust.

BUG=b:214478588
TEST=virtio::video::decoder::backend::vaapi::tests::test_get_capabilities
passes on Hatch.

Change-Id: I52ac6b5b915d9c3a9b55381e1076c1b5ac0dfb5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3514624
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-07-13 06:51:29 +00:00
Richard
5d77466913 virtio-vhost: Enable block tests
Commented out code reference sandbox crate, which still needs to be
upstreamed

Still need to enable:
 * balloon (try_clone not implemented)
 * console (Need to enable Serial)
 * snd (Unix code not conditionally compiled out)
 * gpu (Waiting for graphics team to upstream)

BUG=b:237011316
TEST=ran "./tools/run_tests --target=host --arch=win64 --verbose"

Change-Id: I1b5f7ae575365351184042bc65cffcfd7efe999a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3721870
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
2022-07-01 23:44:09 +00:00
Daniel Verkamp
98fcb96d6b Cargo: bump all rand dependencies to 0.8
The previous configuration made us pull in three different versions of
rand, and depending on "*" is a recipe for API incompatibility.

crosvm-fuzz needs to match its rand version to the rand_core used in
common/cros_fuzz, so that will be upgraded separately.

BUG=b:236978141
TEST=cargo build
TEST=emerge-hatch crosvm

Change-Id: I655ed3f156e4ac43afa3122596f62e9caa43b4f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3722184
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-06-30 23:22:37 +00:00
Richard
b9ddd723ce virtio-vhost: Enable handler to be built and tested on Windows
Still need to enable:
 * balloon (try_clone not implemented)
 * console (Need to enable Serial)
 * snd (Unix code not conditionally compiled out)
 * gpu (Waiting for graphics team to upstream)
 * vhost-user block

BUG=b:237011316
TEST=ran "./tools/run_tests --target=host --arch=win64 --verbose"

Change-Id: If2b69250477f88ded7176054196107733736786e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3721868
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Richard Zhang <rizhang@google.com>
2022-06-30 00:48:02 +00:00
Vikram Auradkar
32cabe0cd4 devices: enable tests
BUG=b:213149155
TEST=presubmit

Change-Id: Iff1a721dddfaed3e2728222a75348745be9ef05a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3710851
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-23 00:26:06 +00:00
Daniel Verkamp
19fc097eb8 crosvm: replace lazy_static with once_cell
We depend on both lazy_static and once_cell, which do basically the same
thing.

The once_cell crate has a few advantages:
- once_cell is on track to be included into libstd.
  (https://github.com/rust-lang/rust/issues/74465)
- once_cell doesn't require macro magic.

Replace the uses of lazy_static with their once_cell equivalents so we
don't need to pull in both crates.

BUG=b:236191006
TEST=tools/presubmit --all
TEST=tools/run_tests --target=host --arch=win64 --build-only
TEST=cargo test --features=plugin

Change-Id: I7cabcd837ef4878e8e8ae635bb4f235a58e4cae3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3707624
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-06-21 23:40:55 +00:00
Vaibhav Nagarnaik
24b9db5095 irqchip: Add WhpxSplitIrqChip implementation
Implement `WhpxSplitIrqChip` for `whpx` (Hyper-V) which has a split IRQ
chip architecture. Add dependencies for the root `whpx` feature on the
`devices/whpx` feature set.

BUG=b:213149158
TEST=Compiled on windows.

Change-Id: I3b0aec441b5abdff3f0266a9467380b0cdc4fdee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3717187
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
2022-06-21 21:31:21 +00:00
Anton Romanov
7910b89eb3 crosvm: move run command to argh
Due to the way we allow arguments to be specified I was not able to
reuse Config structure for cmdline arguments. (eg we allow multiple ways
to specify same config)

There is still some usage of arguments mod that we need to cleanup
later.

Change-Id: Ia0c12d508d0a10d17f58944de71276e5984d69ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3684144
Auto-Submit: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-06-13 23:55:20 +00:00
Vikram Auradkar
3a2f600275 devices: Conditionally depend on unix only crates
BUG=b:213149155
TEST=presubmit

Change-Id: I89a1aaf3e171cbd6c1591ae510dd46424d6f8752
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3703221
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-06-13 23:08:52 +00:00
Vaibhav Nagarnaik
839fc21eb2 devices: Add tsc handling
Add `tsc` as a device. Includes operations to calibrate and sync the
TSC values across the physical cores in order to minimize variations
found when moving vcpu threads across cores.

BUG=b:234508273
TEST=Compiled.

Change-Id: I5c79deebc9471dacf9d6596384ee77a8811a58bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3682118
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
2022-06-09 22:15:01 +00:00
Alexandre Courbot
fc891cea82 virtio: video: decoder: add ffmpeg-based software decoder backend
The virtio video decoder device is currently only available under very
drastic conditions: a build linked against libvda (a ChromeOS-only
library that needs the cros chroot to be built and linked against), and
a ChromeOS-flavored Chrome instance running alongside crosvm, so the
browser can provide the video decoding service through Mojo.

This makes the decoder device very difficult to develop on for
non-Chromies, and also for Chromies actually since they will always need
a DUT to test it on.

This patch introduces an alternative decoder backend based on
ffmpeg's libraries that performs decoding on the host's CPU. It supports both
guest pages and virtio objects as target, and can be considered a
reliable and predictable way to test the decoder in any environment.

We introduce our own ffmpeg bindings after a quick state of the art
revealed that the existing ones were all unsuitable, either for
technical or licensing reasons. Doing so is also not a big effort and
does not add any new external crate dependency to crosvm.

BUG=b:169295147
TEST=cargo test --features "video-decoder,ffmpeg" -p devices ffmpeg
TEST=v4l2r's simple_decoder example decodes test-25fps.h264 properly with the
     following command:
     ./simple_decoder test-25fps.h264 /dev/video0 --input_format h264 --save test-25fps.nv12
TEST=ARCVM Android youtube plays videos correctly when the ffmpeg
     backend is used.

Change-Id: Ic9c586193f7939f2a3fe59d009c3666585a8bbc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3026355
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-06-07 11:44:21 +00:00
Richard
a19d6ce89c devices: Update rng devices to be platform agnostic
On Unix, instead of getting random data from `/dev/urandom`, it will get
it from the `rand` platform agnostic crate instead.

OsRng.fill_bytes on unix will make a syscall to getrandom(2) if
available, otherwise it will read from `dev/urandom` after a succesful
poll to `dev/random`. Regardless of which way a random data is
retrieved, if the entropy pool is not intialized, `fill_bytes` will
block until it is intialized. This shouldn't be a problem because it is
a one time cost.

This CL will also upstream the Windows implementation of the rng device.

BUG=b:213149162
TEST=built and presubmits

Change-Id: Ic017f11795f8006e0bf2a04eb0478b3a3d336507
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3657812
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
2022-05-25 01:35:13 +00:00
Noah Gold
44306221c1 devices: Upstream Windows vhost-user net device.
Splits the vhost-user device into unix & Windows components, and
upstreams the Windows side. Note that we can't build devices on Windows
yet in crosvm because we have to upstream a fair bit more first
(net_util, cros_async, the vmm side of the vhost-user device).

Since net_util isn't upstreamed yet, we've made some very minor changes
to keep things consistent & building on Linux.

TEST=unix is tested by bots upstream & downstream; windows is tested by
bots downstream only.

BUG=b:226233737

Change-Id: Ie3f9818ff93c9e0085a5434055f9dc71c6f6851c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3549854
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-04-07 01:19:21 +00:00
Alexandre Courbot
c7cd0e0114 Move libvda to media/libvda
As we are going to introduce more media-related crates, reserve the
"media" folder as a placeholder for them, starting with the existing
libvda.

BUG=b:169295147
BUG=b:214478588
TEST=cargo build --features "video-decoder,video-encoder,libvda"

Change-Id: I1b2ec65cbba8b735db3d19845c504546fa1c64ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3565623
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-04-06 01:19:07 +00:00
Vikram Auradkar
3a29174a7b Upstream windows serial device
Bug: b:213149155
Test: cargo test and presubmit
Upstream-Crate: devices
Change-Id: I1420fee814271dae9502878963872449dae8218e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3527444
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-03-24 23:45:10 +00:00
Alexandre Courbot
da20cf1d78 devices: serial: parse options using serde_keyvalue crate
Use our new serde_keyvalue crate to annotate the SerialParameters
structure and allow us to create it from a key-values string. Add tests
to help ensure parsing doesn't break in the future.

The existing arguments can be parsed identically by this new code, so
replace the old serial options.

BUG=b:218223240
TEST=cargo test -p devices serial_device::tests::params_from_key_values
TEST=cargo test parse_serial

Change-Id: I4898a45399b69b87a44f80d3a214daf081b06173
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3439670
Reviewed-by: Anton Romanov <romanton@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-03-24 01:33:22 +00:00
Keiichi Watanabe
15b4769df5 devices: vvu: Add uuid argument for vvu-proxy
Add optional `uuid` argument to `--vvu-proxy` so a user can specify a
UUID that will be stored in virtio_vhost_user_config space so that the
guest can read the value by reading /sys/devices/pci*/*/resources.
We can use this value to allow the guest to know the socket path that
the VVU proxy device uses.

BUG=b:215472603
TEST=pcimem /sys/device/pci.../resource0 0x2008 b*16,
     where 0x2008 == (DEVICE_CONFIG_BAR_OFFSET + offset in vvu config)

Change-Id: I99f1d988cb793b44682ddf927837139dabd42cf8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3516669
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-03-23 08:11:12 +00:00
Alexandre Courbot
eea1729c39 rutabaga_gfx: do not support GLX if x feature is not enabled
At the moment compiling with the "virgl_renderer" feature enabled but
"x" disabled results in a link error because the virgl_renderer enables
all its platforms without checking. Fix this by enabling the glx
platform only if the x feature has also been enabled.

BUG=b:226033718
TEST=`cargo build --features "virgl_renderer"` passes.
TEST=`cargo build --features "virgl_renderer,x"` passes and enables GLX
in virgl_renderer.

Change-Id: I85041fc2a3db7e49415add69389bee3160ba4a5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3539327
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-03-23 02:12:23 +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
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
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
45f1a419d4 Make crates depend on base instead of sys_util
As we make progress on upstreaming sys_util, we do not want more
dependencies on sys_util added. This check helps in that cause.

With this change only files that are inside common can depend directly
on sys_util.

Test: python3 ./tools/impl/check_code_hygiene.py common/sys_util_core
Bug: b:213149154

Change-Id: I57a8cb9189d3263a4031338b302cb27da799f4de
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3473344
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-02-25 20:17:46 +00:00
Keiichi Watanabe
6f9c40feee devices: vhost-user: Extend DeviceHandler to support VVU
BUG=b:194137301
TEST=cargo test in devices

Change-Id: I1b5a53eec0114f35421512f374f7cec693520fd7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3149876
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-02-10 11:22:13 +00:00
Keiichi Watanabe
7bae9eeda5 devices: vvu: Add VFIO PCI driver for vvu
BUG=b:194137301
TEST=build

Change-Id: Ib4c6a8c5cca3e270a4236be9bf37df2b170e8eb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3295304
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-02-09 17:08:33 +00:00
David Stevens
0f924dd693 balloon_control: expose rust API for balloon
Add a crate containing an API for controlling the balloon. This is done
by reusing the API between the control socket and the balloon device.

BUG=b:213962590
TEST=compiles

Change-Id: I5d89d5ebee55162d28ba45ca2c49b7083561b916
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3394440
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-01-28 03:52:35 +00:00
Anton Romanov
d48d4608d6 vhost: user: Move from getopts to argh.
Motivation: get rid of required options vs help boilerplate
BUG=n/a
TEST=run_tests

I've also done some binary size testing as well:

Baseline:
   text    data     bss     dec     hex filename
5050303  264640    1072 5316015  511daf crosvm

StructOpt:
   text    data     bss     dec     hex filename
5400901  277104    1072 5679077  56a7e5 crosvm

StructOpt, default-features = false
   text    data     bss     dec     hex filename
5418437  275872    1072 5695381  56e795 crosvm

argh
   text    data     bss     dec     hex filename
5024287  262648    1072 5288007  50b047 crosvm

Change-Id: I7ebe09e38d3854c4a0e5c8e3a2aecb123652ce1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3339792
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
Auto-Submit: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-01-06 21:16:50 +00:00
Keiichi Watanabe
4960f63d6d devices: vvu: Add utilities to bind vfio-pci device
Add utilities to bind a vfio-pci device, which will be used in
the virtio-vhost-user driver.

This works like the following use of DPDK's devbind script [1].
$ dpdk-devbind -b vfio-pci 'Bus:Slot.Func'

[1]: https://doc.dpdk.org/guides/tools/devbind.html

BUG=b:194137301
TEST=cargo test in devices

Change-Id: I67fb34ae2ad55320231751ea553a2094bb8cdde4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3295303
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-12-22 13:55:23 +00:00
Chih-Yang Hsia
c6d01914de device: virtio: snd: Add missing handle_irq_resample
While running alsa_conformance_test against the virtio-snd device, the
driver will randomly stop getting irq events forever. (vp_interrupt will
never get called).

At the same time, the host device will still see an uncleared
`interrupt_status` so the `trigger_interrupt` -> `signal`
will just drop the interrupt signal on
the host device side. And the device can't be used forever when the
issue happens.

Root cause:
Irq resample events never get handled in the virtio-snd device, so the
interrupt handler in guest just can't get notified if there are some
unhanded interrupts in the irq line during the resample event.

Changes:
- Add `f_resample` future in the run_worker
- Use `select!` from futures crate with `async-await` feature
- Change local interrupt in run_worker to Rc<RefCell<interrupt>>
- Use anyhow::Context for errors

BUG=b:202368198
TEST=vm.AudioAlsaConformance.virtio_cras_snd
TEST=Run alsa_conformance_test multiple times in guest VM

Change-Id: Id1440420dcfeccbbb455b1d342863e430ef4b6f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3317327
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-07 03:33:46 +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
Keiichi Watanabe
b3f4433512 vmm_vhost: Rename features to "vmm" and "device"
Rename feature names:
* vhost-user-master -> vmm
* vhost-user-slave -> devicwe

BUG=b:206900656
TEST=kokoro

Change-Id: I84b627b757421a2ea9f56018ad44e227df20ab8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3295220
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-12-01 09:45:48 +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