xref: /aosp_15_r20/external/crosvm/docs/book/src/integration/chromeos.md (revision bb4ee6a4ae7042d18b07a98463b9c8b875e44b39)
1*bb4ee6a4SAndroid Build Coastguard Worker# Crosvm on ChromeOS
2*bb4ee6a4SAndroid Build Coastguard Worker
3*bb4ee6a4SAndroid Build Coastguard WorkerA copy of crosvm is included in the ChromeOS source tree at [chromiumos/platform/crosvm], which is
4*bb4ee6a4SAndroid Build Coastguard Workerreferred to as **downstream** crosvm.
5*bb4ee6a4SAndroid Build Coastguard Worker
6*bb4ee6a4SAndroid Build Coastguard WorkerAll crosvm development is happening **upstream** at [crosvm/crosvm]. Changes from upstream crosvm
7*bb4ee6a4SAndroid Build Coastguard Workerare regularly merged with ChromeOS's downstream crosvm.
8*bb4ee6a4SAndroid Build Coastguard Worker
9*bb4ee6a4SAndroid Build Coastguard Worker## The merge process.
10*bb4ee6a4SAndroid Build Coastguard Worker
11*bb4ee6a4SAndroid Build Coastguard WorkerA crosvm bot will regularly generate automated commits that merge upstream crosvm into downstream.
12*bb4ee6a4SAndroid Build Coastguard WorkerThese commits can be found in
13*bb4ee6a4SAndroid Build Coastguard Worker[gerrit](https://chromium-review.googlesource.com/q/hashtag:crosvm-merge).
14*bb4ee6a4SAndroid Build Coastguard Worker
15*bb4ee6a4SAndroid Build Coastguard WorkerThe crosvm team is submitting these merges through the ChromeOS CQ regularly, which happens
16*bb4ee6a4SAndroid Build Coastguard Worker**roughly once per week**, but time can vary depending on CQ health.
17*bb4ee6a4SAndroid Build Coastguard Worker
18*bb4ee6a4SAndroid Build Coastguard WorkerGooglers can find more information on the merge process at [go/crosvm-uprev-playbook].
19*bb4ee6a4SAndroid Build Coastguard Worker
20*bb4ee6a4SAndroid Build Coastguard Worker## Building crosvm for ChromeOS
21*bb4ee6a4SAndroid Build Coastguard Worker
22*bb4ee6a4SAndroid Build Coastguard Workercrosvm on ChromeOS is usually built with Portage, so it follows the same general workflow as any
23*bb4ee6a4SAndroid Build Coastguard Worker`cros_workon` package. The full package name is `chromeos-base/crosvm`.
24*bb4ee6a4SAndroid Build Coastguard Worker
25*bb4ee6a4SAndroid Build Coastguard WorkerThe developer guide section on
26*bb4ee6a4SAndroid Build Coastguard Worker[Make your Changes](https://www.chromium.org/chromium-os/developer-library/guides/development/developer-guide/#make-your-changes)
27*bb4ee6a4SAndroid Build Coastguard Workerapplies to crosvm as well. You can specify the development version to be built with cros_workon, and
28*bb4ee6a4SAndroid Build Coastguard Workerbuild with cros build-packages. Consecutive builds without changes to dependency can be done with
29*bb4ee6a4SAndroid Build Coastguard Workeremerge.
30*bb4ee6a4SAndroid Build Coastguard Worker
31*bb4ee6a4SAndroid Build Coastguard Worker```bash
32*bb4ee6a4SAndroid Build Coastguard Worker(chroot)$ cros_workon --board=${BOARD} start chromeos-base/crosvm
33*bb4ee6a4SAndroid Build Coastguard Worker(chroot or host)$ cros build-packages --board=${BOARD} chromeos-base/crosvm
34*bb4ee6a4SAndroid Build Coastguard Worker(chroot)$ emerge-${BOARD} chromeos-base/crosvm -j 10
35*bb4ee6a4SAndroid Build Coastguard Worker```
36*bb4ee6a4SAndroid Build Coastguard Worker
37*bb4ee6a4SAndroid Build Coastguard WorkerDeploy it via `cros deploy`:
38*bb4ee6a4SAndroid Build Coastguard Worker
39*bb4ee6a4SAndroid Build Coastguard Worker```bash
40*bb4ee6a4SAndroid Build Coastguard Worker(chroot)$ cros deploy ${IP} crosvm
41*bb4ee6a4SAndroid Build Coastguard Worker```
42*bb4ee6a4SAndroid Build Coastguard Worker
43*bb4ee6a4SAndroid Build Coastguard WorkerIterative test runs can be done as well:
44*bb4ee6a4SAndroid Build Coastguard Worker
45*bb4ee6a4SAndroid Build Coastguard Worker```bash
46*bb4ee6a4SAndroid Build Coastguard Worker(chroot)$ FEATURES=test emerge-${BOARD} chromeos-base/crosvm -j 10
47*bb4ee6a4SAndroid Build Coastguard Worker```
48*bb4ee6a4SAndroid Build Coastguard Worker
49*bb4ee6a4SAndroid Build Coastguard WorkerWarning: Using `cros_workon_make` is possible but patches the local Cargo.toml file and some
50*bb4ee6a4SAndroid Build Coastguard Workerconfiguration files. Please do not submit these changes. Also something makes it rebuild a lot of
51*bb4ee6a4SAndroid Build Coastguard Workerthe files.
52*bb4ee6a4SAndroid Build Coastguard Worker
53*bb4ee6a4SAndroid Build Coastguard Worker### Rebuilding all crosvm dependencies
54*bb4ee6a4SAndroid Build Coastguard Worker
55*bb4ee6a4SAndroid Build Coastguard WorkerCrosvm has a lot of rust dependencies that are installed into a registry inside cros_sdk. After a
56*bb4ee6a4SAndroid Build Coastguard Worker`repo sync` these can be out of date, causing compilation issues. To make sure all dependencies are
57*bb4ee6a4SAndroid Build Coastguard Workerup to date, run:
58*bb4ee6a4SAndroid Build Coastguard Worker
59*bb4ee6a4SAndroid Build Coastguard Worker```bash
60*bb4ee6a4SAndroid Build Coastguard Worker(chroot or host)$ cros build-packages --board=${BOARD} chromeos-base/crosvm
61*bb4ee6a4SAndroid Build Coastguard Worker```
62*bb4ee6a4SAndroid Build Coastguard Worker
63*bb4ee6a4SAndroid Build Coastguard Worker## Building crosvm for Linux
64*bb4ee6a4SAndroid Build Coastguard Worker
65*bb4ee6a4SAndroid Build Coastguard Worker`emerge` and `cros_workon_make` workflows can be quite slow to work with, hence a lot of developers
66*bb4ee6a4SAndroid Build Coastguard Workerprefer to use standard cargo workflows used upstream.
67*bb4ee6a4SAndroid Build Coastguard Worker
68*bb4ee6a4SAndroid Build Coastguard WorkerJust make sure to initialize git submodules (`git submodules update --init`), which is not done by
69*bb4ee6a4SAndroid Build Coastguard Workerrepo. After that, you can use the workflows as outlined in
70*bb4ee6a4SAndroid Build Coastguard Worker[Building Crosvm](../building_crosvm/linux.md) **outside** of cros_sdk.
71*bb4ee6a4SAndroid Build Coastguard Worker
72*bb4ee6a4SAndroid Build Coastguard WorkerNote: You can **not** build or test ChromeOS specific features this way.
73*bb4ee6a4SAndroid Build Coastguard Worker
74*bb4ee6a4SAndroid Build Coastguard Worker## Submitting Changes
75*bb4ee6a4SAndroid Build Coastguard Worker
76*bb4ee6a4SAndroid Build Coastguard WorkerAll changes to crosvm are made upstream, using the same process outlined in
77*bb4ee6a4SAndroid Build Coastguard Worker[Contributing](../contributing/index.md). It is recommended to use the
78*bb4ee6a4SAndroid Build Coastguard Worker[Building crosvm for Linux](#building-crosvm-for-linux) setup above to run upstream presubmit checks
79*bb4ee6a4SAndroid Build Coastguard Worker/ formatting tools / etc when submitting changes.
80*bb4ee6a4SAndroid Build Coastguard Worker
81*bb4ee6a4SAndroid Build Coastguard WorkerCode submitted upstream is tested on linux, but not on ChromeOS devices. Changes will only be tested
82*bb4ee6a4SAndroid Build Coastguard Workeron the ChromeOS CQ when they go through [the merge process](#the-merge-process).
83*bb4ee6a4SAndroid Build Coastguard Worker
84*bb4ee6a4SAndroid Build Coastguard Worker## Has my change landed in ChromeOS (Googlers only)?
85*bb4ee6a4SAndroid Build Coastguard Worker
86*bb4ee6a4SAndroid Build Coastguard WorkerYou can use the [crosland](http://crosland/cl) tool to check in which ChromeOS version your changes
87*bb4ee6a4SAndroid Build Coastguard Workerhave been merged into the [chromiumos/platform/crosvm] repository.
88*bb4ee6a4SAndroid Build Coastguard Worker
89*bb4ee6a4SAndroid Build Coastguard WorkerThe merge will also contain all `BUG=` references that will notify your bugs about when the change
90*bb4ee6a4SAndroid Build Coastguard Workeris submitted.
91*bb4ee6a4SAndroid Build Coastguard Worker
92*bb4ee6a4SAndroid Build Coastguard WorkerFor more details on the process, please see [go/crosvm-uprev-playbook] (Googlers only).
93*bb4ee6a4SAndroid Build Coastguard Worker
94*bb4ee6a4SAndroid Build Coastguard Worker## Cq-Depend
95*bb4ee6a4SAndroid Build Coastguard Worker
96*bb4ee6a4SAndroid Build Coastguard Worker**We cannot support Cq-Depend** to sychronize changes with other ChromeOS repositories. Please try
97*bb4ee6a4SAndroid Build Coastguard Workerto make changes in a backwards compatible way to allow them to be submitted independently.
98*bb4ee6a4SAndroid Build Coastguard Worker
99*bb4ee6a4SAndroid Build Coastguard WorkerIf it cannot be avoided at all, please follow this process:
100*bb4ee6a4SAndroid Build Coastguard Worker
101*bb4ee6a4SAndroid Build Coastguard Worker1. Upload your change to upstream crosvm and get it reviewed. Do not submit it yet.
102*bb4ee6a4SAndroid Build Coastguard Worker1. Upload the change to [chromiumos/platform/crosvm] as well.
103*bb4ee6a4SAndroid Build Coastguard Worker1. Use Cq-Depend on the ChromeOS changes and submit it via the CQ.
104*bb4ee6a4SAndroid Build Coastguard Worker1. After the changes landed in ChromeOS, land them upstream as well.
105*bb4ee6a4SAndroid Build Coastguard Worker
106*bb4ee6a4SAndroid Build Coastguard Worker## Cherry-picking
107*bb4ee6a4SAndroid Build Coastguard Worker
108*bb4ee6a4SAndroid Build Coastguard Worker### Cherry-picking without the usual merge process
109*bb4ee6a4SAndroid Build Coastguard Worker
110*bb4ee6a4SAndroid Build Coastguard WorkerIf you need your changes faster than the usual merge frequency, please follow this process:
111*bb4ee6a4SAndroid Build Coastguard Worker
112*bb4ee6a4SAndroid Build Coastguard Worker1. Upload and submit your change to upstream crosvm.
113*bb4ee6a4SAndroid Build Coastguard Worker1. Upload the change to [chromiumos/platform/crosvm] as well.
114*bb4ee6a4SAndroid Build Coastguard Worker1. Submit as usual through the CQ.
115*bb4ee6a4SAndroid Build Coastguard Worker
116*bb4ee6a4SAndroid Build Coastguard Worker**Never** submit code just to ChromeOS, as it will cause upstream to diverge and result in merge
117*bb4ee6a4SAndroid Build Coastguard Workerconflicts down the road.
118*bb4ee6a4SAndroid Build Coastguard Worker
119*bb4ee6a4SAndroid Build Coastguard Worker### Cherry-picking to release branch
120*bb4ee6a4SAndroid Build Coastguard Worker
121*bb4ee6a4SAndroid Build Coastguard WorkerYour change need to be merged into [chromiumos/platform/crosvm] to cherry-pick it to a release
122*bb4ee6a4SAndroid Build Coastguard Workerbranch. You should follow
123*bb4ee6a4SAndroid Build Coastguard Worker[ChromiumOS Merge Workflow](https://www.chromium.org/chromium-os/developer-library/guides/development/work-on-branch/)
124*bb4ee6a4SAndroid Build Coastguard Workerto cherry-pick your changes. Since changes are merged from [crosvm/crosvm] to
125*bb4ee6a4SAndroid Build Coastguard Worker[chromiumos/platform/crosvm] through [the merge process](#the-merge-process), you can't use gerrit
126*bb4ee6a4SAndroid Build Coastguard Workerto cherry-pick your changes but need to use git command locally.
127*bb4ee6a4SAndroid Build Coastguard Worker
128*bb4ee6a4SAndroid Build Coastguard Worker```
129*bb4ee6a4SAndroid Build Coastguard Worker$ cd chromiumos/src/platform/crosvm
130*bb4ee6a4SAndroid Build Coastguard Worker$ git branch -a | grep remotes/cros/release-R120
131*bb4ee6a4SAndroid Build Coastguard Worker  remotes/cros/release-R120-15662.B
132*bb4ee6a4SAndroid Build Coastguard Worker$ git checkout -b my-cherry-pick cros/release-R120-15662.B
133*bb4ee6a4SAndroid Build Coastguard Worker$ git cherry-pick -x $COMMIT
134*bb4ee6a4SAndroid Build Coastguard Worker$ git push cros HEAD:refs/for/release-R120-15662.B
135*bb4ee6a4SAndroid Build Coastguard Worker```
136*bb4ee6a4SAndroid Build Coastguard Worker
137*bb4ee6a4SAndroid Build Coastguard Worker`$COMMIT` is the commit hash of the original change you want to cherry-pick not the merge commit.
138*bb4ee6a4SAndroid Build Coastguard WorkerNote that you push to special gerrit `refs/for/`, not pushing directly to the release branch.
139*bb4ee6a4SAndroid Build Coastguard Worker
140*bb4ee6a4SAndroid Build Coastguard WorkerAlso note that release branch cherry picks don't get CQ tested at all - they are submitted directly
141*bb4ee6a4SAndroid Build Coastguard Workeronce you CQ+2 - so it is very important to test locally first.
142*bb4ee6a4SAndroid Build Coastguard Worker
143*bb4ee6a4SAndroid Build Coastguard Worker## Running a Tryjob
144*bb4ee6a4SAndroid Build Coastguard Worker
145*bb4ee6a4SAndroid Build Coastguard WorkerFor googlers, see go/cdg-site
146*bb4ee6a4SAndroid Build Coastguard Worker
147*bb4ee6a4SAndroid Build Coastguard Worker[chromiumos/platform/crosvm]: https://chromium.googlesource.com/chromiumos/platform/crosvm
148*bb4ee6a4SAndroid Build Coastguard Worker[crosvm/crosvm]: https://chromium.googlesource.com/crosvm/crosvm
149*bb4ee6a4SAndroid Build Coastguard Worker[go/crosvm-uprev-playbook]: http://go/crosvm-uprev-playbook
150