Crosvm book don't have a documentation for how to run and use the virtio-fs. Add a fs chapter under device, and upload a runnable example. BUG=b:235067443 TEST=mdbook build docs/book Change-Id: I8ef1ceb9d4cfc5f9a2e8afa2416d1f3ba69691b4 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4535500 Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Reviewed-by: Takaya Saeki <takayas@chromium.org> Commit-Queue: Yuan Yao <yuanyaogoog@chromium.org>
36 lines
1.1 KiB
Bash
Executable file
36 lines
1.1 KiB
Bash
Executable file
#!/bin/bash
|
|
# Copyright 2023 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 a shared directory
|
|
|
|
set -e
|
|
|
|
SRC=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
|
|
#If "example_simple" is executed, reuse its image. Otherwise, create one.
|
|
mkdir -p "$SRC/images/simple" && cd "$_"
|
|
mkdir -p "host_shared_dir"
|
|
HOST_SHARED_DIR="$SRC/images/simple/host_shared_dir"
|
|
|
|
if ! [ -f rootfs ]; then
|
|
# Build a simple ubuntu image and create a user with no password.
|
|
virt-builder ubuntu-20.04 \
|
|
--run-command "useradd -m -g sudo -p '' $USER ; chage -d 0 $USER" \
|
|
-o ./rootfs
|
|
|
|
virt-builder --get-kernel ./rootfs -o .
|
|
fi
|
|
|
|
# Use crosvm/tools/examples/images/simple/host_shared_dir as mount point
|
|
cargo run -- run \
|
|
--shared-dir "$HOST_SHARED_DIR:my_shared_tag:type=fs" \
|
|
--rwdisk ./rootfs \
|
|
--initrd ./initrd.img-* \
|
|
-p "root=/dev/vda5 " \
|
|
./vmlinuz-*
|
|
|
|
## In guest OS, run following instructions to set up the shared directory
|
|
## sudo su
|
|
## mkdir /tmp/guest_shared_dir
|
|
## mount -t virtiofs my_shared_tag /tmp/guest_shared_dir
|