• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Docker for Building/Running crosvm
2
3This module contains various pieces of Docker infrastructure for supporting crosvm outside of Chrome
4OS environments. This includes the kokoro build environment.
5
6[TOC]
7
8## Introduction
9
10Ordinarily, crosvm is built using the standard `cargo build` command inside of a Chrome OS chroot.
11The chroot requirement is there because of various path dependencies in the crosvm `Cargo.toml` are
12targeted to paths outside of the crosvm repo itself. If one were to checkout crosvm in isolation,
13`cargo build` would be inadequate, failing with an error related to these missing paths.
14Additionally, crosvm depends on native packages that are not ordinarily available from an OS package
15manager (e.g. minijail) or have been forked in the Chrome OS project in an incompatible fashion
16(libusb).
17
18## `crosvm-base` Docker Image
19
20To support building crosvm outside of a Chrome OS chroot, this modules contains a `Dockerfile` that
21is used to build the `crosvm-base` docker image. Part of that image build process is downloading
22various repos, checking out pinned commits (specified in `checkout_commits.env`), and installing
23them. For the path dependencies in the `Cargo.toml`, the `Dockerfile` downloads and places the
24source code in the correct spot relative to the crosvm source repository. The `crosvm-base` build
25step stops short of actually building crosvm. It doesn't even have the source code for crosvm. The
26intent here is to use `crosvm-base` for building and running any version of crosvm.
27
28To build the `crosvm-base` image, run `build_crosvm_base.sh`. The script will automatically use the
29checkouts from `checkout_commits.env` which can be reconfigured to point to any commit desired. To
30upgrade `checkout_commits.sh` to the HEAD of each remote master branch, run the
31`upgrade_checkout_commits.sh` script.
32
33## `crosvm` Docker Image
34
35After generating a `crosvm-base`, the system is ready to build crosvm into its own `crosvm` docker
36image. The resulting docker image will be capable of running VMs without fear of missing native
37dependencies. Run the `build_crosvm.sh` script to build crosvm into a docker image. Once that
38completes, use the `crosvm_wrapper.sh` script to run crosvm within the docker image. That script
39will pass the arguments given to it verbatim to crosvm. In addition, the current working directory
40is bind mounted into the container so that file paths passed to `crosvm_wrapper.sh` should work as
41long as they are relative paths to files contained in the working directory.
42
43## `smoke_test`
44
45There is a convenience wrapper for `smoke_test` that uses the `crosvm` docker image to execute
46all the tests. Run `wrapped_smoke_test.sh` after building `crosvm-base` docker image to run the
47`smoke_test` within docker.
48