2023-05-16 05:35:46 +00:00
|
|
|
# How to Contribute to crosvm
|
2021-10-25 14:19:47 +00:00
|
|
|
|
2023-03-02 22:51:14 +00:00
|
|
|
## How to report bugs
|
2021-10-25 14:22:25 +00:00
|
|
|
|
2022-10-18 00:49:24 +00:00
|
|
|
We use Google issue tracker. Please use
|
|
|
|
[the public crosvm component](https://issuetracker.google.com/issues?q=status:open%20componentid:1161302).
|
|
|
|
|
|
|
|
**For Googlers**: See [go/crosvm#filing-bugs](https://goto.google.com/crosvm#filing-bugs).
|
2021-10-25 14:22:25 +00:00
|
|
|
|
2023-03-02 22:51:14 +00:00
|
|
|
## Contributing code
|
2021-10-25 14:19:47 +00:00
|
|
|
|
2023-03-02 22:51:14 +00:00
|
|
|
### Gerrit Account
|
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
|
2023-05-10 08:46:37 +00:00
|
|
|
"Change-Id" into all commit messages so gerrit can identify changes. Even warning messages appear,
|
|
|
|
the message hook will be installed.
|
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-10-11 13:35:54 +00:00
|
|
|
### Commit Messages
|
|
|
|
|
|
|
|
As for commit messages, we follow
|
2024-03-19 23:00:53 +00:00
|
|
|
[ChromeOS's guideline](https://www.chromium.org/chromium-os/developer-library/guides/development/contributing/#commit-messages)
|
2022-10-11 13:35:54 +00:00
|
|
|
in general.
|
|
|
|
|
|
|
|
Here is an example of a good commit message:
|
|
|
|
|
|
|
|
```
|
|
|
|
devices: vhost: user: vmm: Add Connection type
|
|
|
|
|
2023-10-03 01:33:00 +00:00
|
|
|
This abstracts away the cross-platform differences:
|
|
|
|
cfg(any(target_os = "android", target_os = "linux")) uses a Unix
|
|
|
|
domain domain stream socket to connect to the vhost-user backend, and
|
2022-10-11 13:35:54 +00:00
|
|
|
cfg(windows) uses a Tube.
|
|
|
|
|
|
|
|
BUG=b:249361790
|
|
|
|
TEST=tools/presubmit --all
|
|
|
|
|
|
|
|
Change-Id: I47651060c2ce3a7e9f850b7ed9af8bd035f82de6
|
|
|
|
```
|
|
|
|
|
|
|
|
- The first line is a subject that starts with a tag that represents which components your commit
|
2023-01-30 23:07:52 +00:00
|
|
|
relates to. Tags are usually the name of the crate you modified such as `devices:` or `base:`. If
|
2022-10-11 13:35:54 +00:00
|
|
|
you only modified a specific component in a crate, you can specify the path to the component as a
|
2023-01-30 23:07:52 +00:00
|
|
|
tag like `devices: vhost: user:`. If your commit modified multiple crates, specify the crate where
|
|
|
|
your main change exists. The subject should be no more than 50 characters, including any tags.
|
2022-10-11 13:35:54 +00:00
|
|
|
- The body should consist of a motivation followed by an impact/action. The body text should be
|
|
|
|
wrapped to 72 characters.
|
|
|
|
- `BUG` lines are used to specify an associated issue number. If the issue is filed at
|
2023-01-30 23:07:52 +00:00
|
|
|
[Google's issue tracker](https://issuetracker.google.com/), write `BUG=b:<bug number>`. If no
|
2022-10-11 13:35:54 +00:00
|
|
|
issue is associated, write `BUG=None`. You can have multiple `BUG` lines.
|
|
|
|
- `TEST` lines are used to describe how you tested your commit in a free form. You can have multiple
|
|
|
|
`TEST` lines.
|
|
|
|
- `Change-Id` is used to identify your change on Gerrit. It's inserted by the gerrit commit message
|
|
|
|
hook as explained in
|
2023-03-02 22:51:14 +00:00
|
|
|
[the previous section](https://crosvm.dev/book/contributing/index.html#gerrit-account). If a new
|
2023-01-30 23:07:52 +00:00
|
|
|
commit is uploaded with the same `Change-Id` as an existing CL's `Change-Id`, gerrit will
|
|
|
|
recognize the new commit as a new patchset of the existing CL.
|
2022-10-11 13:35:54 +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
|
2023-08-03 18:21:08 +00:00
|
|
|
git checkout -b myfeature --track origin/main
|
2022-07-21 18:11:46 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
After making the necessary changes, and testing them via
|
2024-01-08 20:36:25 +00:00
|
|
|
[Presubmit Checks](https://crosvm.dev/book/building_crosvm/linux.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.
|
|
|
|
|
2023-09-13 23:06:48 +00:00
|
|
|
If the branch contains multiple commits, each one will be uploaded as a separate review, and they
|
|
|
|
will be linked in Gerrit as [related changes]. You may revise any commit in a branch using tools
|
|
|
|
like `git rebase` and then re-upload the whole series with `./tools/cl upload` when `HEAD` is
|
|
|
|
pointing to the tip of the branch.
|
|
|
|
|
2022-07-21 18:11:46 +00:00
|
|
|
> 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
|
2024-01-08 20:36:25 +00:00
|
|
|
[Building Crosvm](https://crosvm.dev/book/building_crosvm/) for information on how to run the same
|
|
|
|
tests locally.
|
2021-04-30 21:43:25 +00:00
|
|
|
|
2023-09-13 23:06:48 +00:00
|
|
|
Each individual change in a patch series must build and pass the tests. If you are working on a
|
|
|
|
series of related changes, ensure that each incremental commit does not cause test regressions or
|
|
|
|
break the build if it is merged without the later changes in the series. For example, an
|
|
|
|
intermediate change must not trigger any unused code warnings or cause test failures that are fixed
|
|
|
|
by later changes in the series.
|
|
|
|
|
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
|
|
|
|
|
2023-01-30 23:07:52 +00:00
|
|
|
[The book of crosvm] is built with [mdBook]. Each markdown file must follow
|
2021-10-28 10:34:00 +00:00
|
|
|
[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
|
2023-01-30 23:07:52 +00:00
|
|
|
installed when you run `./tools/install-deps` script. Or you can use the `tools/dev_container`
|
2022-07-07 05:44:52 +00:00
|
|
|
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/`.
|
|
|
|
|
2023-07-25 14:36:03 +00:00
|
|
|
To format markdown files, run `./tools/fmt` in the `dev_container`.
|
|
|
|
|
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
|
2023-09-13 23:06:48 +00:00
|
|
|
[related changes]: https://gerrit-review.googlesource.com/Documentation/user-review-ui.html#related-changes
|
2022-07-29 22:05:14 +00:00
|
|
|
[the book of crosvm]: https://crosvm.dev/book/
|