Fixes a clippy warning with Rust 1.60 - the variables can be initialized
right away rather than having a separate `let` without an assignment.
BUG=b:239075544
TEST=tools/clippy
Change-Id: Ifd1db84ba5b4bf45c5e5efebcddf2e35a760a071
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3790037
Tested-by: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Fix `crosvm devive` command for gpu and fs crases due to double-init of
syslog.
BUG=b:240349875
TEST=`crosvm device gpu` and `fs` don't crash after the fix, and they still can write logs
Change-Id: I8ea35132de66841375366595bd0bb51a8f83f7b1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3782448
Commit-Queue: Takaya Saeki <takayas@chromium.org>
Tested-by: Takaya Saeki <takayas@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Syslog also needs to be initialized here, otherwise these commands won't
be able to use the log macros.
BUG=None
TEST=crosvm devices command is able to log.
Change-Id: I727fd91dc24226e67dd65502a32823bf78f3b4ab
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3780063
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Recent OpenSSL versions have added deprecation warnings for functions
used by libtpm2, which breaks the default build that uses -Werror. Force
it off for our build.rs file so we can keep working until libtpm2 is
updated.
BUG=None
TEST=tools/clippy
Change-Id: I874df1393c6a9b5033e90e8182e6ba694d48e1df
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3790036
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
crosvm is switching the import style to use one import per line.
While more verbose, this will greatly reduce the occurence of merge
conflicts going forward.
Note: This is using a nightly feature of rustfmt. So it's a one-off
re-format only. We are considering adding a nightly toolchain to
enable the feature permanently.
BUG=b:239937122
TEST=CQ
Change-Id: Id2dd4dbdc0adfc4f8f3dd1d09da1daafa2a39992
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3784345
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Balloon support can not be compiled out, and don't need to be
disabled at run time.
BUG=b:235887451
TEST=Guest has balloon device by default, does not have balloon
device when disabled. Ballooning via cli functions by default,
return not supported when running vm has ballooning compiled out.
Change-Id: I737851496fe4c14cdbb69c48e6edf1ca9186c15a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3786928
Tested-by: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zihan Chen <zihanchen@google.com>
The test_target.py script is not longer directly executable
but the test runner would still be pointed at it when used
for iterative development.
BUG=None
TEST=./tools/test_target set vm:aarch64 && source .envrc && cargo test
Change-Id: Id179fe83cd1f449d266576340a2f6f46e63c2878
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3784340
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
When the shared memory feature is enabled, there is a bug in how the
driver handles vfds without an associated pfn. Disable the feature bit
until the bug is fixed.
BUG=b:213532601
TEST=crostini.CopyPaste.wayland_to_x11_buster_stable
Change-Id: Ic5f68e167e8ee8f4c990d0c4d73149e60b3ce908
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3789166
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: David Stevens <stevensd@chromium.org>
We want the ffmpeg crate to be independent of crosvm - remove a
dependency to base by adding a dedicated trait for types that can be
used as sources to a ffmpeg buffer.
BUG=b:169295147
TEST=v4l2r's simple_decoder can decode a H.264 stream.
Change-Id: I2ae6c2678a6a672746e6fc11a70dee692986db69
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3782032
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
This method's result is always used as a dyn AsRawDescriptor, so it's
more flexible to directly implement AsRawDescriptor here instead of
restricting the return type to Event.
BUG=None
TEST=cargo test --features "video-decoder,ffmpeg" -p devices video
Change-Id: Ib911ba671f819106169cde049fda6cb12ebaa4b6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3782034
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
The use of AV_CODEC_CAP_DR1 is not obvious from its name alone, so add a
comment about what we are doing here.
BUG=None
TEST=cargo build --features "video-decoder,ffmpeg"
Change-Id: Ib1d38c878ce761fafa85e57076e6d429f63495b5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3782033
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Initializing gralloc may spawn threads, so it needs to be done after
sandboxing the wl device. Initializing gralloc requires expanding the
wl device's sandbox. Rather than trying to maintain a new dedicated
minijail configuration for wl, reuse the gpu's configuration. This
should be sufficient, since virglrenderer has to open minigbm within the
sandboxed gpu process.
BUG=None
TEST=ARCVM and crostini GUI on volteer, zorc-arc-r, grunt-arc-r
Change-Id: I291fb59c665a8ba65058a6f55dee959c839bb43c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3787936
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Tested-by: David Stevens <stevensd@chromium.org>
We only need to enforce a lifetime to the data source of the packet ; we
are not interested in its type. Replace it by () and remove that generic
parameter.
BUG=b:169295147
TEST=cargo build --features "video-decoder,ffmpeg"
Change-Id: Ibd9e976cab9dcc9cf0a44487580eb067211cc9b8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3782031
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
The GPU can be heavy on fd usage (fences, dma-bufs, eventfd and
shmemfds per context, etc). Increase the limit.
BUG=b:207515789, b:237224199, b:240092999
TEST=cts-tradefed run cts -m CtsMediaTestCases -t android.media.cts.DecodeAccuracyTest
Change-Id: Icae6652d173614a809a5fc27b2c85910d57e6bb3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3788603
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Tested-by: Rob Clark <robdclark@chromium.org>
Non-trivial rolls are sent to OWNERS, which may not be familiar
with the changes.
BUG=b:239081770
TEST=./infra/recipes.py test run
Change-Id: I55c4c8e9a81812c7238c36e95edd512072df9491
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3785280
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Loading 32-bit images is needed for kvm-unit-tests.
BUG=b:233317135
TEST=boots, new unit tests
Change-Id: I6ba63255e0e2993f3735ef81489f64dbd0bb6374
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764465
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Steven Richman <srichman@google.com>
Tested-by: Steven Richman <srichman@google.com>
Commit-Queue: Steven Richman <srichman@google.com>
Being able to build an AvCodec means that the returned name will be
valid - unless there is a bug in libavcodec itself. Simplify the method
returning the codec's name to not return an Option, but instead a string
representing an invalid codec in the unlikely case we actually get one.
BUG=None
TEST=cargo build --features "video-decoder,ffmpeg"
Change-Id: Ic2c1b5db5391c421ae6f78faabcfe3197090ce17
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3782030
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
`available_interrupt_enabled` as a name didn't tell us a whole lot about
what the method did and why. This CL renames it to
`queue_wants_interrupt`, which seems a little closer to describing
interrupt suppression.
This CL also converts the comment to a proper docstring.
BUG=b:235414140
TEST=builds
Change-Id: I885b917d40e6c86c44ff37542999734cdcf00874
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3781295
Commit-Queue: Noah Gold <nkgold@google.com>
Tested-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
This closes the deltas between some of the files of the crate. The
changes include
- Enables building/testing balloon module on windows.
- Suppressing dead-code warnings on windows in cross platform files.
- u16 to enum fix.
- Organizing imports.
- Using Descriptor(windows friendly) over RawDescriptor.
- Using Option<Tube> instead of Tube.
- Fix some args parsing on windows.
BUG=213149155
TEST=presubmit and built on windows downstream
Change-Id: Idd2ee81384bc5fade610aa864b2c712ea0a0e0d2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3783010
Tested-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Refactor how rx messages are processed, so that the processing code can
be shared with the slave_req_fd.
BUG=b:201745804
TEST=launch sibling VM on manatee
Change-Id: Iecb88c5129d7b3aa8c46a64c24cce61f1e0a0b14
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3765016
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Tested-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Update the vvu driver so that it sends and receives data as discrete
vhost-user messages instead of as a byte stream. This will make it
easier for vvu to intercept transmitted messages, and it allows the
receiving code to be somewhat simplified.
The device implementation already processes received data as full
messages, and doesn't currently examine transmitted messages, so it
doesn't need to be updated.
BUG=b:201745804
TEST=launch sibling VM on manatee
Change-Id: I94a7437a28136e682d2002a34e5f0b7d29d9c238
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3765015
Tested-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Switch virtio-wl to the new shared memory APIs.
Using the shared memory APIs requires establishing mappings based on
shm offset rather than raw pfn. This means virtio-wl needs to manage its
shmem address space itself, rather than relying on
VmMemoryDestination::NewAllocation. To maintain compatibility with older
drivers, a feature bit is used to determine whether drivers expect
mappings to be specified by shm offset or by pfn.
BUG=b:201745804
TEST=launch crostini gui app
TEST=crosvm device wl --wayland-sock $XDG_RUNTIME_DIR/wayland-1 --socket /tmp/vhost.sock
TEST=crosvm ... --vhost-user-wl /tmp/vhost.sock ...
Change-Id: Ia559de7107130440c8f81a30aab1f6b061d15118
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3765014
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Rename cras-snd to snd for Vhost User Device. But cras-snd is still used
for crosvm params.
BUG=b:220649000
TEST=tast run vm.AudioAplay.vhost_user_cras and aplay
Change-Id: Id1990a1cc91a25481db823108862d8e0ce320658
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3765006
Commit-Queue: Norman Bintang <normanbt@chromium.org>
Tested-by: Norman Bintang <normanbt@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Extract Parameters from common_backend to its own modules.
Move unix specific code for VirtioSnd to virtio::snd::sys::unix.
Expose the unix specific function/enum following the style guide.
BUG=b:233542268
TEST=emerge and call aplay
Change-Id: Id9bbed8dde8df71489742b79d3fdec1b4a42ef76
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3765010
Commit-Queue: Norman Bintang <normanbt@chromium.org>
Tested-by: Norman Bintang <normanbt@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Do not use a reference when it's not safe to call minijail.fork() multiple
times.
BUG=b:238646369
TEST=build
Change-Id: I91def471ef64ef11ba32032ccc095d5282362d62
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3779079
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Tested-by: Junichi Uekawa <uekawa@chromium.org>
The code to manage the EventDevice buffers was a little tricky to
follow. This CL refactors it.
BUG=b:239699447
TEST=builds. Tested downstream.
Change-Id: I979643ed82dc69544d2073d09f55a52a4cc3bb39
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3782777
Tested-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
Specify the type so cargo doc can find the right async_from function.
Fixes a warning when running tools/cargo-doc.
BUG=None
TEST=tools/cargo-doc
Change-Id: Ida4431cd663d4b5959a58a707c9c89d7569df986
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764043
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Make the function reference in the docs into a link so it's easier to
follow in the generated HTML docs.
BUG=None
TEST=tools/cargo-doc
Change-Id: I1dbf2f02deb547422c2d8c3a17b892fc96b6f448
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764042
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Permissions should be properly set up now.
BUG=b:239081770
TEST=None
Change-Id: I05906a289791e4296d76bc0f807faa80456bff24
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3780869
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
Notifies the current crosvm oncalls when post-submit is failing.
BUG=b:238234148
TEST=lucicfg validate
Change-Id: I747f70d3abfb5dd26dedfcb2ed230122e063967f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3783012
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
Most of our VhostUserBackends require an Executor to be constructed,
which interferes with our wish to jail them: we want to create the
VhostUserBackend before the child process gets forked, but the forking
process would render the Executor invalid in the child.
Work around this issue by introducing a VhostUserDevice trait which is
supposed to include all the device state without its runtime. Once the
child process is forked, the device can be converted into a
VhostUserBackend using its into_backend() method.
This new trait is illustrated using the Console device.
BUG=b:217480043
TEST=cargo build
Change-Id: Ifc7525aae39da8fdb19fcd237832213c9223a56d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3762973
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Morg <morg@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
A listener is responsible for managing and cleaning up its own
resources, but this can cause problems when jailing device processes.
Typically, the listener is created in the parent thread and then passed
to the device thread so the device thread does not require the
capabilities to allocate the listener's resources. However, when cleanup
time comes, the listener in the child is still responsible for
destroying the resources created by the parent, which may require extra
capabilities. For instance, for a vhost-user socket the listener is
expected to remove the socket file, but we don't necessarily want the
child to be able to remove files from the filesystem...
Fix this by adding a new method, take_parent_process_resources(), that
can be called prior to creating the child process by the parent in order
to obtain the resources that the parent needs to cleanup when the child
process exits. The resources are presented in the form of an opaque box
and must be kept by the parent until the child process exits. After
that, dropping the box will free the resources that we don't want the
child to clean up.
If we are not creating a child process, then the method is simply not
called and the listener will cleanup the resources itself.
BUG=b:218223240
TEST=vhost-user console device gets properly cleaned up.
Change-Id: I7b8c4b700a868f4fd100c45f0e577fddfe8bb216
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3762972
Reviewed-by: Morg <morg@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
send_report used to panic if we tried to send more events than would fit
in the buffer. Now overflow is handled gracefully. We've also increased the
buffer size, which was previously quite tiny, so that we're less likely to drop
events if there is a flood of them.
BUG=b:239699447
TEST=builds. tested downstream.
Change-Id: Ie4b9d927bb75c6a3126de17e781d4a3e18551f7c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3780879
Commit-Queue: Noah Gold <nkgold@google.com>
Tested-by: Noah Gold <nkgold@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Directly allocate dma-bufs within the virtio-wl process and remove the
VmMemoryRequest::AllocateAndRegisterGpuMemory type. This is preparation
for migrating to the SharedMemoryMapper interface.
BUG=b:201745804
TEST=Launch arcvm, launch gedit w/crostini, launch gedit w/vhost-user-wl
Change-Id: I232f1fd3dfdb8d7ed068c6b3c2ea23f35d0ddabc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3765012
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Tested-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Make status queue properly optional. As part of this, refactor how the
optional event queue is handled, to prevent exponential growth in the
number of select statements needed to handle optional queues.
BUG=None
TEST=ARCVM boots and balloon works
Change-Id: I55d59875b7e0223a57f1c8c5d0e0d8a4a6b9a26c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3779083
Tested-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Currently this only builds and runs for Windows
BUG=b:213149155
TEST=built and presubmits
Change-Id: Icc874da61c987fc36c4c9ccea56bd136d660f453
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764469
Tested-by: Richard Zhang <rizhang@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>