• Stars
    star
    370
  • Rank 115,405 (Top 3 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 5 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

virtio implementation

vm-virtio

The vm-virtio workspace provides virtio abstractions and implementation for the virtio queue and devices. For now, it consists of the following crates:

  • virtio-bindings -> provides Rust FFI bindings to the corresponding Linux kernel API;
  • virtio-blk -> contains abstractions for parsing and executing a request of the block device;
  • virtio-console -> contains abstractions for the virtio console device;
  • virtio-device -> provides abstractions for the common functionality of the virtio devices, and a default implementation for the MMIO transport operations (read, write);
  • virtio-queue -> provides a virtio device implementation for a virtio queue, a virtio descriptor and a chain of such descriptors;
  • virtio-queue-ser -> provides abstractions for serialization and deserialization for virtio queue states;
  • virtio-vsock -> provides an implementation for the vsock packet.

Note

We offer support only for virtio v1.0+ (the legacy interface is not supported).

The queues are the mechanism for data transport between the virtio device and the guest driver. Each device can have zero or more virtqueues, for example the block device has one queue, the vsock device has three queues etc. The communication between the driver and device is possible through different transport options, i.e. PCI, MMIO, and Channel I/O buses. In addition to the queue and device emulation that is provided in vm-virtio, the VMM has to also define the device backend and the event handling mechanism.

The Queue abstraction

For details about the abstractions provided in virtio-queue, check its separate README.

The VirtioDevice trait

Virtio device implementations will implement the VirtioDevice trait. Typically, the VMM will implement virtio devices and provide the paravirtualized IO emulation for all supported virtio devices. For example, a VMM willing to emulate a virtio networking device will implement the VirtioDevice trait.

The VirtioDevice implementation will be discovered by the guest through a virtio transport layer (MMIO, PCI or Channel I/O). The transport layer implementation will then call into the VirtioDevice's activate method to notify the device that the guest driver is done configuring it and that it should be ready to handle IO from the guest. On the other hand, the VirtioDevice's reset method will be called by the transport layer when the guest driver needs to reset and release all the emulated device resources.

Tests

Our Continuous Integration (CI) pipeline is implemented on top of Buildkite. For the complete list of tests, check our CI pipeline.

Each individual test runs in a container. To run the tests locally, you can use the dev-container on both x86 and arm64.

cd ~/vm-virtio
container_version=15
docker run -it \
           --security-opt seccomp=unconfined \
           --volume $(pwd):/vm-virtio \
           --volume ~/.ssh:/root/.ssh \
           rustvmm/dev:v${container_version}
cd vm-virtio
./rust-vmm-ci/test_run.py

The vm-virtio workspace is tested with unit tests (including documentation examples). For running all the tests, use the following command:

cargo test --all-features

--all-features is used in order to also include the tests under a feature, such as backend-stdio.

For details about the testing in the virtio-queue crate, check its separate documentation.

Fuzzing

We run 15 minutes long fuzzing sessions for each PR and on merges to the main branch. For more details about the fuzz targets and implementation, check the Fuzzing Readme.

For changes that could introduce security vulnerabilities, we recommend running the "fuzzing-vm-virtio" Buildkite pipeline that runs fuzzing for 1 day instead of 15 minutes. This pipeline is optional which means that PRs can be merged without waiting for the fuzzing sessions to finish. As running fuzzing for 1 day keeps the Builkite agents busy and could cause delays in merging other PRs, this longer fuzzing sessions are not run by default on all PRs. To enable the run, one of the Buildkite administrators need to unblock the pipeline by following the Buildkite run link in the PR and click on the corresponding unblock pipeline button.

License

This project is licensed under either of

More Repositories

1

community

rust-vmm community content
459
star
2

vm-memory

Virtual machine's guest memory crate
Rust
310
star
3

kvm-ioctls

Rust
269
star
4

linux-loader

Linux kernel loader
Rust
190
star
5

vmm-reference

A VMM implementation based of rust-vmm components
Rust
147
star
6

vhost

Rust
126
star
7

kvm-bindings

Rust
113
star
8

vmm-sys-util

Helpers and utilities used by multiple rust-vmm components and VMMs
Rust
79
star
9

vhost-device

'vhost-user' device backends workspace
Rust
69
star
10

seccompiler

Provides easy-to-use Linux seccomp-bpf jailing.
Rust
69
star
11

rust-vmm-container

Container with all dependencies required for running rust-vmm crates integration tests.
Shell
65
star
12

event-manager

Rust
45
star
13

vm-device

Rust
36
star
14

mshv

Crates for Microsoft Hypervisor ioctls and bindings
Rust
32
star
15

vm-superio

Emulation for legacy devices
Rust
30
star
16

vm-allocator

Provides allocations and release strategies for resources used during the lifetime of a VM.
Rust
30
star
17

rust-vmm-ci

Python
18
star
18

vhost-user-backend

Deprecated repository, code now lives in: https://github.com/rust-vmm/vhost/
Rust
18
star
19

virtio-bindings

This crate is now part of the vm-virtio workspace: https://github.com/rust-vmm/vm-virtio
Rust
15
star
20

vfio-ioctls

Safe wrappers for VFIO
Rust
15
star
21

vfio

Rust
14
star
22

crate-template

This is the template used by all repositories which represent a crate. The purpose is to speed up the creation of new crates and keep the same standard in rust-vmm.
Rust
12
star
23

vfio-bindings

Rust
11
star
24

vm-fdt

Rust
11
star
25

acpi_tables

Rust
9
star
26

xen-sys

Rust
9
star
27

kvm

Rust
8
star
28

vmm-vcpu

7
star
29

kvm_wrapper

Deprecated. Use https://github.com/rust-vmm/kvm-bindings instead.
Rust
6
star
30

vfio-user

Rust
4
star
31

vm-pci

Rust
2
star
32

io-rate-limiter

Rust
1
star
33

.github

1
star