mdbook: Explain how to build a binary for beginner

Add a section to explain how to build crosvm binary for beginners who
may not have used cargo.
Also, ran mdformat on the file.

BUG=none
TEST=check

Change-Id: I902157cd471652b829d73bb27fc52e04db64d6d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3252186
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
This commit is contained in:
Keiichi Watanabe 2021-10-30 00:51:26 +09:00 committed by Commit Bot
parent 99020040f9
commit cb14f61ce7

View file

@ -67,12 +67,21 @@ The container image is big and may take a while to download when first used.
Once started, you can follow all instructions in this document within the Once started, you can follow all instructions in this document within the
container shell. container shell.
## Building a binary
If you simply want to try crosvm, run `cargo build`. Then the binary is
generated at `./target/debug/crosvm`. Now you can move to
[Basic Usage](/running_crosvm/basic_usage.html).
If you want to enable [additional features](/running_crosvm/features.html), use
the `--features` flag. (e.g. `cargo build --features=gdb`)
## Development ## Development
### Iterative development ### Iterative development
You can use cargo as usual for crosvm development to `cargo build` and You can use cargo as usual for crosvm development to `cargo build` and `cargo
`cargo test` single crates that you are working on. test` single crates that you are working on.
If you are working on aarch64 specific code, you can use the `set_test_target` If you are working on aarch64 specific code, you can use the `set_test_target`
tool to instruct cargo to build for aarch64 and run tests on a VM: tool to instruct cargo to build for aarch64 and run tests on a VM:
@ -159,15 +168,14 @@ skip some slower checks, like building for other platforms.
also stop minijail from killing processes that violate the seccomp rule, also stop minijail from killing processes that violate the seccomp rule,
making the sandboxing much less aggressive. making the sandboxing much less aggressive.
- Seccomp policy files have hardcoded absolute paths. You can either fix up - Seccomp policy files have hardcoded absolute paths. You can either fix up
the paths locally, or set up an awesome hacky symlink: the paths locally, or set up an awesome hacky symlink: `sudo mkdir
`sudo mkdir /usr/share/policy && sudo ln -s /path/to/crosvm/seccomp/x86_64 /usr/share/policy/crosvm`. /usr/share/policy && sudo ln -s /path/to/crosvm/seccomp/x86_64
We'll eventually build the precompiled policies /usr/share/policy/crosvm`. We'll eventually build the precompiled policies
[into the crosvm binary](http://crbug.com/1052126). [into the crosvm binary](http://crbug.com/1052126).
- Devices can't be jailed if `/var/empty` doesn't exist. - Devices can't be jailed if `/var/empty` doesn't exist. `sudo mkdir -p
`sudo mkdir -p /var/empty` to work around this for now. /var/empty` to work around this for now.
- You need read/write permissions for `/dev/kvm` to run tests or other crosvm - You need read/write permissions for `/dev/kvm` to run tests or other crosvm
instances. Usually it's owned by the `kvm` group, so instances. Usually it's owned by the `kvm` group, so `sudo usermod -a -G kvm
`sudo usermod -a -G kvm $USER` and then log out and back in again to fix $USER` and then log out and back in again to fix this.
this.
- Some other features (networking) require `CAP_NET_ADMIN` so those usually - Some other features (networking) require `CAP_NET_ADMIN` so those usually
need to be run as root. need to be run as root.