Commit graph

3771 commits

Author SHA1 Message Date
Alexandre Courbot
b524833ab8 devices: vhost-user: handler: use vmm_vhost's socket listener
vmm_vhost comes with its own set of listeners that implement the same
interface. Switch to use its socket listener as that will allow us to
further factorize code.

BUG=b:229554679
TEST=vhost-user console device works.
TEST=vvu console device works.

Change-Id: I19d0c9b95a0cca57eefd6c72b875e8a166d06b89
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3591110
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-27 06:53:07 +00:00
Alexandre Courbot
64a3fc2d08 devices: vhost-user: remove Arc from SlaveListener and SlaveReqHandler
The SlaveReqHandler should be the sole owner of a VhostUserBackend since
it calls its mutable methods, so we shouldn't need an Arc here. If
sharing is necessary users can use their own locking mechanism.

Single ownership will help to retrieve the backend after a client
disconnects, to reuse it for another connection if needed.

BUG=b:229554679
BUG=b:216407443
TEST=cargo test -p vmm_vhost
TEST=vhost-user console device works.
TEST=cargo test -p devices

Change-Id: I2358c807ac3ddb1ee4b29d97df0ade5a3e30a85a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3591108
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-27 06:53:06 +00:00
Alexandre Courbot
c9b84cf570 base: fix cargo doc warnings
Fix a few link-related (either dead links or typos) in the base crate.

BUG=None
TEST=cargo doc

Change-Id: I520dd2fbfc16de72fcf19ecdd90943a7a963103c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671057
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-05-27 05:29:02 +00:00
Peter Collingbourne
09f4513745 book: document that --gdb is x86 only
Change-Id: I26599a7e95b2caf899ed5ca95c56b9c7219440d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671957
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Peter Collingbourne <pcc@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-05-27 03:28:04 +00:00
Dennis Kempin
4977f49b8b dev_container: Move --stop logic before calculation of command
Otherwise we may exit thinking we are trying to run an interactive
command in a non-interactive terminal.

BUG=None
TEST=./tools/dev_container --stop </dev/null

Change-Id: Ie34cf662b82090b100533306572552c5a550211e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671132
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-27 02:36:53 +00:00
Dennis Kempin
b360cd9fa9 infra: Add ChromeOS post-submit builder
This re-creates the Kokoro equivalent crosvm/ci/build-chromeos.sh.

It is a very inefficent builder that does a fresh checkout of
chromeos for every build.

We may want to consider using some of the chromiumos recipes
for caching the repo or sdk between builds.

BUG=b:233230344
TEST=./recipes.py test run
./recipes.py run build_chromeos

Change-Id: I5d545bae4817cae5b79c5d65901081d9b1391466
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664842
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-26 22:03:51 +00:00
Dennis Kempin
ab93b5c3dc infra: Add verify builder for health_check
Adds a builder for both pre- and post-submit, executes the newly
added health_check recipe.

BUG=b:233913455
TEST=lucicfg validate main.star

Change-Id: I69e9738a02bb298d3b2556058d2df1ee9979bda4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3669815
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-26 20:33:29 +00:00
Kaiyi Li
d6b6a991df virtio-gpu: move parameters to a separate file
BUG=b:233676779
TEST=build on Android

Change-Id: I20cf4c330844f5048553ba44e002747c874b54bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668927
Auto-Submit: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-26 20:19:46 +00:00
Daniel Verkamp
6792731800 seccomp: arm: allow fstatat for xhci
glibc 2.33 uses the fstatat64 syscall to implement statx(), which is
called by the USB emulation code when a device is added. Allow it along
with fstat64 to fix a crash on USB device insertion.

aarch64 and x86_64 use the newfstatat syscall instead, so they do not
need to be adjusted.

BUG=chromium:1328120
TEST=Attach yubikey to Crostini on kevin

Change-Id: I6a592e25126a5baebdbc8839ba11b971950f4575
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671085
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-26 20:14:08 +00:00
Jeffrey Kardatzke
dd94f70697 crosvm: Add support for HEVC profile
Submit after crrev.com/c/3664859 is merged.

BUG=b:215043150, b:183217901
TEST=HEVC playback works in ExoPlayer on guybrush w/ full set of changes

Change-Id: If775435040a77f4620a55d6838353836c40291c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664289
Commit-Queue: Jeffrey Kardatzke <jkardatzke@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-05-26 20:09:50 +00:00
Daniel Verkamp
a6f7cbf5fb seccomp: aarch64: fix USB ioctl struct sizes
The ioctl allow list for the emulated xhci USB controller device was
copied from the 32-bit ARM version, but the structure sizes are
incorrect for 64-bit aarch64. Update the constants for ioctls that take
a structure with a different size:

- USBDEVFS_REAPURBNDELAY: struct usbdevfs_urb
- USBDEVFS_SUBMITURB: struct usbdevfs_urb
- USBDEVFS_CONTROL: struct usbdevfs_ctrltransfer

BUG=chromium:1328120
TEST=Share USB device with Crostini on trogdor64

Change-Id: I45d69021257af55cfeaf72dd33a500a358adc5ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3670055
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-26 19:37:54 +00:00
Mike Gerow
539ba3dcc9 Reland "devices: debugcon: add bochs-style debugcon device"
This is a reland of commit 129840471d

Original change's description:
> devices: debugcon: add bochs-style debugcon device
>
> This allows for creating a simple write-only debug connection that uses
> a single IO port. This method is supported by both bochs and qemu[1].
>
> The main motivation here is to help in improving crosvm's ability to
> boot OVMF, which makes use of this simple debug device on port 0x402.
> For that one would use `--serial
> type=stdout,hardware=debugcon,debugcon_port=1026` or something similar.
>
> Note that serde_keyvalue doesn't support parsing hex values, hence the
> need to use `1026`, but I intend to address that as well to allow the
> more natural `debugcon_port=0x402` phrasing.
>
> [1]: https://github.com/qemu/qemu/blob/master/hw/char/debugcon.c
>
> BUG=b:233610263
>
> Change-Id: I73238e5c35925668d133bfaa542fcbcf1e28765f
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3661255
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: Mike Gerow <gerow@google.com>
> Tested-by: kokoro <noreply+kokoro@google.com>

Bug: b:233610263
Change-Id: I2f2125da95e8907f4f0c16930952e9b765d33e6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671087
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Mike Gerow <gerow@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-26 19:25:02 +00:00
Richard
b22eff068e devices: upstream virtio balloon for Windows
BUG=b:213149162
TEST=built and presubmits

Change-Id: I4323cbe8457501ab6988110b53b2c790a51ce8b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3655755
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Richard Zhang <rizhang@google.com>
2022-05-26 18:23:34 +00:00
Mike Gerow
d46572f47e Revert "devices: debugcon: add bochs-style debugcon device"
This reverts commit 129840471d.

Reason for revert: This conflicts with https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600167 breaking the build

Original change's description:
> devices: debugcon: add bochs-style debugcon device
>
> This allows for creating a simple write-only debug connection that uses
> a single IO port. This method is supported by both bochs and qemu[1].
>
> The main motivation here is to help in improving crosvm's ability to
> boot OVMF, which makes use of this simple debug device on port 0x402.
> For that one would use `--serial
> type=stdout,hardware=debugcon,debugcon_port=1026` or something similar.
>
> Note that serde_keyvalue doesn't support parsing hex values, hence the
> need to use `1026`, but I intend to address that as well to allow the
> more natural `debugcon_port=0x402` phrasing.
>
> [1]: https://github.com/qemu/qemu/blob/master/hw/char/debugcon.c
>
> BUG=b:233610263
>
> Change-Id: I73238e5c35925668d133bfaa542fcbcf1e28765f
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3661255
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: Mike Gerow <gerow@google.com>
> Tested-by: kokoro <noreply+kokoro@google.com>

Bug: b:233610263
Change-Id: Ia70540c3041611f59968cb7929b238eecfe2530d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671082
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Mike Gerow <gerow@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-26 18:23:30 +00:00
Dennis Kempin
cb99b70b1d infra: Add health check builder
The builder calls ./tools/health-check for fmt/clippy/python checks.

BUG=b:233913455
TEST=recipes.py run health_check

Change-Id: Ia4b8298ef921b33a687d4e64956fc1f017649e7f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668814
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-26 17:47:46 +00:00
Dennis Kempin
bcbf2cb678 infra: Preserve container between steps
This allows us to run multiple steps with the same intermediate
build data.
To make sure we start with a clean slate, any existing containers are
deleted at the beginning of each recipe.

BUG=b:233913455
TEST=./recipes.py test run

Change-Id: Ieda684d40bf08937183cba34242360c025724af8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668813
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-26 17:47:46 +00:00
Mike Gerow
129840471d devices: debugcon: add bochs-style debugcon device
This allows for creating a simple write-only debug connection that uses
a single IO port. This method is supported by both bochs and qemu[1].

The main motivation here is to help in improving crosvm's ability to
boot OVMF, which makes use of this simple debug device on port 0x402.
For that one would use `--serial
type=stdout,hardware=debugcon,debugcon_port=1026` or something similar.

Note that serde_keyvalue doesn't support parsing hex values, hence the
need to use `1026`, but I intend to address that as well to allow the
more natural `debugcon_port=0x402` phrasing.

[1]: https://github.com/qemu/qemu/blob/master/hw/char/debugcon.c

BUG=b:233610263

Change-Id: I73238e5c35925668d133bfaa542fcbcf1e28765f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3661255
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Mike Gerow <gerow@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-26 17:13:59 +00:00
Alexandre Courbot
532cce15b1 devices: vhost-user: console: poll input asynchronously
Using the new `SerialInput` trait, we can create an async input source
and get rid of the polling thread.

BUG=b:228912920
TEST=vhost-user console device is working (with input) on Linux.

Change-Id: I1be9ae499f9c782b4aacba44e1eca524f1b701c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600168
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-26 11:17:52 +00:00
Alexandre Courbot
738adc7072 devices: serial: introduce SerialInput trait
Introduce a new dedicated trait for types that can be used as serial
input. This trait adds the requirement that the type must implement
`AsRawDescriptor`, which will allow us to use the input as a poll source
instead of having to spin a dedicated thread to call `read()` on it.

BUG=b:228912920
TEST=cargo build

Change-Id: Ib07f7b4e63545fa0f27940553ad6124796f5b3cc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600167
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-26 10:09:52 +00:00
Dennis Kempin
784ab4b469 health-check: Add option to run only some checks
The default is still to run all of them, but this will allow us to run
checks in separate luci steps to provide an easier to read result.

BUG=b:233913455
TEST=./tools/health-check python fmt

Change-Id: Iddc803f8f423db36ece53a13acfe564560b789a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668812
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-26 01:03:59 +00:00
Dennis Kempin
c2292ef52f dev_container: Keep alive with 'sleep infinity'
We run a neverending command in the container to keep it alive in the
background.
By default, this would be bash, which does the job when --tty is
specified. But we no longer do that all the time.

Instead we can use sleep, which does not rely on such tricks.

BUG=b:233913455
TEST=./tools/dev_container true

Change-Id: I2d04aabbef6b670daf6b94fdc2c65c7bd759c61b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3669682
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-26 01:03:59 +00:00
Daniel Verkamp
ac65c32e6e main: only allow --gdb option when compiled with gdb feature
Without this cfg check, execution can reach an unreachable!() statement
in the arg handling code on non-gdb builds.

BUG=None
TEST=cargo build # without --features=gdb

Change-Id: I8bec7abbb39e658d5c8f45946fd4fc28f0ae97a2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668741
Reviewed-by: Anton Romanov <romanton@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-25 22:45:55 +00:00
Vikram Auradkar
a243d3115c crosvm: refactor main.rs
- make gpu-display related code unix only
- add/use
  - use_host_cpu_topology
  - get_vcpu_count
  - net_vq_pairs_expected

BUG=b:227659915
TEST=presubmit

Change-Id: I6a1901d25de351bfbdf9d5b1210123ac3b1ddb55
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3663966
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-25 20:43:20 +00:00
Daniel Verkamp
e84d9c1d7c devices: pci: PciBarIndex API cleanup
Everything that takes a PCI BAR index should use the appropriate
PciBarIndex type rather than u8 (or usize) for better type safety and
descriptiveness.

BUG=b:232838930
TEST=tools/presubmit

Change-Id: I0a918a6da6327c963fb297ba765563774a7e5e49
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664282
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
2022-05-25 20:36:40 +00:00
Daniel Verkamp
18203fa00f devices: virtio-pci: refactor BAR lookup
The read_bar() and write_bar() functions had an open-coded equivalent of
BAR lookup to find out if the access was intended for the settings BAR
or one of the device-specific extra BARs. Instead, we can reuse the same
BAR lookup code to find the index of the relevant BAR and compare it
against the settings_bar field.

BUG=b:232838930
TEST=tools/presubmit

Change-Id: I2e5f3ccff47d31718e835ccb745db75dbda2e4ec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664281
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-25 20:36:40 +00:00
Daniel Verkamp
19da3a6c48 devices: virtio: clean up write_bar/read_bar matches
Define constants for the end of the ranges that exist within the
settings BAR so we can use the range syntax in the match instead of
manually checking against the start and end.

This uses inclusive range (..=) syntax, since exclusive range pattern
syntax (..) is experimental. Therefore, each range has a `_LAST`
constant that is equal to the address of the last valid byte in that
range (first + size - 1).

Rewriting the matches in this way allows us to clean up the two clippy
ignores and makes the code a bit easier to read.

BUG=b:232838930
TEST=tools/clippy
TEST=Boot x86-64 Crostini

Change-Id: Ibb8b5ea055e598c19504b7b1b6753706ad458875
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664280
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
2022-05-25 20:36:40 +00:00
Daniel Verkamp
337d123007 x86_64: gdb: add support for FPU and SSE registers
BUG=None
TEST=connect gdbstub and run `info all-registers`

Change-Id: I2800134923d73117122b0cb136021d30ebe4cd76
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3657060
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-25 17:33:30 +00:00
Lepton Wu
911a2d0671 devices: vhost-user: fs: open vvu device outside jail.
We need to open vvu device before we go to jail since we don't have
access to sysfs in jail.

BUG=b:233690640
TEST=manual - fs is usable from a sibling guest when using VVU.

Change-Id: I0340d105b667cce2ba88d7557e64771fa2bedf9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3665907
Auto-Submit: Lepton Wu <lepton@chromium.org>
Commit-Queue: Lepton Wu <lepton@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-25 16:44:13 +00:00
Alexandre Courbot
1f486e2313 gpu: fix (again) unused_mut warning when no gpu feature is enabled
This was fixed in crrev.com/c/3659824, but a subsequent commit somehow
reverted that line.

BUG=None
TEST=`cargo build` does not display any warning.

Change-Id: Id50ee4f615117ada8c27552e073f7fb04d8d009e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664166
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-25 09:14:18 +00:00
Alexandre Courbot
4212e80393 devices: vhost-user: console: make async functions generic
We want to eventually reuse these functions in the regular virtio device
code, which uses a different kind of interrupt, so make that parameter
generic.

BUG=b:228912920
TEST=cargo build

Change-Id: I1139ce6626ac7b952b7769db6e66d677607d3307
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600166
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-05-25 09:12:23 +00:00
Alexandre Courbot
8477c44059 virtio: console: simplify process_transmit_queue
The error path reproduces the code outside of the match arm, so it can
be removed.

BUG=b:228912920
TEST=cargo build

Change-Id: Ibd485a52441be03501041bc4136bab9293c7066b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600165
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-25 09:12:23 +00:00
Alexandre Courbot
e8d53e8ee6 virtio: console: clarify process_transmit_queue
Used tx buffers are returned to the driver with 0 bytes written by the
device. The current code makes it look like we return the number of
received bytes, even though this is not the case since
process_transmit_request always returns 0 for some reason.

Make this more clear by explicitly setting 0 bytes used, and making
process_transmit_request return nothing.

BUG=b:228912920
TEST=cargo build

Change-Id: I9094f7a43847d7e29d5390f274d6650ca5ec7c4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600164
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-05-25 09:12:23 +00:00
Michael Hoyle
c29271e168 Revert "Revert "metrics: Add metrics crate.""
This reverts commit 55a5c8d8f9.

In order to accommodate the removal of the
UnixSeqPacket+CloseNotifier change, I updated the controller.rs
to reference platform-specific internal implementations.

On Windows, CloseNotifier is used to detect closed Tubes.
On Linux, we rely on PollContext returning because the socket fd
    is hung up.

Some minor adjustmets to the code were made just to allow as
litte duplication as possible.

In the end, very little logic has changed from the original CL,
it's just moved around.

TL;DR:
This fixes the downstream regression by removing its dependency
on the breaking changes to base.

BUG=b:232316549
FIXED=b:232316549
TEST=Crosvm tests

Change-Id: I946d5096f7a312538c3c694950697fab1be7f0ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3661257
Commit-Queue: Michael Hoyle <mikehoyle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-25 04:45:13 +00:00
Richard
a19d6ce89c devices: Update rng devices to be platform agnostic
On Unix, instead of getting random data from `/dev/urandom`, it will get
it from the `rand` platform agnostic crate instead.

OsRng.fill_bytes on unix will make a syscall to getrandom(2) if
available, otherwise it will read from `dev/urandom` after a succesful
poll to `dev/random`. Regardless of which way a random data is
retrieved, if the entropy pool is not intialized, `fill_bytes` will
block until it is intialized. This shouldn't be a problem because it is
a one time cost.

This CL will also upstream the Windows implementation of the rng device.

BUG=b:213149162
TEST=built and presubmits

Change-Id: Ic017f11795f8006e0bf2a04eb0478b3a3d336507
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3657812
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
2022-05-25 01:35:13 +00:00
Dennis Kempin
69a55d5540 Re-Enable -v and -vv on dev_container
They have been dropped with the recent refactoring to not use argh.

BUG=None
TEST=./tools/dev_container -v

Change-Id: Ifa65b14d316e27dbb5cef9714fbd3adf110b79e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664051
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-24 23:55:40 +00:00
Paramjit Oberoi
6562f9d118 Don't exit immediately on a guest panic event.
BUG=b:233758484,b:224887095
TEST=manual

Change-Id: I2634f012b7756f7208fc69233b785bddf9b8a818
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3661258
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Paramjit Oberoi <psoberoi@google.com>
Reviewed-by: Vineeth Pillai <vineethrp@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-24 23:50:30 +00:00
Dennis Kempin
0948bc8d3a infra: Initial setup of linux pre/post-submit builders
The builders use the existing dev_container to run tests
for the 3 currently supported architectures on linux:
x86_64, aarch64 and armhf.

A new recipe 'build_linux' has been added runs the
dev_container to build and execute tests.

To share code with other upcoming recipes, some of the
recipe code has been extracted into a shared crosvm
module.

Basic tests for the recipes have been added.

BUG=b:233230344
TEST=./recipes.py test run
./recipes.py run build_linux

Change-Id: I17ecb25c0a0eabdce56537831454ac22d4dc7021
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3654196
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-24 23:13:13 +00:00
Anton Romanov
86939a1337 crosvm: fix logging for commands other than run, add ability to disable syslog output
BUG=b:231388464
TEST=tested manually

Change-Id: I3d0504e28b9fe9e791b801a3d58ff3ba5beef2cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3661922
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Auto-Submit: Anton Romanov <romanton@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-05-24 18:18:25 +00:00
Vikram Auradkar
91d4199d4e crosvm: move unix specific code into sys/unix/
- move command args that have unix specific help messages
- move wait_all_children. Call it through cleanup function.
- move parse_gpu_display_options
- impl Default for DiskOption

Change-Id: Ia2495df278f7213f50cecfa107717e03b504cca8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3649738
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-05-24 17:44:01 +00:00
Rob Clark
82c5129590 rutabaga_gfx: Expose "fake" capset for minigbm
minigbm virtgpu_cross_domain backend checks for this capset.  Eventually
once this check is removed in minigbm (once everyone is using the
context-types arg to control whether cross-domain is exposed) we can
drop the dummy capset.  But we need it for now.

BUG=b:230100768
TEST=gfxbench, android games in arcvm

Change-Id: I7c955c365f439806c797d1d38daef2e1c9b3079f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3608703
Auto-Submit: Rob Clark <robdclark@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-24 15:27:36 +00:00
Rob Clark
d570dc761f rutabaga_gfx: Add cmdline arg to control exposed context types
Add a way to control exposed capsets from cmdline.  This will let us
enable certain context types only in certain VMs, with a single build
of crosvm.

BUG=b:230100768
TEST=gfxbench, android games in arcvm

Change-Id: I8d32a22c4c198566e984b06d6aa545796752c128
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636797
Auto-Submit: Rob Clark <robdclark@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-24 15:27:36 +00:00
Rob Clark
69ecfb0e39 rutabaga_gfx: Add support for drm native contexts
Expose support for the new virtgpu drm native contexts.

BUG=b:230100768
TEST=gfxbench, android games in arcvm

Change-Id: I068e9b14ac47782c9251d9b67156755f2888d17f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3469494
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-05-24 15:27:36 +00:00
Gurchetan Singh
d18f0bac4d devices: gpu: conditionally enable capsets if context_mask is specified
This allows finer grain selection of context types, and eventually deletion
of preprocessor flags and "default component type".

BUG=b:173630595
TEST=compile

Change-Id: I5669911dfd4d6a7fd290e73ed3939d54fabdb89f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3655287
Reviewed-by: Rob Clark <robdclark@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-24 15:27:36 +00:00
Rob Clark
567c777f15 rutabaga_gfx: conditionally enable capsets based RutabagaBuilder input
If the context_mask is specified, only advertise those capability sets.

If not specified, for backwards compatibility, use the older behavior.
Eventually, the older beahvior may be deprecated.

BUG=b:230100768
TEST=gfxbench, android games in arcvm

Change-Id: I3c37f94dfb5df25831d187deff600027aac2382d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636798
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-05-24 15:27:36 +00:00
Gurchetan Singh
3c77043c19 rutabaga_gfx: consolidate flags into the rutabaga builder
A lot of these flags can be deprecated over time.  For example,
specifying the context type and "use_vulkan" is a bit redundant.
Things like "use_syncfd" and "use_guest_angle" can also be removed.

BUG=b:173630595
TEST=compile

Change-Id: I77bff7f02ebfd3b0e65145d144bfc15afa50f386
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3655286
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Commit-Queue: Rob Clark <robdclark@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-24 15:27:36 +00:00
Rob Clark
6d7a90be3a rutabaga_gfx: add context type mask
A way to control exposed capsets.

BUG=b:230100768
TEST=gfxbench, android games in arcvm

Change-Id: I91616405b695be73d6cc872aa5ae2a9dcecd0fb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636799
Commit-Queue: Rob Clark <robdclark@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-24 15:05:16 +00:00
Dennis Kempin
5ea2f62af3 tools: Use git ls-files to discover source files
This fixes little annoyances where fmt or other tools would try to run
on files not part of version control (e.g. local editor configs).

BUG=b:227224259
TEST=./tools/fmt -v

Change-Id: Iddff90ec95a9e28cd80ac3aece26202e8a42e9d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3662022
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-05-23 22:45:44 +00:00
Pierre-Clément Tosi
43f3455d55 dev_container: Properly set --podman default
By passing main(..., podman=args.podman), we mask the function's default
value for that parameter which is False when --podman isn't passed. This
doesn't match what 34811a88ee ("dev_container: Add --podman command
line parameter") says about the flag:

    The parameter [--podman] defaults to true if docker is not installed

Instead, use the computed default for the argument itself.

BUG=b:233346153
TEST=tools/dev_container bash -c 'echo Hello'
Change-Id: I2e5f9855853279a8ceeb9347931d59fd334f0004
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3655968
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Pierre-Clément Tosi <ptosi@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-05-23 22:45:34 +00:00
Colin Cross
1136e3b115 Fix compiling crosvm against x86_64-unknown-linux-musl
Fix some compatibility issues in crosvm to allow it compile against
musl libc:

- Ioctl numbers are ints like bionic, not unsigned long like glibc.
- The sched_param struct has extra fields that must be initialized, zero
  initialize the whole struct.
- libc::pthread_t is void* and doesn't match std::os::unix:🧵:RawPthread,
  it needs a cast.
- Some msghdr and cmsghdr fields are u32 instead of usize.
- cmsghdr has an extra __pad1 fields that must be initialized, zero initialize
  the whole struct.
- msghdr has private __pad1 and __pad2 fields that cannot be initialized,
  zero initialize the whole struct.

Bug: 216192129
Test: m USE_HOST_MUSL=true crosvm
Change-Id: I0652148e09b9a4d167801b002036ec5a575d3bb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3651504
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-23 21:47:12 +00:00
Anton Romanov
9453959c4c crosvm: rework logging
Motivation:
    * simplify and unify, align more with standard log facade
    * code reduction
    * remove hardcoded platform-specific things
    * a little more flexibility
    * easily allow lov level/filtering config as cli argument

Note that there is more code removal than simply loc as updating tests
added few loc

Change-Id: I7beb4b2c28c3462553c6663b234ee38df79f59f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3657053
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Anton Romanov <romanton@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Reviewed-by: Michael Hoyle <mikehoyle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-23 21:11:49 +00:00