Commit graph

6574 commits

Author SHA1 Message Date
Federico 'Morg' Pareschi
362f5103fa cros_tracing: Fix missing fully qualified names
We need to use fully qualified crate names for things like Ordering when
we use them inside macros.

BUG=None
TEST=built crosvm with tracing and checked macros work without imports

Change-Id: I7cae94822ca5c3ef188e8e46e79edfb6bd0fca5b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4560807
Auto-Submit: Morg <morg@chromium.org>
Commit-Queue: Takaya Saeki <takayas@chromium.org>
Commit-Queue: Morg <morg@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
2023-05-24 04:49:56 +00:00
recipe-roller
f312972f7d 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/8780248365330761185

depot_tools:
2568d4c1eb
  2568d4c (sokcevic@chromium.org)
      Add additional check for PS parents

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: I60a46eb5a873dca12205e571913255a6663e9ade
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4559372
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>
2023-05-24 03:59:53 +00:00
Noah Gold
d89938d37f vm_control: add Windows vm_control client support.
With the server support in place, we can connect to the control socket
just like unix does (albeit a named pipe instead of a UDS).

BUG=b:276361599
TEST=tested snapshot commands on Windows.

Change-Id: I874463026e3b4504009c6a19d7ba9ffb8fa169fa
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4558308
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
2023-05-24 00:01:51 +00:00
Noah Gold
ae33f0fc5a src: run the control server on Windows.
If --socket is specified on a non-prod build, we will run a named pipe
server on that socket which will soon service requests like pressing the
power button, etc.

BUG=b:276361599
TEST=builds + later CLs in the chain.

Change-Id: I0be227f5e915feb29ab2883ab3bceb85a50cfc92
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4558307
Reviewed-by: Richard Zhang <rizhang@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2023-05-24 00:01:51 +00:00
Noah Gold
883e44a700 src: implement control socket adapter for Windows.
Implements a control socket adapter for named pipes that will allow
run_control to listen for control socket connections on Windows just
like it does on unix.

BUG=b:276361599
TEST=unit test

Change-Id: I3b2453e3b066a565cab64fc69ba19e960c3a806a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4558304
Reviewed-by: Richard Zhang <rizhang@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2023-05-23 22:53:30 +00:00
Noah Gold
2516507e92 base: make Tubes return a Disconnect error.
Detecting if a Tube is disconnected used to be a little painful since
we'd have to extract the underlying io::Error and check for BrokenPipe.
On unix it wasn't ever this hard since Error::Disconnected exists for
the Tube Error type. On Windows it looks like we just forgot to
implement this.

This CL makes all broken pipes on Tube read/write return Disconnected
instead of a generic IO error.

BUG=b:276361599
TEST=manual run of VM.

Change-Id: I422951b770fd966d6d5e9618c3b756bb2ab5ef7d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4558305
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
2023-05-23 22:53:30 +00:00
Noah Gold
3a46037613 base: fix StreamChannel broken pipe bug.
StreamChannel notifications were not properly handling broken pipes
when fetching the number of bytes available during the notification
sync. This is because the PeekNamedPipe call comes after the final read
call that drains the named pipe, and at this point the pipe is broken.
This CL fixes the problem by treating the byte count as zero if the
pipe is broken, which is technically true (it has no data).

BUG=b:279840868
TEST=manual

Change-Id: Ib563c7e5e426524f666ff191ec3774a4b40f59a0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4556842
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
2023-05-23 22:04:40 +00:00
Noah Gold
70e9e588d1 base: relax thread::spawn_with_timeout trait reqs.
base:🧵:spawn_with_timeout was stricter than
std:🧵:spawn, which wasn't really helpful.
(In prod code we use std:🧵:spawn, so being
stricter than that isn't useful or safer in a meaningful
way.)

BUG=b:276361599
TEST=builds

Change-Id: I4197d3ac082af4077f82d7d70a11869b0a886238
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4556841
Reviewed-by: Richard Zhang <rizhang@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2023-05-23 21:41:06 +00:00
Noah Gold
738220a623 base: new Tube APIs (split, PipeTube, FlushOnDrop).
* Sometimes we want to split a Tube end into a reader & writer so
those responsibilities can be handled separately. This is what
`split_to_send_recv` does.
* On Windows, making a Tube directly attached to a named pipe will be
  needed for the control client. This is what `PipeTube` implements.
  Just like a raw named pipe, it has no notification support, and so it
  hides those elements of the Tube API.
* On Windows, we need a way to ensure a Tube is flushed before it is
  dropped so that a disconnecting client can ensure the server has read
  its messages before the pipe is dropped / EPIPE happens.
  Paradoxically, the "flush" can only be implemented on the server end
  of a pipe, so in CrosVM, our "clients" are actually the server end of
  pipes.

BUG=b:276361599
TEST=tested in future CL in the chain.

Change-Id: I70a7badc92461d49b9f08a5f997157b0698cff24
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4556840
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
2023-05-23 21:36:56 +00:00
Noah Gold
a6169ea5b1 base: fix ERROR_MORE_DATA being a read failure.
In our overlapped read helper API, ERROR_MORE_DATA was considered to be
a fatal error (if returned from the initial call to ReadFile). It looks
like this might only happen for message mode pipes, which probably
weren't used with this function until an upcoming CL. This error would
cause us to return early and leave the OverlappedWrapper in use. Leaving
the wrapper in use is still possible, so that's a bug (b/279459822).

BUG=b:276361599
TEST=future CLs in the chain.

Change-Id: Icc8dff9b83542365336664ee1219654cb3ec1eef
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4556839
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2023-05-23 21:31:49 +00:00
Noah Gold
448e796868 base: add interruptable ConnectNamedPipe for pipes.
Similar to our other overlapped utility functions for read, this CL adds
one for the named pipe equivalent of accept (ConnectNamedPipe).

BUG=b:276361599
TEST=unit tests

Change-Id: I30780fbfea6ff57aaf4bb3176f400f5b5e5fb9de
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4556838
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
2023-05-23 21:31:49 +00:00
recipe-roller
f913a0e9eb Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (depot_tools, recipe_engine) into this repository.

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

depot_tools:
02838e6f4e
  02838e6 (tusharvickey1999@gmail.com)
      Import Get-FileHash from PowerShell's version specific path

recipe_engine:
a5c25e8f06
  a5c25e8 (iannucci@chromium.org)
      [recipes.py] Unset PYTHONPATH in case users have conflicting va...

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: I0edc7774d0b64501a2133b7a602003ddeaaca4d7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4558944
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>
2023-05-23 20:53:57 +00:00
Noah Gold
c350eee33b hypervisor: implement blanket MSR fetch for WHPX.
For snapshotting, we want to save/restore *all* MSRs rather
than a one or two specific MSRs. To accomplish this, we're
implementing get_all_msrs for WHPX.

BUG=b:269705560
TEST=unit tests

Change-Id: I706c3bd1d9d11ca58c709e1a19e0184dc560f193
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546271
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-05-23 20:00:32 +00:00
Noah Gold
458bc9e033 hypervisor: add test for interrupt state snapshot.
After running into issues with MSRs, it seemed advisable to have a smoke
test for these functions too.

BUG=b:269705560
TEST=unit test

Change-Id: I2017dc95c19a7097a4be17099cd33ae75bf7c6f6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546270
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Steven Moreland <smoreland@google.com>
2023-05-23 20:00:32 +00:00
Gurchetan Singh
fefe0c8aba rutabaga_gfx: move to updated stream_renderer_flush api
Removed unused parameters.

BUG=b:278138335
TEST=compile

Change-Id: I5226689af156fca5f80d0c79ead88a12ce99aba5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546261
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-05-23 16:01:26 +00:00
Shintaro Kawamura
f35834e243 base: tube: handle EINTR on Tube
According to man 7 signal:

> On Linux, even in the absence of signal handlers, certain blocking
> interfaces can fail with the error EINTR after the process is stopped
> by one  of the stop signals and then resumed via SIGCONT.  This
> behavior is not sanctioned by POSIX.1, and doesn't occur on other
> systems.
>
> The Linux interfaces that display this behavior are:
>
> •  "Input"  socket  interfaces,  when  a  timeout  (SO_RCVTIMEO)  has
>    been set on the socket using setsockopt(2): accept(2), recv(2),
>    recvfrom(2), recvmmsg(2) (also with a non-NULL timeout argument),
>    and recvmsg(2).
> •  "Output" socket interfaces, when a timeout (SO_RCVTIMEO) has been
>    set on the socket using setsockopt(2):  connect(2),  send(2),
>    sendto(2),  and sendmsg(2), if a send timeout (SO_SNDTIMEO) has
>    been set.

The swap feature sends SIGSTOP and SIGCONT to crosvm processes. The
balloon command tube and the proxy devices fall into this category.

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

Change-Id: I34535430d6fcde4eaf3d2b21acf9ee444baad42c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4547741
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2023-05-23 10:29:53 +00:00
Shintaro Kawamura
ded8ec392e base: tube: send/recv for srteam socket to use io::Result
It is confusing that `Tube::recv()` may return `Error::Send`. This was
because `TubeError::Recv` accepts `std::io::Error` only while socket
related raw function in base crate returns `base::Error`.
`TubeError::Recv` and `Tube::Send` should accept either of `base::Error`
or `std::io::Error` but the same one.

`std::io::Error` is preferred because send/recv on `ScmSocket` are I/O.

`std::io::Error::raw_os_error()` always returns `Some` if the error was
constructed via `std::io::Error::last_os_error()`.

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

Change-Id: I73509c7173b4b0e5e7ed939ef20e36db2f16ade3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546494
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Shin Kawamura <kawasin@google.com>
2023-05-23 10:29:53 +00:00
Daniel Verkamp
5da3111c57 fuzz: improve virtqueue fuzzer coverage
Exercise more of the virtqueue descriptor chain API by consuming the
reader and writer. This also makes the fuzzer match the real-world usage
of the DescriptorChain APIs.

BUG=None
TEST=cargo +nightly fuzz run virtqueue_fuzzer

Change-Id: Ic56362cda87dd482a7c8fa6b3dd89cebfee8bc30
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4553720
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-05-23 00:24:32 +00:00
Frederick Mayle
b3d2d4f801 devices: virtio: minor handle_irq_resample simplifications
This commit basically undoes https://crrev.com/c/3311457 because,
after https://crrev.com/c/3858693, there is no longer a RefCell to
worry about.

Change-Id: Ic14dac01dff28f5644981c302a647663f2a6771d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4553719
Auto-Submit: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-05-23 00:10:22 +00:00
Elie Kheirallah
3a53bce8c6 devices: add snapshot/restore to IrqChip riscv64
Add missing snapshot/restore function to Irqchip for riscv64

BUG=N/A
TEST=presubmit

Change-Id: Ic73c71be6104bc4724225039588500bf9107ab68
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4553718
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Elie Kheirallah <khei@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-05-22 22:49:02 +00:00
Elie Kheirallah
9787c96675 crosvm: Add irq_chip snapshot/restore to VM
Add Irq_chip snapshot/restore to the existing operation of
snapshot/restore in the VM.

BUG=b:276357277
TEST=crosvm snapshot/restore && presubmit

Change-Id: I7bfb7eba11668e507d8a7d8b7fa75878c3b1a943
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4550006
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Steven Moreland <smoreland@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Elie Kheirallah <khei@google.com>
2023-05-22 22:13:35 +00:00
Vikram Auradkar
f054575a8b clippy: Disallow len_without_is_empty and len_zero
BUG=b:283512997
TEST=none

Change-Id: I0477583b3f8c8eefeb1d79f11302b1b28a8bd770
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4549999
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2023-05-22 21:27:21 +00:00
Vikram Auradkar
bc604656c9 clippy: Disallow nmodule_inception
BUG=b:283512997
TEST=none

Change-Id: I5cacef1d485d2f25e5377e285a47442da766bac2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4549998
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2023-05-22 21:21:43 +00:00
Vikram Auradkar
0e1c85f293 clippy: Disallow new_without_default
BUG=b:283512997
TEST=none

Change-Id: If10b73f0cd686ff1a1a17e4aa3260f01e1ee8db5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546662
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2023-05-22 21:14:06 +00:00
recipe-roller
2e8301e875 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/8780370419358540161

depot_tools:
63d20c330b
  63d20c3 (yueshe@google.com)
      Roll mac_toolchain in depot_tools to latest version

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: Iac0a1be0389ed84c6be655f0956eea62d5415a8b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4550406
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>
2023-05-22 19:35:19 +00:00
maciek swiech
fac9000051 balloon: use protos for registered events
since the RegisteredEvent model is effectively an external API, switch
to using protobuf as a more formal/stable means of communicating
messages. also introduces exporting the registered_events.proto file as
part of crosvm_control build, alongside the currently existing header
file.

this patch also introduces feature-gating for registered_events and
protos so as not to bring in too many third party dependencies for a
base build.

BUG=b/278117550
TEST=run bzImage locally
TEST=sidecar program available at https://x20.corp.google.com/users/dr/drmasquatch/socket-pinger-proto

Change-Id: I5d91d87f7807effc125352caf5c75eee2593f70d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4521604
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: maciek swiech <drmasquatch@google.com>
2023-05-22 19:28:45 +00:00
Takaya Saeki
293bdf3f24 cros_async: Rename Mutex to RwLock
Currently, cros_async::sync::Mutex is named "Mutex", but it is actually
a read-write lock, which is confusing to readers. As a result, readers
often mistakenly think that the part of the code which should use a
read-write lock is using a Mutex.

This change renames Mutex to RwLock to eliminate the confusion. In
addition, this change updates the documentation to recommend developers
to use the standard `futures:🔒:Mutex` if they just need a Mutex,
not a read-write lock.

BUG=None
TEST=./tools/dev_container ./tools/presubmit

Change-Id: Ic008d2448308066d9c5cabb0b6c499a62994e5e2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546967
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Takaya Saeki <takayas@chromium.org>
2023-05-22 07:01:38 +00:00
recipe-roller
6cd80fc3ea 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/8780424526726794721

depot_tools:
3a5cc40813
  3a5cc40 (jwata@google.com)
      [autosiso] Do not double quote arguments on Windows.

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: Ib8a4cb82fbf1e7d54c29d25b07808ee579b70307
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4550883
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>
2023-05-22 05:17:31 +00:00
recipe-roller
cb7000cd1e 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/8780634031203720577

recipe_engine:
ca81081334
  ca81081 (vadimsh@chromium.org)
      [swarming] Update `swarming` CLI tool.

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: Ie0d4b3dead644a791a023f0cc2a78a83184cf106
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4550003
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>
2023-05-19 21:46:33 +00:00
Daniel Verkamp
de1aa5026f devices: virtio: add Reader::peek_obj() and remove Clone
This makes it possible to read an object from a Reader without consuming
it, which can be used to replace a sequence like .clone().read_obj().
Therefore Clone is no longer needed on Reader (and Writer already did
not need it), so the #[derive(Clone)] can be removed.

The core functionality of the io::Read implementation for Reader is
factored out into a new copy_regions_to_mut_ptr() function so it can be
reused by both peek_obj() and io::Read.

BUG=None
TEST=cargo test -p devices reader_peek_obj
TEST=tools/dev_container tools/presubmit

Change-Id: I8cca912a34ced46bbd0c2d75a84f3eca65fe6b56
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4545950
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
2023-05-19 21:06:14 +00:00
Daniel Verkamp
a37829eadd base: windows: move file_utils to sys/windows
BUG=b:263815124
TEST=tools/run_tests --platform=mingw64

Change-Id: Iffa9e8137465d5427f0fdea2b36783ae99ec37c9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4126571
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-05-19 19:58:45 +00:00
Daniel Verkamp
380359295e base: windows: merge win/syslog.rs into syslog.rs
BUG=b:263815124
TEST=tools/run_tests --platform=mingw64

Change-Id: I619d86bfc10aae5083eeb771cd77e8a7748cdfba
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4126570
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-05-19 19:52:38 +00:00
Daniel Verkamp
b13262f48f base: windows: move give_foregrounding_permission to a new file
Move the AllowSetForegroundWindow() wrapper out of windows/win.

BUG=b:263815124
TEST=tools/run_tests --platform=mingw64

Change-Id: I401eb5098ce9d2d02c1f5d8651743d99c19a037f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4126567
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-05-19 19:52:38 +00:00
Richard Zhang
152b16832a vhost_user: Implement sleep for vhost user devices
* Created IPC message for sleep in vmm_vhost
* Save active virtqueue states in the device process
* Removed unused queues field in Worker

BUG=b:280607608
TEST=presubmits and e2e_test

Change-Id: I18350d8e687e4e46d812679d45b90e54d098abf9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4522139
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-05-19 18:40:39 +00:00
Richard Zhang
882890f47a vhost-user: return the active Queue from stop_queue
Most of this change involves wrapping the Queue object inside an
Rc<RefCell<>>, Arc<Mutex<>>, or Rc<AsyncMutex<>>.

This is necessary for getting device suspend and resume to work.

Bug=280607608
TEST=presubmits

Change-Id: I7e3680aea2927c1fc9d971f27ebbb09ec308a634
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4545603
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-05-19 17:56:12 +00:00
recipe-roller
4c7130dc04 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/8780649754928416401

depot_tools:
9c32c9240c
  9c32c92 (jojwang@google.com)
      Add explicit path for infra_internal in infra_internal_superpro...

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: I52d1efd07f54a2c07bcf36684cceae40d19d4dbe
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4549066
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>
2023-05-19 17:39:41 +00:00
yuanyaogoog
6a8c9dc22c docs: Add virtio-fs document in crosvm book
Crosvm book don't have a documentation for how to run and use the virtio-fs.

Add a fs chapter under device, and upload a runnable example.

BUG=b:235067443
TEST=mdbook build docs/book

Change-Id: I8ef1ceb9d4cfc5f9a2e8afa2416d1f3ba69691b4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4535500
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Commit-Queue: Yuan Yao <yuanyaogoog@chromium.org>
2023-05-19 01:45:15 +00:00
Takaya Saeki
6bf5d2b6b4 io_uring: refactor prep_next_sqe to remove an argument no longer used
uring::SubmitQueue has pre-allocated io_vecs field inside it, and
prep_next_sqe provides a caller with an io_vec so that the caller
doesn't have to allocate an io_vec by itself. This used to be used by
add_rw_op before. However, no caller uses this given io_vec, but they
allocate io_vec by themselves.

This change removes io_vecs from the arguments of prep_next_sqe, and
refactor SubmitQueue structure to make it simpler.

BUG=None
TEST=cargo test -p io_uring. A vm launches by crosvm run
--async-executor uring...

Change-Id: I07bb2f496d3a2e4ca038a4dd861dd80b87ba41ef
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546822
Commit-Queue: Takaya Saeki <takayas@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-05-19 01:34:54 +00:00
Takaya Saeki
fb6487f90f io_uring: make tests more DAMP
Refactor some tests so that they become more DAMP style by expanding
unnecessary extra utiltiy function.

BUG=None
TEST=cargo test -p io_uring

Change-Id: I9c0850ac8cf0e5cd4b11c94048c5c5be3a7085ee
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546821
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Takaya Saeki <takayas@chromium.org>
2023-05-19 01:28:35 +00:00
Takaya Saeki
e8766a6f60 io_uring: test only methods that are actually used and remove add_rw_op
Currently, a lot of io_uring tests are tesing `add_read`, `add_write`,
and `add_rw_op`, but these methods are actually never used except by
those tests themselves. So, these methods and their tests are no longer
necessary.

This change removes these methods and tests only for them, turning
`add_read` and `add_write` intto utility functions for testing.

BUG=None
TEST=cargo test -p io_uring

Change-Id: I2d58afa826d5f09d7b3b5cdbcab798f26d617c23
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546820
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Takaya Saeki <takayas@chromium.org>
2023-05-19 01:26:09 +00:00
recipe-roller
89cd6ead0f 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/8780715821411182737

depot_tools:
b0e8e7adbc
  b0e8e7a (dlf@google.com)
      output actual CIPD package URL instead of 'None' when calling r...

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: Ifcaeb1de101b66ca08ac38990ccd13dabd280b55
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546996
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>
2023-05-19 00:05:20 +00:00
recipe-roller
5530ab49fc 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/8780723924581877921

depot_tools:
44a278067b~..b6cb9e0b9a86099eda513d1bfc450de707b5d0e7
  44a2780 (jojwang@google.com)
      Allow empty commits in presubmit recipe.
  66a30a7 (mfarazma@redhat.com)
      Skip goma on unsupported platforms
  b6cb9e0 (brucedawson@chromium.org)
      Remove Python 2 support for presubmit Commands

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: Icffcc3ecb305da7d0eecf267792ba75f03a94a5b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546991
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>
2023-05-18 23:47:54 +00:00
Idan Raiter
eb2d7e5b9b sandbox: Call lower_token before run_control
Upstreaming a fix:

We found that token lowering can conflict with valid operations if they
happen in another thread, concurrently. An example is creating a named
pipe / Tube pair, where the client->server connection fails with access
denied if the token is lowered in between the two operations.

We fix this for now, by moving lower_token before run_control with a big
warning of the pitfalls of moving it again.

BUG=b:281108137
TEST=Ran emulator

Change-Id: I1bce32edc6872f895630eb3005427521e3653228
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4544898
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Idan Raiter <idanr@google.com>
2023-05-18 23:02:14 +00:00
Daniel Verkamp
88d5f4fee7 io_uring: remove stats, in_flight, and completed info
These statistics are updated but never read. Remove them to avoid some
extra atomic operations in the critical path.

BUG=None
TEST=tools/dev_container tools/presubmit
TEST=cargo test -p io_uring -- --include-ignored

Change-Id: Iad28e28b8d617862c4d5a089aba30dde773d6c31
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4541760
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-05-18 20:02:42 +00:00
Frederick Mayle
cb450f4996 cros_async: factor out common executor code
fd_executor, uring_executor, and handle_executor had a lot of duplicate
code. A new trait `Reactor` is introduced to abstract away the
differences between the IO backends. There is now a single
`RawExecutor`, which is generic over `Reactor`s.

No behavior changes are intended, with some small exceptions:

* A new error variant is used in some cases, e.g. instead of
  `Error::PollExecutor` an error might be `Error::Io` now. Nothing seems
  to inspect these errors, so it is unlikely to cause an issue.
* There is an extra alloc when the executor is dropped (for the boxed
  future).
* The Unix backends had an `AtomicI32` state field but the Windows
  backend did not. Now Windows does as well. This might save a syscall
  here and there.

Change-Id: Ieeff9d9888ed082cf3e0213e586c55c9d8a1f8bf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4331554
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-05-18 17:40:14 +00:00
Elie Kheirallah
6fad425736 devices: irqchip: add snapshot/restore
Add snapshot/restore to irqchip for kvm and whpx to save the state of the irqchip.
Add saving apic_base as part of the irqchip.

BUG=b:266515147
BUG=b:232437513
Test=crosvm build - testing requires more changes related to VmRunnableLinux

Change-Id: Iffbd38634390d276d70d6467549df9ffaf176059
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4518572
Commit-Queue: Elie Kheirallah <khei@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Auto-Submit: Elie Kheirallah <khei@google.com>
2023-05-18 17:27:36 +00:00
recipe-roller
63b9c3adef 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/8780747906884786097

recipe_engine:
d0c2ca6a54
  d0c2ca6 (atyfto@google.com)
      [protoc] Update py3 protobuf & protoc to 4.21.1

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: Ifc4c60a116180a250465ef9ab2c01beef06738e8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546552
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>
2023-05-18 15:43:22 +00:00
recipe-roller
4243a89f73 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/8780762367472068417

depot_tools:
39e668df57~..a4b871ebd9d9f96b49c69aabae97080ffb4a55e1
  39e668d (dlf@google.com)
      support cipd describe command in cipd testing
  a4b871e (sokcevic@chromium.org)
      Disable showing callstacks when running async jobs

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: Ic2aefc85a184693532d17ec8fae2b9e115e05707
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4546551
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>
2023-05-18 15:17:59 +00:00
Pattara Teerapong
e1d624aaed seccomp: arm: snd_null_device: add timerfd_settime
Null snd device use timer to simulate the delay to write/read data.

On ARM devices we allow timerfd_settime64, but using aplay/arecord on
version R108-15133.0.0 with null device will make it crash. Allowing
timerfd_settime solves the issue.

BUG=b:280151005
TEST=run crosvm on kukui with null snd device and call aplay/arecord

Change-Id: Ie3d06691f4b87075a4513b13340e74f4dd21f100
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4547037
Auto-Submit: Pattara Teerapong <pteerapong@chromium.org>
Reviewed-by: Norman Bintang <normanbt@chromium.org>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2023-05-18 14:38:07 +00:00
yuanyaogoog
ed842f4918 tools: Enable sandbox in example scripts
Currently, example scripts disabled sandboxing feature. However,
sandboxing feature is a big part in crosvm security model.

This commit will create /var/empty directory in host, so that the
minijail can be created.

BUG=b:281951944
TEST=tools/examples/example_simple tools/examples/example_network
tools/example_desktop

Change-Id: I8cece99ee7df22f51b61eb1eeebde7b65a715e04
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4535442
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Yuan Yao <yuanyaogoog@chromium.org>
2023-05-18 06:36:03 +00:00