Commit graph

156 commits

Author SHA1 Message Date
A. Cody Schuffelen
97dff044f8 Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))]
Updates are made to source and documentation.

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

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

md files manually updated to fix line lengths.

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

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

TEST=CQ

BUG=b:300969352
FIXED=b:300969352

Change-Id: I90f0dfb09494f875fef1cd11bfcbd48030846092
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4878761
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-10-10 17:34:32 +00:00
Daniel Verkamp
157ce87067 Cargo.toml: remove chromeos from base and devices
This feature does nothing in the base and devices crates, so remove it.

The remaining features enabled by chromeos are still needed until they
are enabled explicitly in the crosvm ebuild, so they aren't removed yet.

BUG=b:244618505
TEST=emerge-brya crosvm

Change-Id: I4fec40fb7ceb4eeff75266a66f19c0f142b9195a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4873792
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-10-09 20:14:59 +00:00
Daniel Verkamp
e10df59fd3 devices: remove --software-tpm support
The software TPM backed by the libtpm2 simulator was only used for
testing; now that we have the vTPM proxy device, the software TPM is no
longer needed.

This also allows removal of the tpm2 submodule (tpm2-sys/libtpm2).

BUG=b:300673042
TEST=tools/dev_container tools/presubmit

Change-Id: I3feb5f715f9f12f832450df712c0f63ed7b4fb13
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4875221
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-10-02 23:28:45 +00:00
Daniel Verkamp
03dd1feab7 Cargo.toml: depend on zerocopy 0.6 explicitly
Previously all of the zerocopy imports just used "*", but there are
API changes in zerocopy 0.7, so ensure we get a compatible version by
depending on 0.6 everywhere.

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

BUG=b:301283548
TEST=cargo build

Change-Id: Ifd702d982a09b5083dddd666dc6f3052cba22214
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4878502
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-09-20 21:28:58 +00:00
Daniel Verkamp
6513b888b0 Cargo.toml: introduce net feature
This commit just adds the feature but intentionally does not use it yet.
For downstream projects (e.g. the ChromeOS crosvm ebuild) that use
--no-default-features and enable individual features manually, those
projects will need to add the net feature to their build scripts in
order to keep network functionality. Once that is done, then we can make
the net feature actually control whether the net device is built.

Change-Id: I47e405ac295eef933f5d83ec3a4a490028da231b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4823132
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-09-12 21:02:33 +00:00
Daniel Verkamp
40114fd26e Remove virtio-vhost-user (VVU) support
This code is unused and untested, while simultaneously making the rest
of the virtio device code more complex. Remove it.

BUG=b:276993009
TEST=tools/dev_container tools/presubmit

Change-Id: I9d44f92419c6912d1735043404d4f64efc95bba4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4676076
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
2023-09-05 17:59:33 +00:00
Daniel Verkamp
045a3074ef Cargo.toml: add version to chrono dependencies
The newest chrono version is currently on the 0.4.x branch, but there
are preparations to release a 0.5.x version. Explicitly specify a 0.4.x
version in our dependencies since there will be backwards-incompatible
API breakages in 0.5.x.
<https://github.com/chronotope/chrono/issues/970>

The exact version chosen (chrono 0.4.19) matches the version we have
pinned in Cargo.lock currently and will match any newer 0.4.x releases,
so there should be no functional change.

BUG=None
TEST=cargo build

Change-Id: Ifa24a547e435ab4987be9358343e6b25c1385c66
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4774870
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-08-11 21:02:25 +00:00
Alexandre Courbot
f484411e29 video: decoder: vaapi: use cros-codecs 0.0.4
The cros-codecs API has changed a lot, and it supports zero-copy
decoding as well as HEVC now.

BUG=b:262824148
TEST=presubmit

Change-Id: Icc2a258642cef012b5640f1c71ccff481b5808f2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4744560
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
2023-08-04 18:17:26 +00:00
Daniel Verkamp
4bd4358aa4 Remove all remaining --features=direct code
BUG=b:279663365
TEST=tools/dev_container tools/presubmit

Change-Id: Iaa0b8176a54982044137b112039bf04f1e183c4e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4713506
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Grzegorz Jaszczyk <jaszczyk@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dmytro Maluka <dmy@semihalf.com>
2023-07-25 17:55:10 +00:00
Wang Ningyuan
c1e471e52a devices: pci: Hotplug compatible PCI trait
CL introduces HotPluggable, additional requirements for a PciDevice to
be configured in a hotplug context. VirtioPciDevice is currently the
only supported type.

TEST=tools/presubmit
BUG=b:243767476

Change-Id: I0e8a6c6fbd430216874b54d7b577f04cd4bae5fd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4615383
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Ryuichiro Chiba <chibar@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2023-07-24 06:24:52 +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
Alexandre Courbot
9ae485d979 video: decoder: vaapi: switch to external cros-codecs
Use the version of cros-codecs publishes on crates.io and adapt the code
to be able to use it. This results in a few simplifications as e.g.
frame ordering is guaranteed by cros-codecs and we don't need to handle
it anymore.

BUG=b:262824148
TEST=ffmpeg -codec:v vp9_v4l2m2m -i Big_Buck_Bunny_720_10s_1MB.webm Big_Buck_Bunny-%03d.png
TEST=cargo test --features "video-decoder,vaapi,ffmpeg" -p devices -- --include-ignored test_decode_h264

Change-Id: Ib694afe8206a4d85b307efaaf3f6669dfe4e18bb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4518093
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2023-05-17 00:52:34 +00:00
Shintaro Kawamura
8590cdcc8a swap: expose Status interface to all variants
Status does not depend on any swap related feature. Exposing Status to
all variants is easy to implement swap status FFI at crosvm_control.

The new "swap/enable" feature switches the actual vmm-swap functionality
to be compiled. The feature is enabled by default on "swap" crate but
disabled on the root package for test dependency.

Vmm-swap feature is enabled by `--features=swap` flag on cargo build as
before.

swap/src/controller.rs is copied from swap/src/lib.rs.

BUG=b:265386761
TEST=tools/dev_container tools/run_tests2

Change-Id: Ifc2539a62d0f594fd5bbb41623c735ea2621f7b6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4486546
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
2023-05-04 12:30:09 +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
Daniel Verkamp
894e7ed13c vhost: only compile on unix platforms
The vhost kernel API is specific to Linux; it doesn't make sense to
build it on Windows.

Change-Id: I3b8f726f74389f2a3ff78eff43b0c4f312382004
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4437030
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-17 23:43:52 +00:00
Keiichi Watanabe
bc9e331085 devices: Explicitly specify "serde" feature for chrono
Since we're serializing `DateTime<Utc>` with `derive(Serialize)` in
cmos.rs, "serde" feature needs to be specified.
Even without this commit, `serde` feature was specified probably because
of indirect dependency. But, it'd be better to specify the feature
explicitly.

BUG=none
TEST=CQ

Change-Id: I637a804d93dab825cb4452d22e4b3882ac27cf98
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4414505
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-04-12 16:57:57 +00:00
Keiichi Watanabe
e0c35da0b0 devices: virtio: Serialize PassthroughFs unit tests with NamedLock
Use NamedLock to prevent PassthroughFs tests from running in
multi-threads when one runs `cargo test`.
Previously, we ran these tests as a part of integration tests with
`libtest_mimic` to ensure it's not parallelized. But, using nextest's
feature is more straightforward. Also, running them as unit tests allow
us to call mocked functions with `#[cfg(test)]` in the future.

Note that NamedLock is not necessary for `cargo nextest` because it runs
each test single-threaded, but in multi-processes.

BUG=b:275016855
BUG=b:277302336
TEST=run_tests

Change-Id: I3751b712eaf1b2180bf4153ab501a32b402c0a29
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4406098
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2023-04-12 04:05:41 +00:00
Elliot Berman
ea5fab36a4 devices: irqchip: Implement GunyahIrqChip
Implement GunyahIrqChip.

Cherry-pick notes: Added license header + delete unused imports.

BUG=b:232360323

Change-Id: I11d32599f221b57974f9d942d1aa9f128fc14516
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4404218
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-04-05 18:32:18 +00:00
Junichi Uekawa
d03c99fc0c crosvm: Uprev uuid > 1
Uprev to version available in Debian.

This seem to end up doing uprev to 1.3 now.

BUG=b:265082456
BUG=b:229895468
TEST=build

Change-Id: I550778acb675c9034b9cfcea77f4ae847e2d2ea1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4364559
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-04-04 23:56:13 +00:00
Keiichi Watanabe
a58648f339 devices: Force to run Passthroughfs integration tests in single thread
We can't run PassthroughFS unit in multithreaded environment because each test creates its own PassthroughFS and the difference instances can execute conflicting process-wide operations (e.g. fchdir).
So, we need to have an integration test binary with a custom test
harness.

BUG=b:275016855
TEST=run_tests --dut=host
TEST=run_tests -p mingw64

Change-Id: I33855ab37bbe9486723038ed196f50a1a85ca748
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4369818
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-03-31 01:43:15 +00:00
Yi-De Wu
65d98b04f6 aarch64: MTK GenieZone hypervisor enablement as Crosvm backend
To support GenieZone (gz) hypervisor as a crosvm hypervisor backend:
- Implement GenieZone hypervisor
- Implement GenieZone’s irqchip
- Create config and feature for GenieZone
- Probe proper hypervisor backend with naive logic
- Inject virtual interrupts
- Bootup guest VM with linux kernel to shell

We still have other todos:

- Integrate with protected VM and pvmfw
- Support multi-core VM

Fixed bugs:
- Replace gz with geniezone in most cases for clarity
- Replace KVM’s ioctl number with GZVM’s ioctl in bindings

Bug: 264630327
TEST:
$ taskset 10 ./crosvm run --disable-sandbox -m 512 -s s1 \
  --rwroot alpine-rootfs.img -p 'init=/bin/sh rodata=off' \
  --display-window-keyboard Image_515_41_no_numa_20230130 \
  --serial type=stdout,hardware=serial,earlycon \
  --serial type=stdout,hardware=virtio-console,console,stdin

Change-Id: Ia5d92ba5cbb4198ab7f9f2a778da03b2199892cd
Signed-off-by: Ze-yu Wang <ze-yu.wang@mediatek.com>
Signed-off-by: Yi-de Wu <yi-de.wu@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4170415
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-03-22 18:04:47 +00:00
Norman Bintang
32ca7e250a devices: virtio: snd: Implement file backend for VirtioSnd
File backend will write audio playback to files. Every PCM playback
stream will have its own file.
Changes:
* Add playback_path and playback_size to virtio::snd::Parameters
* Add new file_backend file in virtio::snd
* Add virtio-snd arg help.

BUG=b:233542268
TEST=run crosvm with --virtio-snd backend=file and call aplay

Change-Id: Iaec01f52292f1181b0137fa3c8d8c2b2b9e7cc49
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4306260
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-03-21 07:46:05 +00:00
Zihan Chen
e670159c2e crosvm: Add seccomp_trace feature
Add a minijail's mode of operation where an always-allow seccomp
filter is attached to forked device processes. This facilitates
capturing seccomp filters used by each device process separately.

TESTED=./tools/build_release -- --features seccomp_trace && strace -ff crosvm --log-level debug run <args>

BUG=b:258316090

Change-Id: Ic4d3f5178e6a2dcbd748d101db43574f3224ff78
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4289510
Commit-Queue: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-03-01 19:18:12 +00:00
Zihan Chen
8a7550c40a crosvm: Partially convert DataInit to zerocopy (1/n)
Thie effort is splitted into multiple CLs, to reduce change size
and also make bisecing breakages easier.

TESTED=CQ only

BUG=b:204409584

Change-Id: Ie90f171bd5f74b732df3129e94733f3b34621092
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4210751
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-02-02 19:28:57 +00:00
Shintaro Kawamura
b5a9833d97 swap: send userfaultfd via Tube on device process fork
This implements the equivalent logic on crosvm as
UFFD_FEATURE_EVENT_FORK. When each device process forks, the ProxyDevice
creates userfaultfd and send it to the monitor process by
SwapController::on_process_forked().

Crosvm does not have any child processes which may access the guest
memory except device processes as of now. Crosvm forks
virgl_render_server, but the mmap is not preserved in the process on
execve(2) since it is a different binary. Also no device process forks
grandchild processes according to the seccomp policy.

We actually can't use UFFD_FEATURE_EVENT_FORK because the feature does
not support non-root user namespace (go/uffd-fork-user-ns) and ARCVM
runs in a non-root user namespace.

This also adds syscalls to seccomp policies for devices to allow the
processes to create and setup a userfaultfd.

BUG=b:266641923
TEST=manually tested

Change-Id: Ide3088e1e95ae3c8259e3f4324124b3376e760b7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4194228
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-02-01 00:47:52 +00:00
Daniel Verkamp
9e2494f7e0 devices: serial: implement out_timestamp for all platforms
This feature has nothing specific to Windows in its implementation, so
pull it up to the portable part of the Serial device.

The unit test is slightly modified to avoid the need for the regex
crate. This was the only use of regex in devices, so it can be dropped
from Cargo.toml.

BUG=None
TEST=cargo test -p devices serial
TEST=tools/run_tests --platform=mingw64

Change-Id: I3073e90d71bda3c9f6da1df3a3b657e62e087302
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4126251
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-01-04 06:21:02 +00:00
Daniel Verkamp
c68c51a84b devices: battery: move monitor code out of sys
The PowerMonitor trait and the code monitoring it for events is not
platform specific, so it can be moved out of sys/unix into the main
battery code.

BUG=b:213149155
TEST=tools/presubmit --all
TEST=emerge-brya crosvm

Change-Id: I5c34c0e98009d866d5345fd940ecc7f742da1d2c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4122803
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-01-03 22:44:29 +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
Frederick Mayle
f51a6f9ef1 devices: remove unconditional dependency on slirp
If we always enable "slirp", then there are new, unwanted dependencies
on "libslirp-sys" and "pcap-file" in android.

The following line from the [features] section is sufficient to enable
it when needed:

    slirp = ["net_util/slirp"]

BUG=b:260604615
TEST=cd devices; cargo test --target=x86_64-pc-windows-gnu --features=slirp

Change-Id: I87ff19a0101b9d09f42b11517bee2fef8b83ec3f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4082148
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2022-12-08 18:53:48 +00:00
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