2021-10-25 14:19:47 +00:00
|
|
|
# Contributing
|
|
|
|
|
2020-01-21 18:44:09 +00:00
|
|
|
## Intro
|
|
|
|
|
2022-01-25 23:14:43 +00:00
|
|
|
This article goes into detail about multiple areas of interest to contributors, which includes
|
|
|
|
reviewers, developers, and integrators who each share an interest in guiding crosvm's direction.
|
2020-01-21 18:44:09 +00:00
|
|
|
|
2021-10-25 14:22:25 +00:00
|
|
|
## Bug Reports
|
|
|
|
|
|
|
|
We use the Chromium issue tracker. Please use
|
|
|
|
[`OS>Systems>Containers`](https://bugs.chromium.org/p/chromium/issues/list?q=component:OS%3ESystems%3EContainers)
|
|
|
|
component.
|
|
|
|
|
|
|
|
## Philosophy
|
2020-01-21 18:44:09 +00:00
|
|
|
|
|
|
|
The following is high level guidance for producing contributions to crosvm.
|
|
|
|
|
2022-01-25 23:14:43 +00:00
|
|
|
- Prefer mechanism to policy.
|
|
|
|
- Use existing protocols when they are adequate, such as virtio.
|
|
|
|
- Prefer security over code re-use and speed of development.
|
|
|
|
- Only the version of Rust in use by the Chrome OS toolchain is supported. This is ordinarily the
|
|
|
|
stable version of Rust, but can be behind a version for a few weeks.
|
|
|
|
- Avoid distribution specific code.
|
2020-01-21 18:44:09 +00:00
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
## Style guidelines
|
2021-10-25 14:19:47 +00:00
|
|
|
|
2022-01-25 23:14:43 +00:00
|
|
|
To format all code, crosvm defers to rustfmt. In addition, the code adheres to the following rules:
|
2021-10-25 14:19:47 +00:00
|
|
|
|
|
|
|
The `use` statements for each module should be grouped in this order
|
|
|
|
|
2022-01-25 23:14:43 +00:00
|
|
|
1. `std`
|
|
|
|
1. third-party crates
|
|
|
|
1. chrome os crates
|
|
|
|
1. crosvm crates
|
|
|
|
1. `crate`
|
2021-10-25 14:19:47 +00:00
|
|
|
|
2022-01-25 23:14:43 +00:00
|
|
|
crosvm uses the [remain](https://github.com/dtolnay/remain) crate to keep error enums sorted, along
|
|
|
|
with the `#[sorted]` attribute to keep their corresponding match statements in the same order.
|
2021-10-25 14:19:47 +00:00
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
## Contributing Code
|
2021-10-25 14:19:47 +00:00
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
### Prerequisites
|
2021-10-25 14:19:47 +00:00
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
You need to set up a user account with [gerrit](https://chromium-review.googlesource.com/). Once
|
|
|
|
logged in, you can obtain
|
|
|
|
[HTTP Credentials](https://chromium-review.googlesource.com/settings/#HTTPCredentials) to set up git
|
|
|
|
to upload changes.
|
2021-11-01 15:18:42 +00:00
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
Once set up, run `./tools/cl` to install the gerrit commit message hook. This will insert a unique
|
|
|
|
"Change-Id" into all commit messages so gerrit can identify changes.
|
2021-11-01 15:18:42 +00:00
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
### Contributor License Agreement
|
2021-10-25 14:19:47 +00:00
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
Contributions to this project must be accompanied by a Contributor License Agreement (CLA). You (or
|
|
|
|
your employer) retain the copyright to your contribution; this simply gives us permission to use and
|
|
|
|
redistribute your contributions as part of the project. Head over to
|
|
|
|
<https://cla.developers.google.com/> to see your current agreements on file or to sign a new one.
|
2021-10-25 14:19:47 +00:00
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
You generally only need to submit a CLA once, so if you've already submitted one (even if it was for
|
|
|
|
a different project), you probably don't need to do it again.
|
2021-10-25 14:19:47 +00:00
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
### Uploading changes
|
2021-10-25 14:19:47 +00:00
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
To make changes to crosvm, start your work on a new branch tracking `origin/main`.
|
2021-10-25 14:19:47 +00:00
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
```bash
|
|
|
|
git checkout --branch myfeature --track origin/main
|
|
|
|
```
|
|
|
|
|
|
|
|
After making the necessary changes, and testing them via
|
2022-07-29 22:05:14 +00:00
|
|
|
[Presubmit Checks](https://crosvm.dev/book/building_crosvm.html#presubmit-checks), you can commit
|
|
|
|
and upload them:
|
2022-07-21 18:11:46 +00:00
|
|
|
|
|
|
|
```bash
|
2022-01-28 12:16:30 +00:00
|
|
|
git commit
|
2022-08-01 23:02:12 +00:00
|
|
|
./tools/cl upload
|
2021-10-25 14:19:47 +00:00
|
|
|
```
|
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
If you need to revise your change, you can amend the existing commit and upload again:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
git commit --amend
|
|
|
|
./tools/cl upload
|
|
|
|
```
|
|
|
|
|
|
|
|
This will create a new version of the same change in gerrit.
|
|
|
|
|
|
|
|
> Note: We don't accept any pull requests on the [GitHub mirror].
|
2021-10-25 14:19:47 +00:00
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
### Getting Reviews
|
2021-10-25 14:19:47 +00:00
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
All submissions needs to be reviewed by one of the [crosvm owners]. Use the gerrit UI to request a
|
|
|
|
review. If you are uncertain about the correct person to review, reach out to the team via
|
|
|
|
[chat](https://matrix.to/#/#crosvm:matrix.org) or
|
|
|
|
[email list](https://groups.google.com/a/chromium.org/g/crosvm-dev).
|
2021-10-25 14:19:47 +00:00
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
### Submitting code
|
2021-04-30 21:43:25 +00:00
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
Crosvm uses a Commit Queue, which will run pre-submit testing on all changes before merging them
|
|
|
|
into crosvm.
|
2021-04-30 21:43:25 +00:00
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
Once one of the [crosvm owners] has voted "Code-Review+2" on your change, you can use the "Submit to
|
|
|
|
CQ" button, which will trigger the test process.
|
2021-04-30 21:43:25 +00:00
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
Gerrit will show any test failures. Refer to
|
2022-07-29 22:05:14 +00:00
|
|
|
[Building Crosvm](https://crosvm.dev/book/building_crosvm.html) for information on how to run the
|
|
|
|
same tests locally.
|
2021-04-30 21:43:25 +00:00
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
When all tests pass, your change is merged into `origin/main`.
|
2021-04-30 21:43:25 +00:00
|
|
|
|
2021-10-28 10:34:00 +00:00
|
|
|
## Contributing to the documentation
|
|
|
|
|
|
|
|
[The book of crosvm] is build with [mdBook]. Each markdown files must follow
|
|
|
|
[Google Markdown style guide].
|
|
|
|
|
2022-01-25 23:14:43 +00:00
|
|
|
To render the book locally, you need to install mdbook and [mdbook-mermaid], which should be
|
2022-07-07 05:44:52 +00:00
|
|
|
installed when you run `./tools/install-deps`script. Or you can use the `tools/dev_container`
|
|
|
|
environment.
|
2021-10-28 10:34:00 +00:00
|
|
|
|
2022-01-28 12:16:30 +00:00
|
|
|
```sh
|
2022-07-07 05:44:52 +00:00
|
|
|
cd docs/book/
|
2021-10-29 16:08:25 +00:00
|
|
|
mdbook build
|
2021-10-28 10:34:00 +00:00
|
|
|
```
|
|
|
|
|
2022-07-07 05:44:52 +00:00
|
|
|
Output is found at `docs/book/book/html/`.
|
|
|
|
|
2022-01-25 23:14:43 +00:00
|
|
|
> Note: If you make a certain size of changes, it's recommended to reinstall mdbook manually with
|
|
|
|
> `cargo install mdbook`, as `./tools/install-deps` only installs a binary with some convenient
|
|
|
|
> features disabled. For example, the full version of mdbook allows you to edit files while checking
|
|
|
|
> rendered results.
|
2021-10-29 16:08:25 +00:00
|
|
|
|
2022-07-13 17:49:40 +00:00
|
|
|
[crosvm owners]: https://chromium.googlesource.com/crosvm/crosvm/+/HEAD/OWNERS
|
2022-01-25 23:14:43 +00:00
|
|
|
[github mirror]: https://github.com/google/crosvm
|
|
|
|
[google markdown style guide]: https://github.com/google/styleguide/blob/gh-pages/docguide/style.md
|
|
|
|
[mdbook]: https://rust-lang.github.io/mdBook/
|
2021-10-28 10:34:00 +00:00
|
|
|
[mdbook-mermaid]: https://github.com/badboy/mdbook-mermaid
|
2022-07-29 22:05:14 +00:00
|
|
|
[the book of crosvm]: https://crosvm.dev/book/
|