The dummy backends behave the same regardless of the codec, so factorize
their declaration as well as their implementation of VideoDecoderBackend
to avoid duplicate code.
BUG=b:214478588
TEST=cargo test --features vaapi -p cros-codecs
Change-Id: Ibaa694b885c1ccf969aed3a0cb167a254e0eaab5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4060492
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.corp-partner.google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
No need to reinvent the wheel - the standard library provides a
reasonable equivalent of this type.
BUG=None
TEST=tools/presubmit
Change-Id: Id7abada4c955a6e87bca735e7879dab2a38cb33c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4062051
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Fixes compiler warning:
warning: patch for the non root package will be ignored, specify patch
at the workspace root:
[...]/src/platform/crosvm/swap/Cargo.toml
[...]/src/platform/crosvm/Cargo.toml
The top-level crosvm/Cargo.toml already specifies the patch, so we can
just remove it from swap/Cargo.toml
BUG=None
TEST=cargo build --features=swap
TEST=emerge-brya crosvm
Change-Id: Icdb9c7745478552ac01f07bdd5c799feff3f69a0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4062050
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Testing tap functionality requires root privileges. The crosvmdev
user of our dev_container is set up for passwordless sudo, so we can
seamlessly execute these tests via sudo.
For running on the developer workstation directly, this will prompt
for a password, which is disruptive to workflows. The --no-root
option can be used to prevent this and skip the tests in question.
BUG=None
TEST=tools/run_tests [--no-root]
Change-Id: I731887837affceb76152466f0006c4ee51a19234
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4063237
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
In the vsock code, we use a mutex to protect our connections `HashMap`
so that we can have access to them from multiple async tasks. We were
using a regular synchronous mutex for this, which could cause the async
tasks to block on these mutexes, possibly leading to blocking up the
executor and deadlocking vsock.
We haven't observed any bugs or deadlocks that are directly attributable
to this; it's likely that we are managing to avoid this by not holding
the lock over await points. We should still fix this for correctness, as
we have no way to otherwise enforce that future changes should uphold
the current guarantees.
BUG: b:247548758
TEST: Built and ran crosvm downstream.
Change-Id: I8928514be491f111887fbf1adac7a3f8b38219dd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4062047
Commit-Queue: Richard Otap <rotap@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
When receiving guest data, we wait on an event after writing them out to
the named pipe so that we know that the write has completed. This resets
the event. Then we call `GetOverlappedResult` with `bWait` set. While
this does behave correctly because `GetOverlappedResult` checks the
internal status of the request before waiting, there's no need to have
the event get reset here.
BUG: b:255635953
TEST: Built and ran crosvm downstream.
Change-Id: Ic031821dda1e7ae696dfafa812afa4c0b6cff0ec
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4062049
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Richard Otap <rotap@google.com>
The DLL notification tests were flaky because we were trying to test an
operation that is somewhat asynchronous from the actions of the test
itself. We would see failures at a pretty low rate because the DLL we
were trying to observe unloads for would not necessarily unload
immediately, or within a short timeout of when we would expect it to
unload.
This was exacerbated by the test using the same DLL for the load and
unload portions of the test. This would add another layer of
nondeterminism about what the state of the test runner process was which
we were trying to deterministically observe.
We can fix this by doing two things:
1. Introduce some synchronization to allow us to wrangle the
asynchronous nature of the test.
2. Use different DLLs for the load and unload tests.
By implementing these changes, the flakiness doesn't appear anymore
after running the test a few thousand times.
BUG: b:229288169
TEST: cargo test --package win_util --lib -- dll_notification
Change-Id: Id6aa216ed91bd9e13523118bcee1b352d511a883
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4062048
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Richard Otap <rotap@google.com>
Currently, build.rs doesn't handle errors from the seccomp compiler
correctly, and build.rs doesn't fail. Due to that, when you have a bug
in seccomp policy files, `cargo build` fails in later stages with
misleading error messages complaining about missing file.
With this change, build.rs fails when the seccomp compiler fails. Since
the build phase fails correctly, cargo shows the stderr from the seccomp
compiler correctly.
BUG=None
TEST=build succeeds
Change-Id: I5645ffabd5ece8888053ac62014bb8ca22d3b9bb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4054809
Commit-Queue: Takaya Saeki <takayas@chromium.org>
Reviewed-by: Zihan Chen <zihanchen@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Parsing a quoted string as the last element of a sequence would fail
since ']' was not recognized as a separator. Fix this and factorize the
code recognizing separators into a single function to prevent this kind
of issue from happening again in the future.
BUG=None
TEST=cargo test -p serde_keyvalue
Change-Id: I1367da843787c40fb6c15a615d7cd036bddd1381
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4054812
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
We will not be using mold and will explore other linker alternatives.
Even though the package was installed, it was not actually used
anywhere. So it's safe to remove.
BUG=None
TEST=None
Change-Id: Iffcd6704d22b6b09d17ce8da8f44253b8ccdf9da
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4062836
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
Auto-Submit: Dennis Kempin <denniskempin@google.com>
crosvm could not compile without this patch if feature `gpu` is not
turned on.
TEST=tools/presubmit
BUG=b:260607247
Change-Id: Idcaad60862d56d8e0ebb47b3bbec42da757e3162
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4060240
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Idan Raiter <idanr@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This interprets the p_paddr field of ELF program headers as an offset
into physical RAM on aarch64 systems, which is a change in behavior. We
pass an offset of 0 on x86-64, so it makes no difference there.
BUG=b:254601048
BUG=b:255697205
TEST=cargo test -p kernel_loader
Change-Id: I9ebaa285c4cde1f70cb7752e91ff4520e06dc82f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4035738
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Everything has been migrated to argh and serde_keyvalue, so we can
remove the old argument parsing code now.
The parse_hex_or_decimal() function is still used in a few places in
config.rs, so move it there for now.
BUG=b:255223604
TEST=cargo build
Change-Id: Ic2d66a7fac7c3ff00b9521c56a719dd23883284b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4049038
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
This removes the last caller of parse_key_value_options().
BUG=b:255223604
TEST=cargo test
Change-Id: Ia17eb320094ee3d46f0db238f2077163e257b7f8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4049037
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
We need to keep stderr FD when spawning processes. Otherwise, log
messages won't be emitted to stderr.
This affects the cases where we spawn device processes such as:
* "crosvm run" without --disable-sandbox,
* virtiofs device, which create its own jail,
* "crosvm devices", which spawn sub processes
BUG=none
TEST=check log messages in virtio-{block,fs} are shown in stderr
Change-Id: If60845d73290a42c863e6c6f4e75869644f659d0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4054212
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Migrate the --stub-pci-device parameters to serde_keyvalue from
parse_key_value_options().
The deprecated `multifunction` option is dropped, as the only caller was
crosvm-direct.sh and it has since been fixed.
BUG=b:255223604
TEST=cargo test -p devices stub
TEST=Run crosvm with --stub-pci-device options; lspci
Change-Id: I3ed0cf52179020bcd1665540dc9bc9e66e17b85e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4049030
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
BufferMapping could previsouly hold a BufferHandle. Make it more generic
so that it can hold types that can convert themselves to a BufferHandle
instead.
This also simplifies the type considerably, as it only takes a single type
parameter instead of two.
BUG=b:214478588
TEST="cargo build --features=video-decoder,vaapi; Fluster still works"
Change-Id: Idcaf4d0a074609e3155daa596e262810149fe037
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4046944
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Move VaapiDecoderSession closer to its impl for tidiness. Also, if
BufferMapping - which is currently in the middle of them - is extended,
we do not want to widen this gap even further.
BUG=b:214478588
TEST="cargo build --features=video-decoder,vaapi"
Change-Id: I1045e04a313e5d7ee62b313f42923333192ac722
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4046943
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Now that serde_keyvalue is capable of parsing vectors and
sub-structs, we are making the following pattern the official way
of providing display parameters:
--gpu backend=3d,displays=[[mode=windowed[800,600]],\
[mode=borderless_full_screen]]
The reasons for this change are:
(1) We will likely use this syntax for other CLI options as well.
(2) We only support one single virtual GPU as of today, but
technically we could support multiple. When we add that
support, there is no ambiguity as to which display is connected
to which GPU with this syntax.
For backwards compatibility, we will preserve the following ways to
provide display parameters:
(1) --gpu width=800,height=600 (which implies windowed mode)
(2) --gpu-display mode=windowed,width=800,height=600 \
--gpu-display mode=borderless_full_screen
BUG=b:254284360
TEST=presubmit
Change-Id: I7f0078b7cf7554c1e93882afce47a4a2a3170a78
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3984545
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
The current syntax is:
--gpu-display horizontal-dpi=100,vertical-dpi=200
We would like to change that to:
--gpu-display dpi=[100,200]
We will keep the backward compatibility for now, but the caller
should not use both of syntax at the same time.
FixedGpuDisplayParameters is introduced for backward compatibility
support, and it will be removed once the old syntax is deprecated.
BUG=b:260101753
TEST=presubmit
Change-Id: I66a31c448ecc1eba60f6d1cbcbc753315c6c1df6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4049340
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Pujun Lun <lunpujun@google.com>
Recently, common_device.policy added clone3. It is included by most
devices through include, but the video device missed it since it doesn't
include common_device.policy due to some policy override.
This commit adds clone3 to the policy of the video device to fix that
problem. With this fix, the video device successfully runs in the
sandbox on newer kernels.
BUG=None
TEST=a vm with a video device launches with the sandbox enabled
Change-Id: Idc2dee824e863f3ee43cfd6ce76656e36d6200c0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4053447
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Takaya Saeki <takayas@chromium.org>
Document the format and rules for specifying command-line options, and
add a section on how configuration files can also be used.
BUG=b:218223240
TEST=mdbook build
Change-Id: Ieec40315b7ae8212c6a5b60280440abc9a5e92e6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4040820
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
To prepare adding more fixtures such as logic for vhost-user device,
move the existing code to create a VM to a separate module.
Specifically, move the all code in e2e_tests/tests/fixture/mod.rs into
e2e_tests/tests/fixture/vm.rs.
BUG=b:243127910
TEST=./e2e_tests/run
Change-Id: I23e6e5db35ce09b5003f37a9a44f9fda8f502809
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4028760
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
This will allow us to identify virtiofs threads in tracing tools such
as perfetto.
BUG=b:260038313
TEST=run arcvm
Change-Id: I198b599a3f710742fc549ab6ae376ad4cb661fc0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4045667
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Rename each virtio device's worker thread name to the form of
"v_{device type}".
e.g. "v_blk" for virtio-blk
This change allows us to embed more information in the thread names
whose length must not exceed 15. For example, we can embed ID for each
block device thread so we can distinguish threads in `ps` and tracing
tools.
BUG=b:260038313
TEST=CQ
Change-Id: I039421c46e9b28f2cb82f7fc644929ba325e895a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4045666
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
When vhost-user front-end send a vhost-user message via Unix domain
socket, a message header is sent first with optional attached files.
Then, a message body is sent as a separate packet if necessary.
However, the existing implementation blocks only before a
message header coming and assumed that the message body is ready when
the header comes. So, there was a race and `handle_request` could return
`EAGAIN`.
This CL splits SlaveReqHandler::handle_request() into recv_header() and
process_message() so a caller can wait between the header and the
additional payload.
On VVU, we shouldn't wait before receiving the payloads because the
proxy device forwards a header and its message body together. So we
check the protocol in needs_wait_for_payload().
BUG=b:237891754
TEST=Run vhost-user block on Linux
TEST=Run vhost-user block on Windows
TEST=Run VVU block on Linux
Change-Id: I35af3eb0e706cb005bf697397698e01e272b0704
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3863050
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
This is a shorter and more explicit name, and is also what qemu uses for
the same parameter.
Since this is a positional argument, it doesn't affect command-line
argument handling, only the (currently unused) configuration files.
BUG=b:255223604
TEST=None
Change-Id: Ice01335a690550e5afd05b93c6c968b0d0859f32
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4044726
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
The rule for crosvm options is that they should be specified in
kebab-case. Switch the disk options to that format, while also keeping
camel_case aliases for compatibility.
BUG=b:255223604
TEST=--block option works with both block-size and block_size
parameters.
TEST=cargo test -p devices block::tests::params_from_key_values
TEST=cargo test -p e2e_tests boot_test_vm
Change-Id: Ie095565ca4b27d59ed86ddc0613419e45749b3fa
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4040818
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Improve the comment on why a fence is necessary in the middle of
`Queue::peek` so that it gets clearer.
BUG=b:258630435
TEST=`./tools/dev_container ./tools/presubmit` passed
Change-Id: I63f80975e6d04665948a6036998e7ed6e24be64c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4045661
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
The documentation for the --net command-line option was not properly
formatting and had a few trailing words. Also add an OR keyword to
clarify that the keys are mutually exclusive.
BUG=b:255223604
TEST=crosvm run --help
Change-Id: Ib0980c3294828eeccf00e3609b21d829c5da9fb1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4040819
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>