1# Wayland 2 3If you have a Wayland compositor running on your host, it is possible to display and control guest 4applications from it. This requires: 5 6- A guest kernel version 5.16 or above with `CONFIG_DRM_VIRTIO_GPU` enabled, 7- The `sommelier` Wayland proxy in your guest image. 8 9This section will walk you through the steps needed to get this to work. 10 11## Guest kernel requirements 12 13Wayland support on crosvm relies on virtio-gpu contexts, which have been introduced in Linux 5.16. 14Make sure your guest kernel is either this version or a more recent one, and that 15`CONFIG_DRM_VIRTIO_GPU` is enabled in your kernel configuration. 16 17## Crosvm requirements 18 19Wayland forwarding requires the GPU feature and the virtio-gpu cross domain mode to be enabled. 20 21``` 22cargo build --features "gpu" 23``` 24 25## Building sommelier 26 27[Sommelier] is a proxy Wayland compositor that forwards the Wayland protocol from a guest to a 28compositor running on the host through the guest GPU device. As it is not a standard tool, we will 29have to build it by ourselves. It is recommended to do this from the guest 30[with networking enabled](../running_crosvm/example_usage.md#add-networking-support). 31 32Clone ChromeOS' `platform2` repository, which contains the source for sommelier: 33 34```sh 35git clone https://chromium.googlesource.com/chromiumos/platform2 36``` 37 38Go into the sommelier directory and prepare for building: 39 40```sh 41cd platform2/vm_tools/sommelier/ 42meson setup build -Dwith_tests=false 43``` 44 45This setup step will check for all libraries required to build sommelier. If some are missing, 46install them using your guest's distro package manager and re-run `meson setup` until it passes. 47 48Finally, build sommelier and install it: 49 50```sh 51meson compile -C build 52sudo meson install -C build 53``` 54 55This last step will put the `sommelier` binary into `/usr/local/bin`. 56 57## Running guest Wayland apps 58 59Crosvm can connect to a running Wayland server (e.g. [weston]) on the host and forward the protocol 60from all Wayland guest applications to it. To enable this you need to know the socket of the Wayland 61server running on your host - typically it would be `$XDG_RUNTIME_DIR/wayland-0`. 62 63Once you have confirmed the socket, create a GPU device and enable forwarding by adding the 64`--gpu=context-types=cross-domain --wayland-sock $XDG_RUNTIME_DIR/wayland-0` arguments to your 65crosvm command-line. Other context types may be also enabled for those interested in 3D 66acceleration. 67 68You can now run Wayland clients through sommelier, e.g: 69 70```sh 71sommelier --virtgpu-channel weston-terminal 72``` 73 74Or 75 76```sh 77sommelier --virtgpu-channel gedit 78``` 79 80Applications started that way should appear on and be controllable from the Wayland server running 81on your host. 82 83The `--virtgpu-channel` option is currently necessary for sommelier to work with the setup of this 84document, but will likely not be required in the future. 85 86If you have `Xwayland` installed in the guest you can also run X applications: 87 88```sh 89sommelier -X --xwayland-path=/usr/bin/Xwayland xeyes 90``` 91 92[sommelier]: https://chromium.googlesource.com/chromiumos/platform2/+/master/vm_tools/sommelier 93[weston]: https://github.com/wayland-project/weston 94