1# Devices 2 3This chapter describes emulated devices in crosvm. These devices work like hardware for the guest. 4 5## List of devices 6 7Here is a (non-comprehensive) list of emulated devices provided by crosvm. 8 9### Emulated Devices 10 11- [`CMOS/RTC`] - Used to get the current calendar time. 12- [`i8042`] - Used by the guest kernel to exit crosvm. 13- [usb] - xhci emulation to provide USB device passthrough. 14- [`serial`] - x86 I/O port driven serial devices that print to stdout and take input from stdin. 15 16### VirtIO Devices 17 18- [`balloon`] - Allows the host to reclaim the guest's memories. 19- [`block`] - Basic read/write block device. 20- [`console`] - Input and outputs on console. 21- [`fs`] - Shares file systems over the FUSE protocol. 22- [`gpu`] - Graphics adapter. 23- [`input`] - Creates virtual human interface devices such as keyboards. 24- [`iommu`] - Emulates an IOMMU device to manage DMA from endpoints in the guest. 25- [`net`] - Device to interface the host and guest networks. 26- [`p9`] - Shares file systems over the 9P protocol. 27- [`pmem`] - Persistent memory. 28- [`rng`] - Entropy source used to seed guest OS's entropy pool. 29- [`scsi`] - SCSI device. 30- [`snd`] - Encodes and decodes audio streams. 31- [`tpm`] - Creates a TPM (Trusted Platform Module) device backed by vTPM daemon. 32- [`video`] - Allows the guest to leverage the host's video capabilities. 33- [`wayland`] - Allows the guest to use the host's Wayland socket. 34- [`vsock`] - Enables use of virtual sockets for the guest. 35- [`vhost-user`] - VirtIO devices which offloads the device implementation to another process 36 through the [vhost-user protocol]: 37 - [vmm side]: Shares its virtqueues. 38 - [device side]: Consumes virtqueues. 39 40## Device hotplug (experimental) 41 42A hotplug-capable device can be added as a PCI device to the guest. To enable hotplug, compile 43crosvm with feature flag `pci-hotplug`: 44 45```sh 46cargo build --features=pci-hotplug #additional parameters 47``` 48 49When starting the VM, specify the number of slots with `--pci-hotplug-slots` option. Additionally, 50specify a [control socket](../architecture/overview.md#the-vm-control-sockets) specified with `-s` 51option for sending hotplug commands. 52 53For example, to run a VM with 3 PCI hotplug slots and control socket: 54 55```sh 56VM_SOCKET=/run/crosvm.socket 57crosvm run \ 58 -s ${VM_SOCKET} \ 59 --pci-hotplug-slots 3 60 # usual crosvm args 61``` 62 63Currently, only network devices are supported. 64 65[device side]: https://chromium.googlesource.com/crosvm/crosvm/+/refs/heads/main/devices/src/virtio/vhost/user/device/ 66[usb]: usb.md 67[vhost-user protocol]: https://qemu.readthedocs.io/en/latest/interop/vhost-user.html 68[vmm side]: https://chromium.googlesource.com/crosvm/crosvm/+/refs/heads/main/devices/src/virtio/vhost/user/vmm/ 69[`balloon`]: balloon.md 70[`block`]: block.md 71[`cmos/rtc`]: https://chromium.googlesource.com/crosvm/crosvm/+/refs/heads/main/devices/src/cmos.rs 72[`console`]: https://chromium.googlesource.com/crosvm/crosvm/+/refs/heads/main/devices/src/virtio/console.rs 73[`fs`]: https://chromium.googlesource.com/crosvm/crosvm/+/refs/heads/main/devices/src/virtio/fs/ 74[`gpu`]: https://chromium.googlesource.com/crosvm/crosvm/+/refs/heads/main/devices/src/virtio/gpu/ 75[`i8042`]: https://chromium.googlesource.com/crosvm/crosvm/+/refs/heads/main/devices/src/i8042.rs 76[`input`]: input.md 77[`iommu`]: https://chromium.googlesource.com/crosvm/crosvm/+/refs/heads/main/devices/src/virtio/iommu.rs 78[`net`]: net.md 79[`p9`]: https://chromium.googlesource.com/crosvm/crosvm/+/refs/heads/main/devices/src/virtio/p9.rs 80[`pmem`]: pmem.md 81[`rng`]: https://chromium.googlesource.com/crosvm/crosvm/+/refs/heads/main/devices/src/virtio/rng.rs 82[`scsi`]: scsi.md 83[`serial`]: https://chromium.googlesource.com/crosvm/crosvm/+/refs/heads/main/devices/src/serial.rs 84[`snd`]: https://chromium.googlesource.com/crosvm/crosvm/+/refs/heads/main/devices/src/virtio/snd/ 85[`tpm`]: https://chromium.googlesource.com/crosvm/crosvm/+/refs/heads/main/devices/src/virtio/tpm.rs 86[`vhost-user`]: vhost_user.md 87[`video`]: video.md 88[`vsock`]: https://chromium.googlesource.com/crosvm/crosvm/+/refs/heads/main/devices/src/virtio/vhost/vsock.rs 89[`wayland`]: wayland.md 90