docs: make sure user is added to the kvm group in running_crosvm/example_simple.md.
At present, the `tools/examples/example_simple` script fails with an access error when the user is not added to the kvm group. This commit makes sure the user is added to the kvm group when trying to run crosvm in running_crosvm/example_simple.md. Tested on my local environment and checked the script works regardless of the user being in the kvm group. BUG=b:294970555 TEST=./tools/presubmit TEST=./tools/examples/example_simple works regardless of user being in the kvm group TEST=shellcheck Change-Id: I19e42af048774f68c7e0a93afa89a7acd183ba82 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4763917 Reviewed-by: Takaya Saeki <takayas@chromium.org> Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Commit-Queue: Joe Hattori <hattorij@google.com>
This commit is contained in:
parent
445e0d4f68
commit
ab3d88e71f
2 changed files with 27 additions and 0 deletions
|
|
@ -34,6 +34,24 @@ The kernel binary is going to be saved in the same directory.
|
|||
Note: Most distributions use an init ramdisk, which is extracted at the same time and needs to be
|
||||
passed to crosvm as well.
|
||||
|
||||
### Add the user to the kvm group
|
||||
|
||||
To run crosvm without `sudo`, the user should be added to the `kvm` group in order to obtain the
|
||||
access to the `/dev/kvm` file. If the user is already in the kvm group, skip this part. Otherwise,
|
||||
execute the command below.
|
||||
|
||||
```bash
|
||||
{{#include ../../../../tools/examples/example_simple:kvm}}
|
||||
```
|
||||
|
||||
You can check if the user is in the kvm group or not with the following command:
|
||||
|
||||
```bash
|
||||
groups | grep kvm
|
||||
```
|
||||
|
||||
After executing the `adduser` command above, please logout and log back in to reflect the kvm group.
|
||||
|
||||
### Launch the VM
|
||||
|
||||
With all the files in place, crosvm can be run:
|
||||
|
|
|
|||
|
|
@ -27,6 +27,15 @@ if ! [ -f rootfs ]; then
|
|||
# ANCHOR_END: kernel
|
||||
fi
|
||||
|
||||
if [ "$(groups | grep kvm -c)" -eq 0 ]; then
|
||||
echo "Adding user $USER to the kvm group to grant access to /dev/kvm"
|
||||
# ANCHOR: kvm
|
||||
sudo adduser "$USER" kvm
|
||||
# ANCHOR_END: kvm
|
||||
echo "Please logout and log back in to reflect the kvm group."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# ANCHOR: run
|
||||
# Create `/var/empty` where crosvm can do chroot for jailing each virtio device.
|
||||
# Devices can't be jailed if /var/empty doesn't exist.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue