crosvm/tools/examples/example_network
Dennis Kempin 1dab58a2cf Update all copyright headers to match new style
This search/replace updates all copyright notices to drop the
"All rights reserved", Use "ChromiumOS" instead of "Chromium OS"
and drops the trailing dots.

This fulfills the request from legal and unifies our notices.

./tools/health-check has been updated to only accept this style.

BUG=b:246579983
TEST=./tools/health-check

Change-Id: I87a80701dc651f1baf4820e5cc42469d7c5f5bf7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894243
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-09-13 18:41:29 +00:00

44 lines
1.2 KiB
Bash
Executable file

#!/bin/bash
# Copyright 2022 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Example VM with internet access and sshd
set -e
SRC=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
mkdir -p "$SRC/images/network" && cd "$_"
if ! [ -f rootfs ]; then
# ANCHOR: build
builder_args=(
# Create user with no password.
--run-command "useradd -m -g sudo -p '' $USER ; chage -d 0 $USER"
# Configure network via netplan config in 01-netcfg.yaml
--hostname crosvm-test
--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"
-o rootfs
)
virt-builder ubuntu-20.04 "${builder_args[@]}"
# ANCHOR_END: build
virt-builder --get-kernel ./rootfs -o .
fi
# ANCHOR: run
# Use the previously configured crosvm_tap device for networking.
cargo run -- run \
--disable-sandbox \
--rwdisk ./rootfs \
--initrd ./initrd.img-* \
--tap-name crosvm_tap \
-p "root=/dev/vda5" \
./vmlinuz-*
# ANCHOR_END: run