Commit graph

5208 commits

Author SHA1 Message Date
recipe-roller
599a21392c Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (recipe_engine) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8801095104517055281

recipe_engine:
af504e0920
  af504e0 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 75120fcbacd9 to 1db56b0f2cfb

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: Ib3a7b02f38b4af4f816f019400f70fb5774d41b2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3937342
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2022-10-06 01:25:40 +00:00
recipe-roller
eaf906f233 Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (depot_tools) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8801105171517745073

depot_tools:
403c44e293~..9cac96fd069ba406f57e1a749bfa20e2802c1ebb
  403c44e (dcheng@chromium.org)
      Add a --max-depth option to git cl split
  9cac96f (robertocn@chromium.org)
      lucicfg: Update from 1.33.1 to 1.33.2

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: I16426cadb41541db7452510210dc82e78b4a9b61
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3936706
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2022-10-05 22:44:41 +00:00
recipe-roller
1a249cf018 Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (depot_tools) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8801108314633557809

depot_tools:
4e1c1958fa
  4e1c195 (rgw@google.com)
      Removing log level info from Presubmit CI

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: I89b67986929f59f5a03011a0d8c8af53f2b2de2a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3936703
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2022-10-05 21:54:29 +00:00
Elie Kheirallah
7a11fa44d1 devices: Added suspendable.rs with the Suspendable trait.
Suspendable trait will be implemented for structs that will
snapshot/restore/sleep/wake, related to suspend/resume with snapshotting.
Added test generation for suspendable trait.

Bug=b:232437513
Test=cargo test

Change-Id: I071bad026c15ce346b6657871e7578528768bfc2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3842812
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
Reviewed-by: Steven Moreland <smoreland@google.com>
2022-10-05 21:22:34 +00:00
Ryan Neph
21c739216e gpu: remove virtio-gpu event trigger upon descriptor hang-up
Prevent runaway CPU usage and rapid power consumption when an event
source unexpectedly hangs-up by removing the descriptor from WaitContext.

BUG=b:250923109
TEST=CQ
TEST=glxgears in crosvm linux guest

Change-Id: Idbf4becd7c3195cb57c0e780c0957201c3d9ba9f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3928618
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-10-05 17:52:55 +00:00
Alexandre Courbot
e91b0fd604 serde_keyvalue: support for tuple and struct enums
Up to now only unit enums were supported. Add support for tuple and
struct enums, which can deserialize the following enum

    enum VideoMode {
        Fullscreen,
        Window(u32, u32),
        Remote { host: String },
    }

from the following inputs:

    mode=fullscreen
    mode=window[640,480]
    mode=remote[host=workstation]

This allows us to stop using flattened or dedicated enums for parsing and also
results in a less ambiguous syntax for these cases.

BUG=b:248993755
TEST=cargo test -p serde_keyvalue
TEST=cargo test

Change-Id: I142fc91fab19f4a977adec3ee36094e5f95363db
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3915040
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-10-05 07:03:48 +00:00
Alexandre Courbot
3573dfef69 serde_keyvalue: add support for sequences and sets
Sequences and sets can be supported by implementing the SeqAccess trait.
This opens up a few new scenarios for the command-line argument parser,
like support for tuples and flags collected into a set.

For instance, the following struct:

    struct Layout {
        resolution: (u16, u16),
        scanlines: Vec<u16>,
    }

Can be built from the following input:

    resolution=[320,200],scanlines=[0,64,128]

BUG=b:248993755
TEST=cargo test -p serde_keyvalue
TEST=cargo test

Change-Id: Ie8972807ed6b171f5b65f6d5b6d458a2cbf450a5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3915039
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-10-05 06:57:37 +00:00
Alexandre Courbot
aa81c96fd1 serde_keyvalue: make unquoted strings stop at the next bracket
In order to support tuples and enum variants, we need to add an extra
separator to specify the bounds of the tuple or enum. `[` and `]` are
good candidates since they are not often met in strings and are not
reserved by the shell, contrary to `(` and `)`.

BUG=b:248993755
TEST=cargo test -p serde_keyvalue
TEST=cargo test

Change-Id: I6743461f0cd3af0bce11e4978fa14776048170a5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3915038
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-10-05 06:55:56 +00:00
Keiichi Watanabe
0ea1263f71 vmm_vhost: Remove unnecessary cfg
BUG=none
TEST=`cargo check` in vmm_vhost succeeded without any warnings

Change-Id: I3adede28406a930bc54c5b0b0fd288fc42a4de89
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3932450
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-10-05 02:35:33 +00:00
Alexandre Courbot
7d894a9cd0 video: encoder: stop spamming the syslog with resource replacement messages
virtio-video typically expects that a resource will be imported once and
reused afterwards, but the encoder works with arbitrary buffers that it
needs to reimport every time. This results in a bunch of

    Replacing source resource with id X

and

    Replacing dest resource with id X

messages printed in the host's syslog every time a new buffer is
submitted.

Demote these messages to debug so they don't clutter the syslog.

TEST=arc.VideoEncodeAccel.h264_360p_i420_vm while looking at
/var/log/messages

Change-Id: I37f6d034aa91bf6c8ff3ee8cc0977cc3ef76975a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3924767
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-10-05 01:58:00 +00:00
Alexandre Courbot
967f8f8d13 devices: video: decoder: vaapi: fix build of VP8 decoding test
GuestResource and FramePlane recently received new members, but this was
not reflected in the test.

TEST=`cargo test --features "video-decoder,vaapi" -p devices -- vp8 --ignored` passes on Hatch.

Change-Id: I09ebd74fc79dcace5357a10c54ee06fbdd0dce77
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3932437
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
2022-10-05 01:39:19 +00:00
Alexandre Courbot
7186bc7bb8 base: event: remove obsolete comments to fix cargo doc
The platform event types are now private, and their methods are exposed
through the base Event type, so remove that comment that triggers a
warning with `cargo doc`.

TEST=`cargo doc` does not warn about this line.

Change-Id: I4577a194582dddaa2536541247807fc4cd1eea06
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3932438
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-10-05 01:39:19 +00:00
David Stevens
4c372205c6 vm_control: rework exposing VmMemory via viommu
Rework how to specify which VmMemoryRequests are exposed to passthrough
devices via virtio-iommu. Instead of specifying this on a per-request
basis, specify it at at a property of the VirtioDevice. This allows the
feature to work even for vhost-user devices.

BUG=b:243061269
TEST=presubmit

Change-Id: I3c381705f10ae0822896a4b9be760202cf79d925
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3865353
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-10-05 01:23:42 +00:00
recipe-roller
197f910384 Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (depot_tools) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8801186330408521921

depot_tools:
2c54a19bd0
  2c54a19 (jojwang@chromium.org)
      git_cache: print gsutil command.

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: Iec636adfc42691f2fa5466043b64283bbb610227
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3933684
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2022-10-05 01:14:12 +00:00
Keiichi Watanabe
07c9bdf352 vmm_vhost: sys: Align platform-specific code with style guide
Update /third_party/vmm_vhost/stc/sys.rs to align it with the code
organization described in
https://crosvm.dev/book/contributing/style_guide_platform_specific_code.html#code-organization

BUG=none
TEST=cargo check in /devices
TEST=cargo check --target=x86_64-pc-windows-gnu in /devices

Change-Id: I4f4035aadcd800335ceb035ab9645c2e6c6b0732
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3932449
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2022-10-05 00:39:19 +00:00
recipe-roller
eb1923b6ec Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (recipe_engine) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8801197654123450001

recipe_engine:
a88daaed2c
  a88daae (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from fed4f1c9c6cd to 4fd960efe802

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: I959d4ee349b0ebbb4701d8972eda1bf46b99d28f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3933683
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2022-10-04 22:14:37 +00:00
Pujun Lun
90a22c35bb gpu_display: remove release_event_device().
This function has no call site so we might remove it to simplify
the code.

BUG=b:213150276
TEST=presubmit

Change-Id: I7c74c91de224cbccecd307c7774a15145d12433e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3930937
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Pujun Lun <lunpujun@google.com>
2022-10-04 22:01:28 +00:00
Dennis Kempin
a2ecd1eb50 Modify builds via CROSVM_BUILD_VARIANT env var
We currently use cargo features to modify the build process, which
makes them non-additive and prevents us from moving towards
using --all-features in the future.

To change build.rs behavior to integrate with downstream build
systems (e.g. use pkg_config only on chromeos) we will use the newly
added CROSVM_BUILD_VARIANT env variable. Currently only
used by ChromeOS, but not limited to it.

For now, CROSVM_BUILD_VARIANT=chromeos will prevent the
embedding of seccomp policies.

BUG=b:244618505
TEST=Test in combination with https://crrev.com/c/3923813

Change-Id: I2bfe999b5252740d57c73c4a85d73bd343c8259e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3926325
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-10-04 21:23:00 +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
Vikram Auradkar
eb52905d36 prebuilts: Add helper crate to download prebuilts
BUG=b:246987526
TEST=presubmit

Change-Id: I1e54cf4a176d48c30340d6e7925733d6a1f4ce93
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3784337
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-10-04 20:22:47 +00:00
Frederick Mayle
d5f37f2982 base: rename platform specific event types to PlatformEvent
This isn't necessary, but it does aid readbility in my opinion.

BUG=b:231344063
TEST=cargo build && ./tools/dev_container ./tools/run_tests --target=host --build-target=mingw64 --build-only

Change-Id: Id486d66773a15f1a544f717aab508d5006be3553
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3864026
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2022-10-04 18:29:21 +00:00
Keita Suzuki
50181346e6 devices: vhost-user: block: Add hot-resizing feature in vhost-user block
Current implementation does not allow hot-resizing feature to be used in
vhost-user block devices because the backend device cannot notify the
frontend that the device configuration has changed. Fix this by adding
and establishing the backend to frontend vhost-user message connection to
the vhost-user block backend, send the HANDLE_CONFIG_CHANGE_MSG to the
frontend, and send interrupt to the guest kernel from the frontend
device when receiving the message.

BUG=b:191845881
TEST=cargo run devices -s /path/to/socket.sock --block ...
cargo run run --vhost-user-blk /path/to/vhost-sock,
cargo run disk resize 0 $SIZE /path/to/socket.sock

Change-Id: Ifab75d65c429dfcea5e632b899f014278a6e6750
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3859218
Commit-Queue: Keita Suzuki <suzukikeita@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Morg <morg@chromium.org>
2022-10-04 12:50:16 +00:00
Keita Suzuki
24630fe1e4 devices: vhost-user: allow backend device to send vhost-user message
Current implementation of vhost-user backend devices cannot directly
send vhost-user messages from the backend to the frontend since the
established connection is stored directly to `VhostShmemMapper`. This
limits the messages that could be sent to memory share-related messages.

To overcome this limitation, introduce struct `VhostBackendReqConnection`
which exposes the required backend to frontend requests and keeps track of
the underlying transport (struct `Slave`), and refactor `Slave` out from
current VhostShmemMapper.The state of the connection is managed using enum
`VhostBackendReqConnectionState`.

This patch also moves the timing of when `BackendReqHandler` is created in
the frontend to when `VhostUserProtocolFeatures::SLAVE_REQ` is negotiated
when creating VhostUserHandler.

BUG=b:191845881
TEST=run ./tools/run_tests

Change-Id: I90235a527d58067f73a509907b4cefc09516f562
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3856036
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-10-04 12:50:16 +00:00
Takaya Saeki
1be9cb2ef5 cros_async: refactor FromStr for ExecutorKind
FromStr trait is manually implemented for ExecutorKind, but
serd_keyvalue should be preferred. This commits refactors ExecutorKind
so that derives serd_keyvalue.

BUG=None
TEST=`crosvm --async-executor (epoll|uring) run ...` works
TEST=test passes on linux and windows

Change-Id: I5aafb6704c20a17120b30c290e1a4069dff9e5ce
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3924880
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Takaya Saeki <takayas@chromium.org>
2022-10-04 09:58:49 +00:00
Alexandre Courbot
753916a7d3 video: decoder: ffmpeg: handle INVALIDDATA in try_receive_frame()
The INVALIDDATA error can be returned by both try_send_packet() and
try_receive_frame(). In both cases we should just skip the invalid input
until the decoder can catch up with something that makes sense.

TEST=arc.VideoDecodeAccel.h264_vm unconditionally passes on Hatch

Change-Id: I4467b50c35fb36562a4b662d14071afcf02f1eb2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3924583
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Tatsuyuki Ishi <ishitatsuyuki@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-10-04 09:21:13 +00:00
Pattara Teerapong
b74bc68371 devices: virtio: snd: reset streams on error
Try to recover from a fatal error by resetting all streams instead of
exitting and putting the device into an unrecoverable state.

On error, all workers will be stopped and streams will be reset, then
workers will be restarted.

Flag `just_reset` will be set on all stream after a reset. This flag
let the invalid state transition to return Ok instead of Err. This let
the guest driver able to stop the stream even when the state is
desynced from device side. Once a valid state transition is made, the
flag is removed.

BUG=b:242021318
TEST=`restart cras` while playing music and recording audio in ARCVM
TEST=`restart cras` while calling `aplay` and `arecord` in termina
TEST=unit test

Change-Id: Ic329e2f82e572e6fcd69a6a197909b494d0360b5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3823181
Commit-Queue: Pattara Teerapong <pteerapong@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2022-10-04 08:10:51 +00:00
Pattara Teerapong
a79baab67b devices: virtio: snd: refactor run_worker
Refactor run_worker by extracting the worker running logic to
run_worker_once function.

BUG=b:242021318
TEST=play music and record audio in ARCVM

Change-Id: Idb2012b92fc113db9b8e16c066e10b72f66a7cdb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3889334
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Pattara Teerapong <pteerapong@chromium.org>
2022-10-04 08:10:51 +00:00
Keir Fraser
88674cade9 base: net: Validate descriptor passed to UnixSeqpacketListener
The existing file descriptor must refer to a listening socket.

TEST=cargo test, added a new unit test
BUG=b:238931628

Change-Id: Ia6bd5d6d30af69fb4b5fa00865f5528f19f569d9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3932714
Commit-Queue: Keir Fraser <keirf@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-10-04 06:53:48 +00:00
Ryuichiro Chiba
d1a1397542 docs: add a vsock document to the book
Add a document which describes how to use the vsock device.

BUG=b:235965219
TEST=`mdformat --wrap 100 --check docs/book/src/SUMMARY.md docs/book/src/devices/vsock.md`
TEST=`mdbook build`

Change-Id: I7c444e84f14f5505a159358f8f5008eb231333f6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3925333
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Commit-Queue: Ryuichiro Chiba <chibar@chromium.org>
2022-10-04 03:40:37 +00:00
Hikaru Nishida
129c75ccea base: unix: Add a wrapper for getppid
BUG=b:215093219
TEST=None

Change-Id: I89d6d163af5fd97ad36fb294e12a0729b1391035
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3865218
Commit-Queue: Hikaru Nishida <hikalium@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-10-04 03:28:02 +00:00
recipe-roller
b8b4aacfd8 Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (recipe_engine) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8801269377727468033

recipe_engine:
7ef0a02150
  7ef0a02 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 3ffe1bbbedd2 to 45c4b0ebf2c5

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: Ie1a42e41d66f776d65962924314a7efc658438d6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3931920
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2022-10-04 03:15:49 +00:00
Federico 'Morg' Pareschi
047e64ada4 devices: virtio: add syslog support to vvu console
BUG=b:233833487
TEST=tested on a DUT, verified guest logs appear on the host

Change-Id: I08b014655000ed7ccecd7ee34bac80e919395276
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3929990
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Morg <morg@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-10-04 02:44:08 +00:00
Pujun Lun
97a6a5fb31 gpu_display: use mpsc channels to avoid busy-waiting (2).
We were busy-waiting on atomic variables for the message loop
state of the WndProc thread. That is to make sure other threads
don't start posting messages to the WndProc thread until the
latter has created the message queue and is about to enter the
message loop. We can use mpsc channels instead. The WndProc
thread notifies other threads that it is ready by sending out its
thread ID.

BUG=b:243184256
TEST=tested in downstream

Change-Id: Ia2a675c083bb6aa9046dd9eab932a95fa06b8709
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3928133
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
2022-10-04 01:11:37 +00:00
Pujun Lun
203cef4216 gpu_display: use mpsc channels to avoid busy-waiting.
We were busy-waiting on atomic variables for surface creation
results. We can use mpsc channels to avoid that, which also
eliminates the need for enum CreateSurfaceResult since we just need
to send booleans.

BUG=b:243184256
TEST=tested in downstream

Change-Id: If4c39c797f9ca9edf3695e44689904066546759f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3928131
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
2022-10-04 01:10:19 +00:00
Daniel Verkamp
f29a992754 tree-wide: apply cargo fmt --nightly
Fix a few recently introduced formatting mismatches.

Change-Id: I1617683532d3cc45f67ec15408fbd4ec4c9d6bb2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3928132
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-10-03 21:39:26 +00:00
Keir Fraser
b83b553ff5 config: Do not forcibly disable balloon for protected VMs.
Android is enabling balloon protocol on pKVM. Blanket disablement
therefore no longer makes sense.

BUG=b:238931615
TEST=Tested downstream

Change-Id: Ie7a1d81e7f0753f708c992087184c52609ce72a0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3931545
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Keir Fraser <keirf@google.com>
2022-10-03 20:40:29 +00:00
Zihan Chen
646b6ea8fa crosvm-fuzz: Migrate crosvm-fuzz to cargo fuzz
Fuzzer targets can be ran with
cargo +nightly fuzz run --fuzz-dir crosvm-fuzz --features
upstream-fuzz <target>

This should enable us to move fuzzing to anywhere including
ClusterFuzz while maintain compatibility with cros infra.

TEST=`cargo fuzz` won't crash in first 30s,
`USE="asan fuzzer" emerge-hatch crosvm` builds,
`/build/hatch/usr/libexec/fuzzers/crosvm_qcow_fuzzer` won't
crash in first 30s
FIXED=b:245007212
BUG=b:244631591

Change-Id: I4b262ee1a6a90247dea96347c55a3849af793bec
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3905095
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-10-03 16:12:15 +00:00
Takaya Saeki
119ace0dca Reland "cros_async: add a command-line option to switch Executor
backend"

This reverts commit 03fdffb447.

Now b:249692652 is fixed by crrev.com/c/3842811/, we can bring back the
command-line option to switch Executor backend.

This commit is identical with the original CL, except it resolving the
conflict with ccrev.com/c/3841945/; it renames the old `use_uring` in a
test to the new name, `is_uring_stable`.
(cros_async/src/sys/unix/uring_source.rs:652)

BUG=b:249692652
BUG=b:239154263
TEST=confirmed crosvm --async-executor correcly switchs the Executor for
`crosvm --async-executor epoll (or uring) device gpu --socket
/tmp/gpu.sock` command. Used additional debug log to tell which
executoris running, which is not commited)
TEST=all tests passed

Change-Id: Iafb6921c1a7594a178712eb46792dc54d5d99f71
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3931568
Commit-Queue: Takaya Saeki <takayas@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-10-03 09:31:24 +00:00
Daniel Almeida
4303659947 media: libva: buffer_type: take ownership of ref_pic_list in the wrapper
It's not ergonomic for the calling code to pass in an array of
references.

Just take ownership of that array, as it's not going to be used again
when the calling code succeeds in creating the wrapper.

BUG=b:214478588
TEST="cargo test"

Change-Id: Ifbb78968ebb29b41fe2ccaa653f30a81fcb23427
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3783002
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-10-03 07:04:24 +00:00
recipe-roller
932c638c9c Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (recipe_engine) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8801544314229374897

recipe_engine:
a7f28f2e84
  a7f28f2 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from aa58dcd859c0 to 20c50aa39686

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: Ic9b84049d57f6f08b3ab0ddeb25f99d64dff82f8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3930628
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2022-10-01 02:27:29 +00:00
Frederick Mayle
c96a9f58a2 virtio: console: allow non-seekable input
pread only works for seekable files, so, for example, a pipe could not
be used. The non-async Console uses read calls and doesn't have this
issue.

There is a possibility of breaking something with this change. Suppose
crosvm was passed an input FD with the cursor at the end of a non-empty
file. Before the async console would read the full file from the
beginning, but now it would immediately EOF.

Another difference is that if the device is reset and then reactivated,
it will continue reading from where it left off instead of restarting at
the beginning of the input.

In both cases, I think the new behavior is better and additionally
matches the non-async console's behavior. The async console is
relatively new, so hopefully no one is depending on this part of its
behavior yet.

BUG=b:243198718
TEST=presubmit

Change-Id: I8e07e231d5def250eb5f42e9a4546fce721cc4bc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3842811
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-09-30 20:32:02 +00:00
Frederick Mayle
ef70f71256 cros_async: fix io at current file pos for io_uring
The `ReadAsync` and `WriteAsync` traits accept file offsets as an
`Option<u64>`. The epoll executor interprets `None` as "current file
position" and the io_uring executor interprets `None` as position zero.
This change updates the io_uring executor in favor of the epoll executor
behavior.

It is important to differentiate between position zero and "current file
position" when you don't know whether a file is seekable. For example,
console and serial devices should support both types of files as input.

BUG=b:243198718
TEST=presubmit --all

Change-Id: I01634e6bbdff352c0a6055419d0fafd10c0c40a6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3841945
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Steven Moreland <smoreland@google.com>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
2022-09-30 20:32:02 +00:00
recipe-roller
bae1bbe53d Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (depot_tools) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8801575770252046113

depot_tools:
1b8211ff13
  1b8211f (sokcevic@google.com)
      Restore git files that may be deleted by CIPD

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: Id8cc5c52c095d4c7132968b5b15786b8db4903d8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3930626
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2022-09-30 18:05:22 +00:00
Idan Raiter
7f4854237b rutabaga: Fix & cross-platform Vulkano memory import
A rebase appears to have caused memory imports to allocate external
memory instead of import it. For example, the input handle is not used.

- Fix the issue and make the import cross-platform. Linux / Windows use
  different extensions.

BUG=b:244622199
TEST=presubmit & downstream

Change-Id: Iaeefa37526d42e23be521a97c9ca038659fefb11
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3926104
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-09-30 17:18:14 +00:00
Colin Downs-Razouk
e0de18a6a5 base: timer: handle 0 interval explicitly
Make it official that setting a Timer's interval to 0 is the same as
setting it to None, meaning it will not be periodic. Fixed the windows
timer to behave this way again, and updated Timer docstring.

Also updated APIC timer to use None for interval which is clearer.

Bug: b:248612697
Test: tested with UserspaceIrqChip in dynamic tick mode
Change-Id: I57713c3ace345a8c64b9219a8e60f36c54a9481c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3925006
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
2022-09-30 16:50:22 +00:00
Keir Fraser
ba9c9e2e1e crosvm: Accept existing control socket file descriptor via command line
An existing file descriptor is specified by a path of the form
/proc/self/fd/<fd>. In this case crosvm will use this existing
listener socket directly, rather than trying to create a fresh one at
the specified path location.

This is useful for sandboxing crosvm in an environment in which it is
unable to create new filesystem entries.

BUG=b:238931628
TEST=Tested downstream

Change-Id: Ic6b24196bbe01960aedfe3f00ec69fd799e6ba91
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3928022
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Keir Fraser <keirf@google.com>
2022-09-30 08:51:01 +00:00
Tatsuyuki Ishi
8f2ccb3b50 virtio: video: Introduce FFmpeg encoder backend.
The FFmpeg backend is a software emulated video encoder device backend.
It can be used for testing, for developing guest kernel changes and
more.

The backend roughly mirrors how the FFmpeg decoder backend is
implemented right now, with the notable difference that it does not use
swscale as the de-facto input format is NV12 or YUV420 and the guest can
likely provide buffers in that format.

BUG=b:239897269
TEST=See testing instructions in the updated book document.

Change-Id: Iae9928bdad86729f890e738acfa58e21573a115b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3920263
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-09-30 05:36:51 +00:00
Tatsuyuki Ishi
d3e58b0275 virtio: video: Add support for converting AvPixelFormat -> Format.
For simplicity, use the same error type as Format -> AvPixelFormat.

This will be used and tested in the FFmpeg encoder backend.

BUG=b:239897269
TEST=cargo build --features "video-encoder,video-decoder,ffmpeg"

Change-Id: Ie5cf2a29379c0d52c78cee50ed6571f4859eee75
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3924881
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-09-30 05:36:51 +00:00
Tatsuyuki Ishi
244033437e virtio: video: Add an Error implementation for TryFromFormatError.
As a convention, error types should always implement Error, so we're
doing it here.

The traits are manually implemented as opposed to using ThisError; it
was simple enough, and using ThisError requires making the error type an
enum which makes it more verbose to construct.

BUG=None
TEST=cargo build --features "video-decoder,ffmpeg"

Change-Id: If94926c1b2f14295b29c877c2c70d361b4adee90
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3925332
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-09-30 05:36:51 +00:00
Takaya Saeki
03fdffb447 Revert "cros_async: add a command-line option to switch Executor backend"
This reverts commit cb6e74a094.

Reason for revert: This CL itself is fine, but b:249692652 reported
that virtio-console has been broken with epoll executor. cb6e74a0 also makes this broken virtio-console, which is confusing for users of virtio-console. cb6e74a0 can be merged again with the workaround for the default executor or after b:249692652 is fixed.

Original change's description:
> cros_async: add a command-line option to switch Executor backend
>
> Currently Executor internally decides which backend to use, such as
> FdExecutor vs URingExecutor on Linux. This makes it hard to test both
> FdExecutor and URingExecutor. In addition, we came across the uring
> instability issue (b:238965061), thus we need a way to explicitly switch
> the polling backend to mitigate the issue.
>
> This commit adds a command-line option to explicitly configure the
> Executor's polling backend.
>
> BUG=b:239154263
> TEST=confirmed crosvm --async-executor correcly switchs the Executor for
> `crosvm --async-executor epoll (or uring) device gpu --socket
> /tmp/gpu.sock` command. Used additional debug log to tell which executor
> is running, which is not commited
>
> Change-Id: Ib310d9edc8ab6005f1b7f210b03668b9a45fa73f
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3811014
> Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
> Commit-Queue: Takaya Saeki <takayas@chromium.org>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Reviewed-by: Noah Gold <nkgold@google.com>

Bug: b:239154263
Bug: b:249692652
Change-Id: I15f575597534cea6004bca4679245ef958bbe1e6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3925329
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-09-30 01:33:11 +00:00