summary refs log tree commit diff
path: root/devices/src/virtio/mod.rs
Commit message (Collapse)AuthorAge
* devices: port vhost-user-net from cloud-hypervisorAlyssa Ross2021-05-11
| | | | | | | This is the cloud-hypervisor vhost-user-net code, modified just enough to compile as part of crosvm. There is currently no way to run crosvm with a vhost-user-net device, and even if there were, it wouldn't work without some further fixes.
* devices: implement dedicated Interrupt struct for virtio WorkerZide Chen2019-10-25
| | | | | | | | | | | | | | | | | | | | | | The code to inject interrupt to the guest can be generic to all virtio devices. This patch: - move those guest interrupt related fields out of Worker structure and put in a separate file, making the worker code cleaner. - remove redandant functions across virtio devices: signal_used_queue(), signal_config_changed(), etc. BUG=chromium:854765 TEST=sanity test on eve and Linux TEST=cargo test -p devices Change-Id: I8e9f760f2057f192fdc74d16a59fea2e6b08c194 Signed-off-by: Zide Chen <zide.chen@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1869553 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* devices: virtio: add copy_config() helper functionDaniel Verkamp2019-08-16
| | | | | | | | | | | | | | | | | | | | | | | Add a new virtio configuration copying function to replace all of the slightly varying read_config() and write_config() implementations in our virtio devices. This replaces a lot of tricky bounds-checking code with a single central implementation, simplifying the devices to a single call to copy_config() in most cases. The balloon device is also changed to represent its config space as a DataInit struct to match most other devices and remove several unwrap() calls. BUG=None TEST=./build_test TEST=Boot vm_kernel+vm_rootfs in crosvm TEST=Start Crostini on nami Change-Id: Ia49bd6dbe609d17455b9562086bc0b24f327be3f Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1749562 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* devices: virtio: add Error type for descriptorsDaniel Verkamp2019-08-13
| | | | | | | | | | | | | | | | Add an error type to describe descriptor Errors in more detail. This lets us return a more accurate error in a later CL in this chain by adding a VolatileMemoryError variant. BUG=chromium:990546 TEST=./build_test Change-Id: I08680d0cb64bfc3667bac7b2ad8a8bc0e78e8058 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1733988 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: Implement Reader/Writer interface over DescriptorChain.Jakub Staron2019-06-21
| | | | | | | | | | | | | | | | | | | This change adds a convinient interface over DescriptorChain. It hides the complexity of DescriptorChain and allows to treat it as a pair of read-only and write-only buffers. In the future, it will also allow to easily support indirect descriptors. BUG=chromium:966258 TEST=cargo test --package devices descriptor_utils TEST=run crosvm without sandbox, share a directory, compare checksum of shared file between host and guest Change-Id: I9fb722ee2024c8d7d40f560571ec7d7c454bfc2b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1647370 Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Jakub Staroń <jstaron@google.com>
* crosvm: virtio-pmem deviceJakub Staron2019-06-05
| | | | | | | | | | | | | | | | | | | | Adds support for virtio-pmem device as an alternative for virtio-blk. Exposing disk image to guest as virtio-blk device results in both guest and host independently caching the disk I/O. Using virtio-pmem device allows to mount disk image as direct access (DAX) in the guest and thus bypass the guest cache. This will reduce memory foodprint of the VMs. BUG=None TEST=cargo test TEST=Boot patched termina kernel in crosvm; mount virtio-pmem device as DAX and run xfstests. Change-Id: I935fc8fc7527f79e5169f07ec7927e4ea4fa6027 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1605517 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Jakub Staroń <jstaron@google.com>
* Adds Virtio-Input device simulationJorge E. Moreira2019-02-01
| | | | | | | | | | | | | | | | | | | | | | | | This allows decoupling input from the wayland socket while using a standard virtio device for it. The proposed virtio input spec can be found at https://www.kraxel.org/virtio/virtio-v1.0-cs03-virtio-input.pdf, it has already been implemented in qemu and (guest) kernel support exists since version 4.1. This change adds the following options to crosvm: --evdev: Grabs a host device and passes it through to the guest --<device>: Creates a default configuration for <device>, receives the input events from a unix socket. <device> can be 'keyboard', 'mouse' or 'trackpad'. Bug=chromium:921271 Test=booted on x86 linux and manually tried virtio-input devices Change-Id: I8455b72c53ea2f431009ee8140799b0797775e76 Reviewed-on: https://chromium-review.googlesource.com/1412355 Commit-Ready: Jorge Moreira Broche <jemoreira@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: add debug labels to devices for improved SIGCHLD logsZach Reizner2019-01-26
| | | | | | | | | | | | | | | | | | | Each device (Bus, Pci, Proxy, etc), gets a debug label associated with it. When a child is spawned, the debug label for it is stored in a map with the child's pid as the key. If a SIGCHLD is handled, this map is used to print a more helpful message about exactly which child died. BUG=None TEST=run with sandboxing and a faulty child device check logs for message about child died the child should have a debug label Change-Id: I61fbbee0a8e701249533a7a3a6a1ad48840f12e5 Reviewed-on: https://chromium-review.googlesource.com/1432835 Commit-Ready: Chih-Yang Hsia <paulhsia@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* tpm: Virtio tpm deviceDavid Tolnay2019-01-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL adds a "tpm" Cargo cfg to crosvm which enables a TPM device backed by libtpm2 simulator. Tested by running the following inside cros_sdk: LIBRARY_PATH=~/src/minijail LD_LIBRARY_PATH=~/src/minijail \ cargo run --release \ --features tpm \ -- \ run \ -r rootfs.ext4 \ --seccomp-policy-dir seccomp/x86_64/ \ -p init=/bin/bash \ -p panic=-1 \ --disable-sandbox \ vmlinux.bin with a Linux image built from CL:1387655. The TPM self test completes successfully with the following output: https://paste.googleplex.com/5996075978588160?raw Justin's TPM playground runs with the following trace output. https://paste.googleplex.com/4909751007707136?raw Design doc: go/vtpm-for-glinux TEST=ran TPM playground program inside crosvm TEST=local kokoro BUG=chromium:911799 Change-Id: I2feb24a3e38cba91f62c6d2cd1f378de4dd03ecf Reviewed-on: https://chromium-review.googlesource.com/1387624 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* devices: allow virtio-wayland to use virtgpu resourcesZach Reizner2018-12-11
| | | | | | | | | | | | | | | | This change uses the resource bridge between virtio-gpu and virtio-cpu to send resources over the host wayland connection that originated from the virtio-gpu device. This will help support gpu accelerated wayland surfaces. BUG=chromium:875998 TEST=wayland-simple-egl Change-Id: I3340ecef438779be5cb3643b2de8bb8c33097d75 Reviewed-on: https://chromium-review.googlesource.com/1182793 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* devices: virtio: remove virtio MMIO transportDaniel Verkamp2018-10-31
| | | | | | | | | | | | All devices have been converted to PCI, so we don't need MmioDevice. BUG=chromium:854766 TEST=Boot crosvm on kevin and verify virtio devices still work Change-Id: Ib6400e15bdb2153d14795de3cb0bfbf1845a8891 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1281832 Reviewed-by: Dylan Reid <dgreid@chromium.org>
* cargo fmt all source codeZach Reizner2018-10-09
| | | | | | | | | | | | | | Now that cargo fmt has landed, run it over everything at once to bring rust source to the standard formatting. TEST=cargo test BUG=None Change-Id: Ic95a48725e5a40dcbd33ba6d5aef2bd01e91865b Reviewed-on: https://chromium-review.googlesource.com/1259287 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* devices: Implement virtio PCI transportDylan Reid2018-10-01
| | | | | | | Change-Id: Ieaa83205ba4e3f029f6d183a1b93799352551299 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1237364 Reviewed-by: Dylan Reid <dgreid@chromium.org>
* devices: Move VirtioDevice to its own fileDylan Reid2018-09-10
| | | | | | | | | | | | | Currently VirtioDevice was only used by MmioDevice. Move it to a separate file to allow it to be used by a PCI implementation in the following commits. Change-Id: Ie2de92d8876fdaa31d71341714681212d52a618c Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1208690 Commit-Ready: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* virtio: Implement the 9P deviceChirantan Ekbote2018-08-08
| | | | | | | | | | | | | | | | | | | | | | | Implement a new virtio_9p device to be used for sharing directories with the VM. BUG=chromium:703939 TEST=mount inside a VM and run `bonnie++ -r 256` Append the shared directory to the crosvm command line: --shared-dir /path/to/dir:test_9p Then mount in the guest: mkdir /tmp/9p mount -t 9p -o trans=virtio test_9p /tmp/9p -oversion=9p2000.L Or for a 9p root: run --shared-dir /mnt/vm_root:/dev/root -p 'root=/dev/root ro rootflags=ro,trans=virtio,version=9p2000.L,cache=loose rootfstype=9p' vmlinux.bin CQ-DEPEND=CL:1065170 Change-Id: I41fc21306ab5fa318a271f172d7057b767b29f31 Signed-off-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1065173 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* gpu: implement virtio-gpuZach Reizner2018-07-20
| | | | | | | | | | | | | | | | | | Basic 2D and 3D support is there. The drm_cursor_test and null_platform_test in drm-tests should run to completion. The extra device is hidden behind both a build time feature called 'gpu' and the device is only added to a VM if the '--gpu' flag is given. TEST=build with --features=gpu; drm_cursor_test && null_platform_test BUG=chromium:837073 Change-Id: Ic91acaaebbee395599d7e1ba41c24c9ed2d84169 Reviewed-on: https://chromium-review.googlesource.com/1036862 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Fix a typo: virtio::NOITFY_REG_OFFSET -> virtio::NOTIFY_REG_OFFSETPhilipp Kern2018-04-23
| | | | | | | | | | | TEST=compiled crosvm successfully Change-Id: Idabf81b8600fa2772e6e315d08d3c853e511a8cd Reviewed-on: https://chromium-review.googlesource.com/1023415 Commit-Ready: Philipp Kern <pkern@google.com> Tested-by: Philipp Kern <pkern@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* devices: Add balloonDylan Reid2017-12-18
| | | | | | | | | | The balloon device is used to take regions of unused memory from the guest and allow other host processes to use that memory. Change-Id: I06c821365a58672d605fc7555beaec599cae1b15 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/759306 Reviewed-by: Stephen Barber <smbarber@chromium.org>
* Move crosvm/hw to a new devices moduleDylan Reid2017-10-09
Moving the devices to their own module makes it easier to add tests that use them. Change-Id: I61bfef4037d16b20145b5fddce604835cdc4f67b Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/706559 Reviewed-by: Zach Reizner <zachr@chromium.org>