book: add more details to network example

Some information seemed omitted from network, which requires some file
creation or modification to get the example working. Added the info.

BUG=N/A
TEST=mdbook build

Change-Id: I01069a3ac690b531e7902eab626ded498df7ebb1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4694602
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
Auto-Submit: Elie Kheirallah <khei@google.com>
This commit is contained in:
Elie Kheirallah 2023-07-18 15:54:39 +00:00 committed by crosvm LUCI
parent 120d8be4cc
commit f3c830ec97
2 changed files with 13 additions and 2 deletions

View file

@ -68,11 +68,20 @@ With the `crosvm_tap` in place we can use it when running crosvm:
To use the network device in the guest, we need to assign it a static IP address. In our example
guest this can be done via a netplan config:
First, create a guest directory and the netplan config:
```bash
mkdir guest/
touch guest/01-netcfg.yaml
```
Then edit guest/01-netcfg.yaml and add the following contents:
```yaml
{{#include ../../../../tools/examples/guest/01-netcfg.yaml:5:}}
```
Which can be installed when building the VM image:
The netplan config can be installed when building the VM image:
```bash
{{#include ../../../../tools/examples/example_network:build}}

View file

@ -19,11 +19,13 @@ if ! [ -f rootfs ]; then
# Configure network via netplan config in 01-netcfg.yaml
--hostname crosvm-test
# $SRC=/path/to/crosvm
--copy-in "$SRC/guest/01-netcfg.yaml:/etc/netplan/"
# Install sshd and authorized key for the user.
--install openssh-server
--ssh-inject "$USER:file:$HOME/.ssh/id_rsa.pub"
# OPTIONAL: inject RSA public key as known key
# --ssh-inject "$USER:file:$HOME/.ssh/id_rsa.pub"
-o rootfs
)