Commit graph

3472 commits

Author SHA1 Message Date
Dennis Kempin
970b00fa4d Add documentation for ChromeOS workflows
This change consolidates some of the spread out information about
what ChromeOS developers need to know about crosvms differences to
other ChromeOS projects.

I created a new directory since I would expect a similar guide for
AOSP eventually.

This also adds more documentation on some of the process changes
suggested in go/crosvm-merge-improvements to improve the
stability of the merge process.

BUG=b:227475914
TEST=None

Change-Id: I08111ecd5a937fde22c7d97f342c1cf02f49b02e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3561886
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-04-18 19:05:49 +00:00
Dennis Kempin
aac461e25e Remove temporarily duplicated code from codebase
This removes sys_util(_core), which moved into base::unix/common, as
well as common/(cros_async,io_uring), which moved into the root
directory.

The only reason the code was still around is that they were still
used in the ChromeOS codebase.
ChromeOS has pinned the version of crosvm it uses for these libraries
so we can go ahead and remove the code.

A few remaining references to sys_util have been updated to base.

BUG=b:227226222,b:229016539
TEST=presubmit

Change-Id: I35a3d1f0ea28182b77abf9b423fcab4cad525981
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3580118
Reviewed-by: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-04-18 18:35:07 +00:00
Elliot Berman
c903a58f86 aarch64: Abstract KVM register read/writes
Remove KVM-specific code from the generic aarch64 module by providing a
generic enum for hypervisor-specific vCpus to use instead:
VCpuRegAArch64.

Change-Id: Idd7379ad35943622c534b5e0d954ec15f9d15b41
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3586723
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Moreland <smoreland@google.com>
2022-04-18 17:58:06 +00:00
Elliot Berman
d28ce639c6 linux: Prepare to run with multiple hypervisors
Move KVM-specific code to "run_kvm" function in preparation for
supporting different hypervisors.

Change-Id: I02b81478ded893a0ee67e132f12d637912491fea
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3586011
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Moreland <smoreland@google.com>
2022-04-15 22:23:33 +00:00
Elliot Berman
53d9530f36 linux: Drop kvm_ prefix from vcpu_ids
Simple rename to emphasize that vcpu_ids are not KVM-specific.

Change-Id: Icaf8a5f15a83021cf48467b0b8d0042ab0ab4a92
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3586010
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Moreland <smoreland@google.com>
2022-04-15 22:23:32 +00:00
Dennis Kempin
af594fe6a6 Merge bot: A few minor tweaks
- Don't try to download gcompute tools multiple times
- Fix off-by-one error in merge log calculation.
- Fail if gerrit upload fails repeatedly

BUG=None
TEST=./tools/chromeos/merge-bot update-dry-runs

Change-Id: I9e845455f8c5209c38aee1bcd6bb1b2b81a3d99a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3585019
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-04-15 20:40:00 +00:00
Dennis Kempin
77569908de Merge bot: Always set up username on gce
Sligthly changes the logic. If we are on GCE, always use the authdaemon
and set up the git user info for the service account.

Outside of GCE just check if a cookie is available.

BUG=None
TEST=Faked out is_gce_instance and ran locally

Change-Id: Icf4c521b650b5d47f395a59695d1f1470621f661
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3585016
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-04-15 19:59:57 +00:00
Dennis Kempin
fe433eb18f Add version pin warning to common/
Could be added to README.md, but who reads those...

BUG=b:229016539
TEST=None

Change-Id: I3cc0f3672999926018fae572d8966dd971dcf80f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3586142
Reviewed-by: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-04-15 19:51:35 +00:00
Dennis Kempin
a3249a7fef Merge bot: Actually execute clone of gcompute-tools
BUG=None
TEST=Ran locally, but cannot test actually running the tool outside of
GCE.

Change-Id: I4483d8ea75fceb3d289a38d2aa3b8c6f85985dfa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3588403
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-04-15 19:31:18 +00:00
Dennis Kempin
ba4adc0efb Add python presubmit checks
This change adds python type and formatting checks and
consolidates code health checks in ./tools/health-check.

Dealing with relative imports in python is tricky, so
we are making ./tools/impl a proper package with no
directly executable files.

Some of the bash shorthands in ./tools had to be converted
to python for this.

To make the new checks pass, we run the formatter and fix
some mypy type checks.

TEST=./tools/health-check
BUG=b:218559722,b:219965702

Change-Id: Ie18d3d6dd2f5a033141e167a6e1aa762791941d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3558592
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-04-15 19:22:53 +00:00
Dennis Kempin
335aaf6ad2 common.py allow absolute paths to programs
This would previously trigger a program not found error.

BUG=None
TEST=Added doctest

Change-Id: I357c44d2b9ce7b2a3240958c5c88008a29164baa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3587885
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-04-15 18:42:27 +00:00
Dennis Kempin
0506ac6549 Curl with headers to get GCE metadata
Metadata-Flavor is a header and not part of the body.

BUG=None
TEST=Has to be tested in GCE.

Change-Id: I92711a86502d19601a5f2d63e6a653743b5b2614
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3579815
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-04-14 23:33:54 +00:00
Dennis Kempin
cc6642deff Do not use curl --fail-with-body
The curl version of Kokoro is too old and does not know it.

BUG=None
TEST=testing in prod.

Change-Id: I8e1fe856dcd893944da06f6a9097497a9c320c43
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3584319
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-04-14 22:51:29 +00:00
Dennis Kempin
f334e19ffc merge bot: Do not check result of git config
If the value is not set, treat it as empty.

BUG=None
TEST=Tested by removing the config setting locally.

Change-Id: Ia160285c03bffcf7a332f3891587e7ada2228623
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3585860
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-04-14 22:43:59 +00:00
Dennis Kempin
45df242c01 merge bot: Skip installing python version if it exists already
If the version is installed, but not the default selected, pyenv
can fail.

BUG=None
TEST=Testing in prod..

Change-Id: I5063051dd300f9dbbb057e429a84062341b3324c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3585859
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-04-14 22:23:43 +00:00
Dennis Kempin
9740b944eb merge buildes: Fix formatting of version check
The script broke after the formatter wrapped the string.

BUG=None
TEST=./ci/kokoro/simulate.py build-merge-into-chromeos.sh

Change-Id: Id6e972d786d5a58f6cbb43f80d02f0aa26483967
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3585858
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-04-14 22:06:34 +00:00
Dennis Kempin
b193738186 New merge bot
The new merge bot is written in python to allow us to improve the
merge process.

The new process is as follows:
- The merge bot will only create a new merge when the previous
  ones have been submitted.
- When the bot creates a new merge, it'll split the merge commits
  into smaller changes to make bisection easier.

This allows us to only ever deal with one set of merge commits
instead of piling on new merges day after day.

For dry runs, the new process is:
- The bot will check existing dry runs and abandon them if the CQ
  is done.
- The bot will vote Verified+-1 to indicate if the dry run passed.
- If no more dry runs are active, it'll create a new one.

This ensures we always have a dry run in the CQ and can easily see
in gerrit which ones have passed.

The python script will also allow us to add convenience features
for oncall for retrying bratches, etc.

BUG=b:227347397
TEST=The script can be run locally:
./tools/chromeos/merge_bot update-merges
./tools/chromeos/merge_bot update-dry-runs

Change-Id: I51fc0741f5032868ad07f5e926e570e29cc461fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3583254
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-04-14 21:38:07 +00:00
Dennis Kempin
a7d91e5f66 p9: Remove dependency on sys_util
The read_dir utility was only used by p9. Other code uses fs::read_dir,
so we can move it from base::unix into p9.

BUG=b:229114164
TEST=presubmit

Change-Id: I9bd12b11233582245db8251aeb3d4480170a2d48
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3584628
Reviewed-by: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-04-14 20:32:59 +00:00
Dennis Kempin
d1440454f5 Remove *_stub crates from workspace
These were erronously added by https://crrev.com/c/3530503

BUG=b:228384796
TEST=None

Change-Id: Id13fd1568e897025cc917c7af4f0bd711185bf1e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3575715
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-04-14 19:13:30 +00:00
Junichi Uekawa
835bfc3cfa Revert "crosvm_control: Generate C header during build"
This reverts commit 06fca32aff.

Reason for revert: cros side dependency is not there yet

Original change's description:
> crosvm_control: Generate C header during build
>
> Generates a C header for the crosvm_control library during crosvm build.
>
> BUG=b:188858559
> TEST=cq
>
> Cq-Depend: chromium:3553666
> Change-Id: Ic6d57d654f546a4ddf9facad16d29a03c103ebbe
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3553761
> Reviewed-by: Dennis Kempin <denniskempin@google.com>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Kameron Lutes <kalutes@chromium.org>

Bug: b:188858559
Change-Id: I34a2d970415f95f559678520901340c1d8e6297a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3581450
Auto-Submit: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2022-04-14 12:48:22 +00:00
Junichi Uekawa
e8d38a6a8f crosvm: Logic for newline for help message.
Now we know the exact line size of the leading part of the help message
we can do a better logic for inserting a newline.

BUG=None
TEST=unit

Change-Id: Ia29ea9876199cfcef4cb97dd64eecbc71c6bcd60
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3581829
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-04-14 07:33:14 +00:00
Lepton Wu
90f58ccc27 Add help message for host-cpu-topology flag.
BUG=b:220638871
TEST=emerge-$BOARD crosvm

Change-Id: Ib9d825ebe64e8edfdb46f58100e6417b90eacfc5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3584833
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Lepton Wu <lepton@chromium.org>
2022-04-14 02:13:49 +00:00
Kameron Lutes
06fca32aff crosvm_control: Generate C header during build
Generates a C header for the crosvm_control library during crosvm build.

BUG=b:188858559
TEST=cq

Cq-Depend: chromium:3553666
Change-Id: Ic6d57d654f546a4ddf9facad16d29a03c103ebbe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3553761
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kameron Lutes <kalutes@chromium.org>
2022-04-13 23:37:32 +00:00
Shao-Chuan Lee
105d68747b Revert "rutabaga_gfx: remove fence polling and enable async callback"
This reverts commit a999284da2.

This also introduces two extra `use` statements to fix the corresponding
errors in the LUCI build, which did not occur in local builds.

Reason for revert: caused deadlock in virglrenderer

Original change's description:
> rutabaga_gfx: remove fence polling and enable async callback
>
> Now that rutabaga users can provide a callback for fence
> completion, fences no longer need to be polled on the main thread.
>
> Optional polling still occurs for Rutabaga Components that still
> rely on it for other purposes (e.g. virglrenderer for GL query
> checking).
>
> Also, use a BTreeMap rather a HashMap since we only expect a dozen
> or so entries at most.  In such cases, a BTreeMap is faster.
>
> * v1 (lfrb@collabora.com): remove all polling + add async_cb
> * v2 (ryanneph@google.com): re-introduce optional polling to fix
>       virglrenderer that relies on it for GL query checking.
> * v3 (ryanneph@google.com): replace timer-based polling with
>       eventfd-based poll() signaling for components that want to
>       use it.
>
> BUG=b:175527587
> TEST=glxgears and vkcube in a crosvm guest VM.
>
> Cq-Depend: chromium:3555854, chromium:3563893
> Change-Id: I8e0181317e954cd15e2b8dc04c9b1329b0a6e182
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2860746
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Ryan Neph <ryanneph@google.com>

BUG=b:175527587,b:228782431,b:228521246
TEST=arc.Notification.vm on kukui-arc-r
TEST=dEQP-VK.wsi.android.swapchain.create#image_usage on dedede/kukui-arc-r

Change-Id: I616e3f283a60fe6a260f796cddce67c548b5e304
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3584076
Reviewed-by: Kazuhiro Inaba <kinaba@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2022-04-13 17:46:41 +00:00
Shao-Chuan Lee
a1fac454ed Revert "gfxstream: support async fence cb"
This reverts commit 3c2d5cefa2.

Reason for revert: depends on crrev.com/c/2860746

Original change's description:
> gfxstream: support async fence cb
>
> This adds the asynchronous interrupts in crosvm-gpu for gfxstream.
> This will allow gfxstream to alternate between the main signalling
> method (ASG [1]) and the more traditional interrupts when it
> makes sense performance-wise.
>
> gfxstream also requires new write fence callbacks that take into
> account the ring_idx and ctx_id where the fence is on.
>
> [1] goto.google.com/address-space-graphics
>
> BUG=b:192614792
> TEST=Tested locally with Vulkan cereal
>
> Change-Id: I010d9ebfc71594b393fee062b984a4c6d69404d8
> Reviewed-on:
> https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3027489
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>

BUG=b:192614792,b:228782431,b:228521246
TEST=arc.Notification.vm on kukui-arc-r
TEST=dEQP-VK.wsi.android.swapchain.create#image_usage on
dedede/kukui-arc-r

Change-Id: I4d2c43320880e38e8396cee3b96ce8c32addf39b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3584075
Reviewed-by: Kazuhiro Inaba <kinaba@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2022-04-13 17:46:40 +00:00
Shao-Chuan Lee
c6d01ebdbc Revert "rutabaga_gfx: enable per-context/per-ring fencing for virgl_renderer"
This reverts commit 8452832b97.

Reason for revert: depends on crrev.com/c/2860746

Original change's description:
> rutabaga_gfx: enable per-context/per-ring fencing for virgl_renderer
>
> Permits virglrenderer contexts to make use of per-context/per-ring
> fencing.
>
> BUG=b:193892617
> TEST=Run glxgears and vkcube in a crosvm guest VM.
>
> Change-Id: I9800d3fbab788602a25f2a118619910300126d4b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3453115
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Ryan Neph <ryanneph@google.com>

BUG=b:193892617,b:228782431,b:228521246
TEST=arc.Notification.vm on kukui-arc-r
TEST=dEQP-VK.wsi.android.swapchain.create#image_usage on dedede/kukui-arc-r

Change-Id: I96be478ed4b994c3ccffa5b3cbc2de00a06332f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3584074
Reviewed-by: Kazuhiro Inaba <kinaba@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2022-04-13 17:46:39 +00:00
Vikram Auradkar
413ec71451 base: fix doc test
Without this change `cargo test --doc` from `/base/` directory
would fail

BUG=b:213153157
TEST=cd base; cargo test --doc

Change-Id: I3a23a33b96237a663c0f6887c18bffdf2d25881e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3584831
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-04-13 16:42:04 +00:00
Vikram Auradkar
a0c4acaf80 book: Add style guide
BUG=b:227345067
TEST=mdbook build

Change-Id: I689b8f92512ed8b97872c67b6bf31833a7fa78a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3557813
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-04-13 13:49:50 +00:00
David LeGare
740c824fe8 Update to gdbstub 0.6.1
Update the GDB stub implementation to the 0.6 version of the gdbstub
crate API, attempting to preserve the current behavior as much as
possible. Hardware breakpoints and single stepping still work, but some
existing issues with software breakpoints are still present.

BUG=None
TEST=Manual

Cq-Depend: chromium:3578400
Change-Id: I522242a1a2055ecdf47b2010a615dc9e0136ebd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578025
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: David LeGare <legare@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-04-13 12:52:24 +00:00
Keiichi Watanabe
c59db48131 devices: vvu: Unbind driver first regardless of driver type
When a VVU driver starts, the current implementation tries to unbind
virtio-pci driver unconditionally, but this can fail when no driver is
bounded or another driver is bounded.

Instead of assuming virtio-pci driver is bounded, we should unbind the
bounded driver regardless of its type by writing to
"/sys/bus/pci/devices/${ADDR}/driver/unbind", which is a symlink to the
unbind file of the currently bounded driver.

This change will allow the vvu driver to open a vvu device after a previous
driver exists. (Note that our vvu device hasn't supported
reinitialization yet.)

BUG=b:216407443
TEST=run vvu on workstation

Change-Id: Ib6c3ac1cd51a8018573596eef9fe0fd759450c07
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3581833
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-04-13 02:27:28 +00:00
Keiichi Watanabe
98dd4c211a docs: Generate API docs only for first-party crates
Pass `--workspace` and `--no-deps` as cargo-doc's arguements.
As a result:
* it won't generate API docs for third-party crates
* it'll generate API docs for our first crates that are not used by the
  minimal crosvm build. (e.g. qcow_utils, libvda, etc)

BUG=none
TEST=test on personal GitHub

Change-Id: I8911eb7d830f1cda77d264c1dc19ff948cfa4768
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578146
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-04-12 22:59:34 +00:00
Keiichi Watanabe
c1ae5cdc49 docs: Generate API docs for non-public items
BUG=b:222030094
TEST=test on my personal GitHub account

Change-Id: I45bc1a3d365bfa170890cee93fef7788d684bbf7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578145
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-04-12 22:59:33 +00:00
Keiichi Watanabe
901cd7df7f Reland "github: Minimize dependencies for document generation"
This is a reland of commit 2b85d4d1e5

Diff from the original CL:
* Changed the return value of `main()` in power_monitor/build.rs
* Ran cargo-check with all features enabled

Original change's description:
> github: Minimize dependencies for document generation
>
> Instead of install full dependencies with `install-deps` in GitHub
> action, minimize dependencies because we use GitHub only for document
> generation.
>
> - Passed `CARGO_DOC` environment when running cargo-doc command so we
>   can skip unnecessary build flow when we just want to generate API docs.
> - Added a new script `install-docs-deps` to install only doc-related
>   dependencies.
>
> BUG=none
> TEST=test on GitHub Action at my personal repository
>
> Change-Id: Ibe988ab43215e285d946812bdd6c1536ae87b50e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578144
> Tested-by: kokoro <noreply+kokoro@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Reviewed-by: Anton Romanov <romanton@google.com>
> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>

Bug=none
TEST=cargo check --all-features

Change-Id: I77ee6543910e3fe7f69be48f8f965eda3433d4e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3584063
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-04-12 22:30:10 +00:00
Lepton Wu
d33666bbd7 x86: Advertise hwp related features.
intel pstate cpufreq driver requires these to work.

BUG=b:220638871
TEST=manual - check cpuinfo_max_freq under sysfs

Change-Id: Ia5ee0aa700520f7ae19f3cb3da3ecfaa2641eceb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3583066
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Lepton Wu <lepton@chromium.org>
2022-04-12 17:23:31 +00:00
Junichi Uekawa
7af06dfc70 Revert "github: Minimize dependencies for document generation"
This reverts commit 2b85d4d1e5.

Reason for revert: breaks powerd compile

Original change's description:
> github: Minimize dependencies for document generation
>
> Instead of install full dependencies with `install-deps` in GitHub
> action, minimize dependencies because we use GitHub only for document
> generation.
>
> - Passed `CARGO_DOC` environment when running cargo-doc command so we
>   can skip unnecessary build flow when we just want to generate API docs.
> - Added a new script `install-docs-deps` to install only doc-related
>   dependencies.
>
> BUG=none
> TEST=test on GitHub Action at my personal repository
>
> Change-Id: Ibe988ab43215e285d946812bdd6c1536ae87b50e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578144
> Tested-by: kokoro <noreply+kokoro@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Reviewed-by: Anton Romanov <romanton@google.com>
> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>

Bug: none
Change-Id: Ie16b65235490071ac4e69bf3f09af3ba0c766eab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3581836
Auto-Submit: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-04-12 13:15:16 +00:00
Junichi Uekawa
3c9351b446 argument: Use terminal_size crate for getting terminal size.
BUG=None
TEST=crosvm help  # reflows at width even in my emacs shell.

Change-Id: I18afb7e359f369d1a0f5291bb7386f84769efe81
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3556929
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-04-12 10:42:12 +00:00
Junichi Uekawa
5b414d97ec argument: Automatically reflow help messages.
Long help messages are not really easy to display, and they had to be
manually indented 30 spaces to be consistent. Let the machine do that
computation. Just use a space to delimit and assume ASCII.

BUG=None
TEST=crosvm run --help looks reasonable.

Change-Id: If846d7ec21be14941049b50d25a1401ed6dd8af0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3524465
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-04-12 08:58:05 +00:00
Alexandre Courbot
2128b2f2d4 plugin: fix clippy warning
Clippy warns us that this block can be collapsed.

BUG=None
TEST=cargo clippy --features plugin

Change-Id: Ie094f85a79ffca210e42744237e8f2f0067045d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3581830
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-04-12 04:37:47 +00:00
Alexandre Courbot
b32bcc4edc devices: vvu: handler: do not run executor within async method
run_vvu() was running the request handling loop on the executor passed
as argument, even though it is an async function that is being run on
the very same executor.

BUG=b:194137301
TEST=VVU console device is working.

Change-Id: I8c79f9285329c07b3411b2d4121c94d0e5c88a49
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578142
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-04-12 02:11:37 +00:00
Keiichi Watanabe
2b85d4d1e5 github: Minimize dependencies for document generation
Instead of install full dependencies with `install-deps` in GitHub
action, minimize dependencies because we use GitHub only for document
generation.

- Passed `CARGO_DOC` environment when running cargo-doc command so we
  can skip unnecessary build flow when we just want to generate API docs.
- Added a new script `install-docs-deps` to install only doc-related
  dependencies.

BUG=none
TEST=test on GitHub Action at my personal repository

Change-Id: Ibe988ab43215e285d946812bdd6c1536ae87b50e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578144
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-04-12 01:41:37 +00:00
Daniel Verkamp
772a28edca base: move Windows-only deps into the target section
chrono, rand, and regex are only needed in the Windows parts of base for
now; remove them from the common dependencies so we don't need to
compile them for Linux builds.

BUG=None
TEST=cargo build --timings

Change-Id: Ib62d8e9c71860a4e924a05c8453c6bd54ba7ecf8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3579725
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-12 00:49:29 +00:00
Daniel Verkamp
f620437e8b virtio_sys: regenerate bindings
BUG=b:218388029
TEST=tools/presubmit --quick

Change-Id: I381dbc4d97e3a0a99dedd4416a347388daf4ccf8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3339853
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-11 21:14:01 +00:00
Daniel Verkamp
f35f636cc5 Rust 1.60 clippy fixes
BUG=None
TEST=tools/presubmit # with rust-toolchain updated to 1.60.0

Change-Id: I5772e8b0593f8d92003e93aeb2145e87610abe2e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3577332
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-11 20:40:36 +00:00
Daniel Verkamp
a795bfff65 base: move descriptor traits and fns out of lib.rs
Common descriptor code can be moved into the appropriate descriptor.rs
and platform-specific files instead of living in the top-level base
lib.rs file.

BUG=None
TEST=tools/presubmit
TEST=kokoro ci

Change-Id: I07b8d822c40b563cffd12c7726a5c126bc1a0e10
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3573363
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-11 20:27:09 +00:00
Daniel Verkamp
3894aa042a base: remove wrap_descriptor
After the preceding patch series, it is now unused.

BUG=None
TEST=tools/presubmit

Change-Id: I8639357db101517de830ef4e3e33bc40980391b3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3572771
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-11 20:27:07 +00:00
Daniel Verkamp
fa0ffe7e81 base: accept AsRawDescriptor in PollContext/EpollContext/mmap
This lets us remove the wrap_descriptor() calls.

A few other places around the tree need to be updated to use Descriptor
instead of RawFd to match the new API.

BUG=None
TEST=tools/presubmit

Change-Id: Ie290f082b50bcf6ae8f77ce6a8b7615fad1be480
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3572770
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-11 20:27:06 +00:00
Peter Fang
63c3a69e21 devices: vfio_pci: implement coordinated PM using PCI config accesses
Perform coordinated PM in the hypervisor for vfio-pci devices using
several sysfs interfaces added to the hypervisor kernel.

The interfaces used and the PCI header hacks are identical to the ones
previously added to pcie.

This is only a temporary solution. A proper communication channel should
be implemented in the future.

BUG=b:189182339
TEST=boot manatee and verify the sysfs interfaces are used correctly in
     the hypervisor

Change-Id: I8022ed17e4bf898065b5ebcf8fe09f5c8e3c3fa4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578021
Reviewed-by: Dmytro Maluka <dmy@semihalf.com>
Reviewed-by: Tomasz Nowicki <tnowicki@google.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-11 19:09:27 +00:00
Peter Fang
87f947a4ff pcie: implement coordinated PM using PCI config accesses
Perform coordinated PM in the hypervisor using several sysfs interfaces
added to the hypervisor kernel.

- /sys/bus/pci/devices/X/power/coordinated
  Writing "enter" to this file will cause the device to enter PCI
  coordinated PM
  Writing "exit" to this file will cause the device to exit PCI
  coordinated PM

- /sys/bus/pci/devices/X/power/op_call
  A write to this file will cause the device to perform a PCI PM
  operation

- /sys/bus/pci/devices/X/power_state
  A read from this file returns a snapshot of the device's current power
  state, including PCI_D3cold

The guest makes use of these interfaces through a couple of
quick-and-dirty hacks in the PCI header in the guest.

- Byte writes to the "Revision ID" register are interpreted as PM op
  calls
- Reads from the "BIST" register are interpreted as device PCI power
  state

The PCI spec defines the "Revision ID" register as read-only. The "BIST"
register is mostly considered legacy and its use has not been observed
in recent Chromebooks.

The rest of the PCI config accesses remain the same.

This is only a temporary solution. A proper communication channel should
be implemented in the future.

BUG=b:189182339
TEST=boot manatee and verify the sysfs interfaces are used correctly in
     the hypervisor

Change-Id: I7570728257300435d0fc77076d1e3f6bea6af5e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3455125
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dmytro Maluka <dmy@semihalf.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-04-11 17:54:51 +00:00
David Stevens
4257919fa7 devices: vvu: poll when opening vvu device
Launching a VVU device requires access to /dev/vfio/$vfio_group. The
permissions on those files can't be set by upstart, since the files
don't exist until a vvu device process binds its vvu pci device to
vfio-pci. Instead, the permissions are set via udev rules.
Unfortunately, there is no good way to wait for udev to modify the
permissions, so the device process just needs to poll until it is
successfully able to open its device.

BUG=b:222424090
TEST=vmc start termina

Change-Id: Id8668c66ff7ddaa7bb43061979ead51d12cde8f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3574422
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-04-11 04:56:18 +00:00
Daniel Verkamp
aebda741ff devices: pci: convert PciAddress::from_string into FromStr impl
Implement the standard FromStr trait, since it has the same prototype as
our existing from_string function.

BUG=None
TEST=cargo test -p devices pci_address

Change-Id: I41bb77638891bfcc39f9fb555b3463f2f92c029f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3576956
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-04-08 19:42:39 +00:00