1
0

example_desktop 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. # Copyright 2022 The ChromiumOS Authors
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. # Example VM with a full desktop
  6. set -e
  7. sudo mkdir -p /var/empty
  8. SRC=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
  9. mkdir -p "$SRC/images/desktop" && cd "$_"
  10. if ! [ -f rootfs ]; then
  11. # ANCHOR: build
  12. builder_args=(
  13. # Create user with no password.
  14. --run-command "useradd -m -g sudo -p '' $USER ; chage -d 0 $USER"
  15. # Configure network. See ./example_network
  16. --hostname crosvm-test
  17. --copy-in "$SRC/guest/01-netcfg.yaml:/etc/netplan/"
  18. # Install a desktop environment to launch
  19. --install xfce4
  20. -o rootfs
  21. )
  22. virt-builder ubuntu-20.04 "${builder_args[@]}"
  23. # ANCHOR_END: build
  24. virt-builder --get-kernel ./rootfs -o .
  25. fi
  26. # ANCHOR: run
  27. # Enable the GPU and keyboard/mouse input. Since this will be a much heavier
  28. # system to run we also need to increase the cpu/memory given to the VM.
  29. # Note: GDM does not allow you to set your password on first login, you have to
  30. # log in on the command line first to set a password.
  31. cargo run --features=gpu,x,virgl_renderer -- run \
  32. --cpus 4 \
  33. --mem 4096 \
  34. --gpu backend=virglrenderer,width=1920,height=1080 \
  35. --display-window-keyboard \
  36. --display-window-mouse \
  37. --net tap-name=crosvm_tap \
  38. --rwdisk ./rootfs \
  39. --initrd ./initrd.img-* \
  40. -p "root=/dev/vda5" \
  41. ./vmlinuz-*
  42. # ANCHOR_END: run