Having both renderers running at the same time can work,
but not without changes. For now, allowing building both
at the same time.
BUG=b:181869105, b:182174209
Test: launch_cvd --gpu_mode=gfxstream
Test: launch_cvd --gpu_mode=virgl_renderer
Change-Id: Ib8a3fd4927401b9f7ebc4a4425a3ddba6621a3e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3092405
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
When nothing fails, output is ignored, but when something fails, you'd
want to look at the error messages.
BUG=None
TEST=time ./builder --vm ./run_tests
Change-Id: If6e73588b33714dea1e7f097a91c80f7c249be48
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3083207
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
The conversion code for KVM <-> hypervisor representation of the Local
APIC state used the unsafe mem::transmute() function to view an array of
i8 as u8 instead for use with the Rust endian conversion functions.
Casting between integer types of the same size with `as` is defined in
Rust as a "no-op" (the bitwise representation is preserved), just like
in C, so transmuting at the slice level is not needed. These can instead
be written as simple loops to avoid the unsafe code.
To ensure this does not regress code quality, I have compared the code
generated for the x86-64 release build. The kvm_lapic_state to
LapicState conversion compiles to identical code, and the reverse
compiles to slightly different code (the compiler decides to emit a loop
instead of unrolling the 64-element copy), but the conversion of each
element still compiles down to a pair of MOV instructions.
The corresponding unit test has also been updated to avoid transmute, as
it was unnecessary there - the individual array element can be cast with
the `as` operator rather than transmuting the whole array.
BUG=None
TEST=cargo test -p hypervisor
Change-Id: I7e792b5507235e5234afe114a1ca744931e047d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2947934
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Improve the log message for unexpected commands received on control
endpoints to include the type of command.
BUG=chromium:1231779
TEST=./test_all
Change-Id: I29963739bf5c5cb9fa427011fe5468a7378b67e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3083225
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Cathedral enthusiant Victor Hugo once said:
“Nothing else in the world ... not all the armies ... is so
powerful as an idea whose time has come.”
He was talking about republicanism vs. monarchy. My friends,
we are on the verge on a change quite possibly bigger than
that: seamless wayland windowing!!
The revolution started by the virtio_wl device is finally making
it's way to virtio_gpu, bringing best-in-class display
virtualization to a wider audience.
The overall approach is described here:
goto.google.com/virtio-gpu-wayland-context
At it's core, virtio-gpu wayland windowing uses the same mechanisms
that another virtio-gpu consumer (say gfxstream or virglrenderer)
uses to submit an opaque command stream to the host. A response
page is allocated by the guest where host commands are place
(gfxstream has been using this mechanism for years).
There are various tables to track the internal context state and
resources. A thread is spun up to poll the Wayland socket. The
asynchronous callback and upcoming virtio-gpu multiple timelines
feature is used to make 3D consumers (gfxstream, virglrenderer)
don't interfere with the Wayland signalling.
In the future, virtio-gpu may be further modifed to perform
multi-queue virtio in-case the single virtio-queue turns out to be
a bottleneck.
As always, look forward to your feedback & questions.
BUG=b:150239451
TEST=Launch Sublime text + weston-terminal with Sommelier changes
Copy + paste into VM window
Copy + paste out of VM window
Change-Id: Ifb74644cc71a561fd278700d91e4bc66d16107a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3055850
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Add an optional deadline to BlockingPool::shutdown. Any worker threads
that have not yet exited once the deadline expires will be detached.
This ensures that we don't end up blocking indefinitely while waiting
for worker threads to exit.
BUG=none
TEST=unit tests
Change-Id: I6d7e73e1c95a934a4fd80825a9d44187532408b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3058842
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
According to pci bridge spec, some registers are writable and should
be marked correctly.
BUG=b:185084350
TEST=Boot a guest with pcie root port
Change-Id: I501fa05cc9ea6b6ea02d5d8bcbb29ba291a4b49e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2954675
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Some pci capability register is writable, and guest could write it
and control it(like msix control and pcie cap control), let each
pci capability returns its writable bits, so guest could write the
value into config register.
BUG=b:185084350
TEST=Boot a guest with and without passthrough device
Change-Id: Ic98a569823c762e7165f83d29ee90d2ba762dead
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2954674
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This is used to finally make a "delay-rt" VM's RT VCPUs RT.
BUG=b:142777321
TEST="grep policy /proc/<pid of rt vcpu>/sched" to make sure RT vcpu
isn't RT until "make_rt".
Change-Id: I73177f8adadf3d1099c2b09871ee9d5feab82587
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2703225
Auto-Submit: Suleiman Souhlal <suleiman@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Suleiman Souhlal <suleiman@chromium.org>
This flag is intended to be used to delay making a VM's RT VCPUs
RT until "make_rt" is called, in order to avoid boot time
regressions with RT.
BUG=b:142777321
TEST="grep policy /proc/<pid of rt vcpu>/sched" to make sure RT vcpu
isn't RT until "make_rt".
Change-Id: I1b9132e11f0acc626434c60cecc2f4afe350961a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2703224
Auto-Submit: Suleiman Souhlal <suleiman@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Suleiman Souhlal <suleiman@chromium.org>
The ForceKeyFrame control is a button control, which means that it
doesn't have a value. This CL performs some minor cleanup and removes
the empty parentheses after the ForceKeyFrame CtrlVal as these are not
required.
BUG=None
TEST=tast run DUT arc.VideoEncodeAccel.h264_192p_i420_vm
Change-Id: Ic86eb92e097de46ce68ed71bfe24299e07f8b78e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3064155
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
/tmp is mounted as tmpfs, and tmpfs does not provide O_DIRECT capabilities. Try
using a ext4 file system.
BUG=b:190435784
TEST=time ./ci/builder --vm # boot_test_vm_odirect passes
Change-Id: I3f8245052ed06c703cc3aa320d300d5f21254e90
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3083206
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Stale balloon stats results can be returned from a stats request for the
following reasons:
* The initial stats buffer from the guest is posted to the
balloon_host_tube without a request.
* Balloon stats requests can fail because the balloon device isn't
completely set up yet; writing a stats request to the tube without
reading the response.
* Balloon stats requests can time out, returning an error. When the
balloon stats are eventually computed, they will be queued to the tube
without a read to consume them.
Possibly other reasons too.
This CL fixes this by adding an id to the balloon stats request. The id
is then returned with the computed stats. When consuming stats results
from the balloon_host_tube, we check that the ID is the one we expect,
if not, we keep reading from the tube until we do.
BUG=b:189282316
TEST=tast run dut multivm.Lifecycle.arc_host
Change-Id: I08e50196a45383b30c9e510b3bacbe32888aef80
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3056310
Auto-Submit: Charles William Dick <cwd@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Charles William Dick <cwd@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Hikaru Nishida <hikalium@chromium.org>
Instead of requiring crosvm to be checked out via the chromeos manifest
to access dependencies in the ChromeOS monorepo, this change adds
git submodules to third_party/.
The CI scripts and Cargo.toml are updated to use the new paths.
BUG=b:194336213
TEST=git clone --recursive https://chromium.googlesource.com/chromiumos/platform/crosvm
cd crosvm
cargo test
./test_all
./ci/kokoro/simulate_all
Change-Id: I9859d18176e21909ac3a140976fbd67cc14129bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3049003
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
We need to call Queue::ack_features to actually enable virtqueue specific
features like VIRTIO_RING_F_EVENT_IDX.
BUG=none
TEST=start a vm with a vhost-user block device
Change-Id: I82d04ad940850b53e17cfaf3ee5cdb4318190424
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3070721
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
VIRTIO_IOMMU_F_TOPOLOGY is not needed as DT/VIOT are the preferred
methods for vIOMMU discovery.
BUG=b:181736020
TEST=boot Linux kernel and verify passthru devices work properly with
iommu=on
Change-Id: I07b2924a8a903ccd5def817af6f7e74c8eb91162
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2976056
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Add generate_acpi() to traits PciDevice and VirtioDevice to allow each
device to generate its ACPI table elements. The default implementation
is to generate nothing.
BUG=b:181736020
TEST=boot Linux kernel
Change-Id: I9d8d2cb81d571e608a45e7fecb82c3f0922d0898
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2846423
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This wrappers allow for permissions and ownership changes that are less
sensitive to time-of-check-time-of-use vulnerabilities.
BUG=None
TEST=CQ passes
Change-Id: I6d5e4809a0b0113f3a95b0395d3cfb82431a3fd8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3049330
Auto-Submit: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Allen Webb <allenwebb@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This CL adds support for the VIRTIO_VIDEO_CONTROL_PREPEND_SPSPPS_TO_IDR
control to the virtio encoder. When this control is enabled SPS and PPS
NAL units are prepended to IDR frames, to improve the resilience of
encoded video streams.
Note: Currently the libvda backend always prepends SPS and PPS NAL
units to IDR frames. This behavior can not be disabled, so when
querying this control it will always be reported as enabled. Trying to
set the control to disabled will result in an error.
BUG=b:161495502
TEST=tast run DUT arc.VideoEncodeAccel.h264_192p_i420_vm
Cq-Depend: chromium:3058721
Change-Id: I2a53b635553cfbdbc483c4d678f124953721dba0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3060098
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Staessens <dstaessens@chromium.org>
and trigger the callback function for the buffer automatically
without relying on Drop. There is no drop guarantee in rust.
Moreover, the callback function is also async in the async code.
We cannot block wait in the callback function.
BUG=b:192912354
TEST=cargo test
Cq-Depend: chromium:3007841
Change-Id: I57902cdb0e083f61349f7124602e957ffa84b3c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3062163
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Woody Chow <woodychow@google.com>
On trogdor devices, fstatfs64 is not used. Instead, 32bit
fstatfs is used. We need to add both to all 32bit Arm
policy files which were originally determined to be
problematic.
This adds fstsatfs to all 32bit Arm policy files which
were modified for the original glibc security change.
Additionally, this commit sorts the syscalls lexicographically
if the policy file was already sorted.
BUG=chromium:1182687
TEST=CQ of http://crrev.com/c/2910526
Change-Id: I42eb12456625d400ee3422af08d56d648e3f9075
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3066144
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Jordan R Abrahams <ajordanr@google.com>
Updates path and includes the libraries in the test runner.
BUG=b:193243281,b:191509642
TEST=./run_tests passes and executes the new tests
Change-Id: If38126fa6bdf2a0a3dca5a79c6e4d76857617fd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3049671
Tested-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
This CL contains a 1:1 copy of the code from the platform2 repo.
The follow-up CL will integrate them with the crosvm build.
History of these files is available at:
267497a7f7/cros-fuzz267497a7f7/vm_tools/p9
This is a prerequisite for the externalization of crosvm.
BUG=b:191509642,b:193243281
TEST=None. This is dead code.
Change-Id: Ia25d9642f2de1febc83bcd48b4b81fcd805c7c1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3049670
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
This CL adds support for dynamically changing the peak bitrate in
addition to the target bitrate. This is done by adapting the
request_encoding_params_change function to use the new Bitrate data
structure, similar to the changes done in the Chrome
VideoEncodeAccelerator.
BUG=b:190336806,b:181514834
TEST=tast run DUT arc.VideoEncodeAccel.h264_192p_i420_vm
Cq-Depend: chromium:3032331
Change-Id: Id0fd3fa2b3d818c8880d4a02a96f84b218b19cef
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3033225
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
The feature was never finished (crbug.com/911799), but adds a
build-time dependency on the trunks proto in platform2.
BUG=b:193267897
TEST=cargo build with and without tpm feature
Change-Id: I7299ba0779bb04ebca6284cfd11873e99500c993
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3043491
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Previously, gaps(or holes) between component disk images were filled
with "GPT header". Rather than relying on arbitrary filler, it'd be nice
those gaps are filled with zeros.
BUG=b:190503456
TEST=cargo test
Change-Id: Ie7bcec5049ddc6c2e852bac6cd9bffc61f9d79d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3058836
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Commit-Queue: Jooyung Han <jooyung@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Jooyung Han <jooyung@google.com>
We don't need to support multi-file partition for composite disk images.
This will make the code simpler.
BUG=b:190503456
TEST=cargo test
Change-Id: I9e115ec73ad451ea46fe91c0d0a3c2e85aa1f010
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3058835
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jooyung Han <jooyung@google.com>
Auto-Submit: Jooyung Han <jooyung@google.com>
Introduce a new disk flag o_direct=true, which uses O_DIRECT for open.
Block access and memory buffer needs to be aligned to 512 bytes.
BUG=b:190435784
BUG=b:184204645
TEST=boot tests (boot_test_suspend_resume, boot_test_vm) keep running with o_direct=true.
Change-Id: I17888f8a6ef2a38baba2c17dbb0d7aa18b70dbfd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2821112
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
fs/worker.rs and fs/mod.rs were still using the old std::sync::Mutex
version instead of the crosvm-specific wrapper sync::Mutex
BUG=b:179636297
TEST=build crosvm and run shared-dir with virtio-fs
Change-Id: I773a885fd0ef35e25bc7a090f067d8a6f60636da
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3058837
Auto-Submit: Morg <morg@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Morg <morg@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
This CL adds support for the VIRTIO_VIDEO_CONTROL_BITRATE_PEAK control
to the crosvm encoder. This control allows configuring the peak bitrate
used when encoding a video. The peak bitrate is only used when the
bitrate mode is set to VBR (variable bitrate), and is ignored for CBR
(constant bitrate).
BUG=b:190336806,b:181514834
TEST=tast run DUT arc.VideoEncodeAccel.h264_192p_i420
Cq-Depend: chromium:2946469
Change-Id: Ie513b474f48f09a710a68c9f06111e0fc6627aa6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2944321
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
... by not holding locks while data is being copied around, but only
when the buffers are being allocated.
BUG=b:174713663
Change-Id: I558e14422eeff690c09f031f6c5564ee7de21e39
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2994806
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Jorge Moreira Broche <jemoreira@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
When VIRTIO_GPU_BLOB_FLAG_CREATE_GUEST_HANDLE is not set, the check
should not be applied. This is also more consistent with
GpuCommand::ResourceAttachBacking.
When VIRTIO_GPU_BLOB_FLAG_CREATE_GUEST_HANDLE is set, the check may not
be correct because upstream kernel made the limit configurable recently
https://patchwork.freedesktop.org/patch/438905/
It should be better to just remove the check and let the kernel does the
validation.
BUG=b:194314538
TEST=huge allocations
Change-Id: I536f44b257a96f7a52a0bc88fc2b63e0e2a701f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3059400
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
At crrev.com/c/2719245, we postpone sending the decoded frames until
receiving the buffer. However, we should also keep the order between
decoded frames and the flush complete event. This CL handles both
event response together to preserve the order.
BUG=b:168750131
BUG=b:192523692
TEST=android.mediav2.cts.CodecDecoderSurfaceTest#testFlushNative
TEST=android.media.cts.AdaptivePlaybackTest
Change-Id: I9184790c855c7d60455d1f71daad768200adc468
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3005181
Auto-Submit: Chih-Yu Huang <akahuang@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
This will prevent future auto merging conflicts related to the Error
struct being update.
BUG=b:194718591
TEST=cargo build
Change-Id: I6ccf1934103cfd6258beecc3ea8aad6ede4f94ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3053108
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Richard Zhang <rizhang@google.com>
`trunks/interface.proto` was renamed to `trunks/trunks_interface.proto`.
Rename `interface.proto` in crosvm accordingly.
BUG=b:193096536
TEST=./build_packages --board=amd64-generic crosvm
Cq-Depend: chromium:3013439
Change-Id: I9c2d1d70e81e60a73daa26fded92746591210ae7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3016218
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Yi Chou <yich@google.com>
Reviewed-by: John L Chen <zuan@chromium.org>
Reviewed-by: Leo Lai <cylai@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Domen Su <domen@google.com>
The `# ignored by ebuild` tag will remove the path to libcras_stub and
allows crosvm to be built with the actual libcras implementation.
This allows all other platforms to build without depending on
`third_party/adhd/cras/client/libcras`, which is a prerequisite for
externalizing crosvm.
An empty libcras_stub crate is provided to keep cargo happy in external
builds.
To build with cargo against libcras, the setup_cros_cargo.sh script
can be used.
BUG=b:191511078
TEST=Tests in crosvm and cros_sdk both pass:
$ ./test_all
$ cros_run_unit_tests --package=crosvm
Cq-Depend: chromium:2993483
Change-Id: I86aad23a86c78e580c1724fb311f870b25d6b09e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2988154
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
This CL adds support for the VIRTIO_VIDEO_CONTROL_BITRATE_MODE control
to the crosvm encoder. This control allows configuring the bitrate
mode used to encode a video.
Possible values are:
- VIRTIO_VIDEO_BITRATE_MODE_VBR (Variable bitrate)
- VIRTIO_VIDEO_BITRATE_MODE_CBR (Constant bitrate)
BUG=b:190336806,b:181514834
TEST=tast run DUT arc.VideoEncodeAccel.h264_192p_i420_vm
Cq-Depend: chromium:2946469
Change-Id: Ic8461e746884620cd426c1b562724e4120fe2129
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2944317
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
The VioSClient object has no reason to keep track of stream states,
except maybe to validate operations, but for that it can simply rely on
the sound server to do it for it.
BUG=b:174713663
Change-Id: Ia0bb1675f4cbfb2714feebe63aec8d75e54c1588
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2986401
Auto-Submit: Jorge Moreira Broche <jemoreira@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Might help a bit more when things stop working.
BUG=None
TEST=./integration_tests/run # and observe the error message.
thread 'boot_test_suspend_resume' panicked at 'called `Result::unwrap()`
on an `Err` value: InvalidFd', integration_tests/tests/fixture.rs:176:24
becomes
thread 'boot_test_suspend_resume' panicked at 'failed to initiailize
syslog: guess of fd for syslog connection was invalid',
integration_tests/tests/fixture.rs:177:13
Change-Id: Ife82b9e430d416a40cefced258e7f9bdc589bf73
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3055551
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
In adhd repository:
git log --pretty=email --patch-with-stat --reverse -- \
audio_streams/ | \
sed '/Change-Id/d' | sed 's/Reviewed-on/> Reviewed-on/g' | \
sed '/Tested-by/d' | sed '/Commit-Queue/d' | sed '/Signed-off-by/d' | \
sed '/Commit-Read/d' | sed '/Cq-Depend/d' | sed '/Auto-Submit/d' | \
sed 's/BUG/> BUG/g' | \
sed 's/TEST/> TEST/g' | \
sed 's/Reviewed-by/> Reviewed-by/g' > ~/cras-to-crosvm.patch
In crosvm repository:
- apply patch by
git am --committer-date-is-author-date < ~/cras-to-crosvm.patch
- squash and amend commits by
git rebase --interactive
Add the `audio_streams` crate
The `audio_streams` crate provides a basic interface for playing audio.
This will be used to enable playback to various audio subsystems such as
Alsa and cras. To start, an empty playback example `DummyStreamSource`
is provided.
> BUG=781398
> TEST=Included Dummy Stream tests and boot crosvm with ac97 using the
DummyStream for output.
> Reviewed-on: https://chromium-review.googlesource.com/1402264
> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
audio_streams: Servers can return a list of open FDs
To allow implementers of the StreamSource trait to be put in Linux
jails, add an optional function that returns a list of file descriptors
that need to be kept open when entering a jail.
> Reviewed-on: https://chromium-review.googlesource.com/1416052
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
audio_streams: Add audio capture interface
Add `CaptureBufferStream` which provides interface for audio capture.
This will be used to enable capture to various audio subsystems such as
Alsa and cras.
A null capture example `DummyCaptureStream` is provided.
> BUG=chromium:932268
> TEST=Unit tests
> TEST=Apply full patch set and run
$ cras_test capture -f /tmp/res.raw
to test capture functionality
> Reviewed-on: https://chromium-review.googlesource.com/1530354
> Reviewed-by: Dylan Reid <dgreid@chromium.org>
audio_streams: add direct read and write functions for audio buffers
These functions are needed so that clients of audio_streams can make use
of the buffer's internal slices directly. Before, the only way to access
internal buffers was indirectly via the client passing in a slice of its
own, which would require an extra copy when the client is using volatile
memory sources which can not be safely turned into slices.
> BUG=chromium:938767
> TEST=build crosvm with "eliminate mut from non-mut references"
> Reviewed-on: https://chromium-review.googlesource.com/1639621
> Reviewed-by: Dylan Reid <dgreid@chromium.org>
audio_streams: Updated trait object syntax
Trait objects without `dyn` generate warnings with newer compiler
versions.
> Reviewed-on: https://chromium-review.googlesource.com/1714273
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Add blueprint files for crosvm dependencies.
Test: m libaudio_streams
Test: m libcras_sys
Test: m liblibcras
Bug: 140201589
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/1789920
> Reviewed-by: Dylan Reid <dgreid@chromium.org>
> Reviewed-by: Ivan Lozano <ivanlozano@google.com>
CRAS: libcras: Support more output formats
Add support for U8, S24_LE, and S32_LE audio to libcras and cras_tests.
24bit samples are stored in 4 bytes of space, not 3.
> BUG=chromium:1010667
> TEST=sox -n -r 48000 -c 2 -b 8 -e unsigned-integer output.raw synth 3 sine 100 &&
cras_tests playback -f U8 output.raw
> TEST=sox -n -r 48000 -c 2 -b 32 output.raw synth 3 sine 100 &&
cras_tests playback -f S32_LE output.raw
> TEST=sox -n -r 48000 -c 2 -b 24 output.raw synth 3 sine 100 &&
sox -t s24 -r 48000 -c 2 output.raw -t s32 output_24.raw vol 0.00390625 &&
cras_tests playback -f S24_LE output_24.raw
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/1856646
> Reviewed-by: Fletcher Woodruff <fletcherw@chromium.org>
CRAS: cras_tests: Restructure arguments
In preparation for adding control functionality to cras_tests,
restructure Command by making AudioOptions a parameter of the Command
enum, e.g Command::Capture(AudioOptions). This way, a control command
can be later added as Command::Control(ControlOptions).
> BUG=chromium:1008990
> TEST=cargo test
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/1865832
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
CRAS: audio_streams: Limits length in copy_cb
Limits the size of index for accessing internal buffer in PlaybackBuffer
and CaptureBuffer to prevent index-out-of-range panic.
> BUG=b:146471328
> TEST=Build and test audio capture with stresstestapp
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/1980593
> Reviewed-by: Yu-Hsuan Hsu <yuhsuan@chromium.org>
CRAS: cras_tests: add WAVE playback and capture
Create structs WavSource and WavSink which adapt hound::WavReader and
hound::WavWriter to implement the Read and Write traits, and use these
to implement WAVE playback and capture.
Dynamically select which source type to use based on the input/output
file name.
The audio is limited to integer sample formats, but supports all bit
depths that CRAS supports. S24_LE samples are upsampled to S32_LE due
to a quirk of the encoder used.
> BUG=chromium:1008990
> TEST="sox -n -r 48000 -b 16 output.wav synth 5 sine 330 &&
cras_tests playback output.wav", check that sine wave is played
accurately.
> TEST="cras_tests capture output.wav && aplay output.wav",
check that data is recorded properly.
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/1832584
> Reviewed-by: Dylan Reid <dgreid@chromium.org>
CRAS: move shm_streams into audio_streams
Move the shm_streams trait into the audio_streams crate so that systems
that do not use CRAS can create audio backends implementing the shm_streams
interface.
Remove cras_types as all code in it has moved to cras-sys or
audio_streams.
Add a StreamEffect struct to audio_streams containing one effect, echo
cancellation, as well as a conversion to CRAS_STREAM_EFFECT in cras-sys.
> BUG=chromium:968724
> TEST=cargo test
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2040904
> Reviewed-by: Dylan Reid <dgreid@chromium.org>
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
CRAS: Add .gitignore
Add .gitignore for audio_streams, cras-sys and libcras to ignore Cargo.lock as
these are rust libraries not end products.
Doc: https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
> BUG=None
> TEST=cargo build
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2100454
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
> Reviewed-by: Dylan Reid <dgreid@chromium.org>
CRAS: Implement FromStr and Default for StreamEffect
1. Implement FromStr and Default traits for StreamEffect.
> BUG=b:149174845
> TEST=cargo test
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2053654
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
CRAS: Change new_stream trait of ShmStreamSource
1. Allow users to create streams with multiple effects by a slice of
StreamEffect in ShmStreamSource::new_stream.
2. Implement FromIterator<&StreamEffect> for CRAS_STREAM_EFFECT.
3. Update CrasClient new_stream API.
> BUG=b:149174845
> TEST=cargo build
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2095644
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Allows audio_streams errors to be passed across threads
Instead of returning Box<dyn Error>, we returns Error that impls Send +
Sync, so that these errors can be passed across threads. It's needed for
collecting the errors when we create streams in child threads.
> BUG=b:149437381
> TEST=emerge-{BOARD} cras_tests
> TEST=cargo test in audio_streams
> TEST=cargo test in libcras
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2215772
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Remove explicit lifetimes that can be elided
Fixes crosvm `cargo clippy` errors:
error: explicit lifetimes given in parameter types where they could
be elided (or replaced with `'_` if needed by type declaration)
> BUG=None
> TEST=crosvm bin/clippy
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2225151
> Reviewed-by: Dylan Reid <dgreid@chromium.org>
audio_streams: add num_channels in ShmStream trait
Add num_channels() to allow to get the channel count of a stream.
> BUG=b:157433024
> TEST=cargo build
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2259312
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
audio_streams: Change timer start time in null_consumption_rate
```
let start = Instant::now();
```
should be moved to earlier than
```
let mut stream_source = NullShmStreamSource::new();
```
> BUG=chromium:1106557
> TEST=cargo test
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2303415
> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
audio_stream: Suppress cargo clippy warnings
Suppress `cargo::type_complexity` and `clippy::too_many_arguments` warnings
which are acceptable.
Also, fixed a trivial clippy warnings.
> BUG=chromium:1112251
> TEST=`cargo clippy` passes
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2331964
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
audio_streams: change frame_rate to u32 in ShmStream and ShmStreamSource
1. Change frame_rate from usize to u32 for
* StreamSource::new_playback_stream
* StreamSource::new_capture_stream
* ShmStreamSource::new_stream
* DummyStream::new
* DummyCaptureStream::new
* NullShmStream::new
* MockShmStream::new
* CrasClient::create_stream
* CrasClient::new_pinned_playback_stream
* CrasClient::new_pinned_capture_stream
* CrasStream::try_new
* cras_audio_format_packed::new
* WavSource
* WavSink::try_new
The frame_rate may supports up to 96000 khz
and therefore the correct data type should be u32.
2. Add frame_rate() to ShmStream trait allow to get the sample rate of a stream.
3. Add sample_rate to
* CrasShmStream
* CrasShmStream::try_new
4. Fix some clippy issues in cras_tests
> BUG=b:168082107
> TEST=cargo build && cargo test
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2434114
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
CRAS: fix clippy lint in audio_streams
Pass SampleFormat by value to sample_bytes() function, since it
implements Copy and is small.
> BUG=None
> TEST=None
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2541844
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
audio_stream: Replace the use of Dummy* to Noop*
Ableist language like dummy should be removed.
Adding a NoopStreamControl that is a duplication of DummyStreamControl
for future migration so we don't break crosvm's dependency.
Will have a follow-up CL to remove DummyStreamControl once all existing
dependencies are removed.
> BUG=b:167649426
> TEST=./build_packages --autosetgov --board=hatch adhd audio_streams \
libcras crosvm
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2547616
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
audio_streams: Cache elapsed Duration in unit tests
Cache start_time.elapsed() with `elapsed` to prevent
"overflow when subtracting duration" error.
> BUG=chromium:1161663
> TEST=`cargo test`
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2612305
> Reviewed-by: Cheng-Yi Chiang <cychiang@chromium.org>
cras: Remove Dummy* for inclusive language
Ableist language like dummy should be removed.
NoopStreamControl has been added to replace and deprecate DummyStreamControl.
Remove DummyStreamControl as all existing dependencies are removed.
> BUG=b:167649426
> TEST=./build_packages --autosetgov --board=hatch adhd audio_streams \
libcras crosvm && src/platform/dev/contrib/search_blocked_words.sh
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2739020
> Reviewed-by: Yu-Hsuan Hsu <yuhsuan@chromium.org>
resolve rust clippy 1.50 issues
The issue was with unnecessary lifetimes and nested match statements
that resolved quite cleanly in this change.
> BUG=b:179277332
> TEST=cargo clippy with rustc 1.50+
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2757729
> Reviewed-by: Dylan Reid <dgreid@chromium.org>
audio_streams: Add next_[playback/capture]_buffer_async
with async sleep.
> BUG=b:179757101
> TEST=cargo test
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/2960197
> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
audio_streams: Add executor arg to next_[playback/capture]_buffer_async
cras stream will need an executor to initialize its AsyncAudioSocket
> BUG=b:179757101
> TEST=cargo test
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/adhd/+/3005176
> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
BUG=b:191511078
TEST=cargo build
Change-Id: I2832583b29722deee2ece210b2e7e821768c3fd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3045578
Auto-Submit: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Should probably be handled by the argument help utility level but at
least make existing help message indented consistently.
BUG=None
TEST=crosvm run --help
Change-Id: I14d39a1f69a28910111a73a0401fbe07e211f6d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3038007
Auto-Submit: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>