From f3c830ec970a1b38d188e74c6419991d9bcd3289 Mon Sep 17 00:00:00 2001 From: Elie Kheirallah Date: Tue, 18 Jul 2023 15:54:39 +0000 Subject: [PATCH] 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 Commit-Queue: Elie Kheirallah Auto-Submit: Elie Kheirallah --- docs/book/src/running_crosvm/example_usage.md | 11 ++++++++++- tools/examples/example_network | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/book/src/running_crosvm/example_usage.md b/docs/book/src/running_crosvm/example_usage.md index 046b0dbcef..af980c4fed 100644 --- a/docs/book/src/running_crosvm/example_usage.md +++ b/docs/book/src/running_crosvm/example_usage.md @@ -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}} diff --git a/tools/examples/example_network b/tools/examples/example_network index 9a53e65577..40dc1f7af3 100755 --- a/tools/examples/example_network +++ b/tools/examples/example_network @@ -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 )