virtio-devices: Simplify virtio device reset
Rather than having to give and return the ioeventfd used for a device clone them each time. This will make it simpler when we start handling the driver enabling fewer queues than advertised by the device.
Signed-off-by: Rob Bradford robert.bradford@intel.com
版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9
京公网安备 11010802032778号
rust-vmmproject dependency1. What is Cloud Hypervisor?
Cloud Hypervisor is an open source Virtual Machine Monitor (VMM) that runs on top of KVM. The project focuses on exclusively running modern, cloud workloads, on top of a limited set of hardware architectures and platforms. Cloud workloads refers to those that are usually run by customers inside a cloud provider. For our purposes this means modern operating systems with most I/O handled by paravirtualised devices (i.e. virtio), no requirement for legacy devices, and 64-bit CPUs.
Cloud Hypervisor is implemented in Rust and is based on the rust-vmm crates.
Objectives
High Level
Architectures
Cloud Hypervisor supports the
x86-64andAArch64architectures. There are some small differences in functionality between the two architectures (see #1125).Guest OS
Cloud Hypervisor supports
64-bit Linuxwith support for modern 64-bit Windows guests currently under development.2. Getting Started
We create a folder to build and run
cloud-hypervisorat$HOME/cloud-hypervisorInstall prerequisites
You need to install some prerequisite packages in order to build and test Cloud Hypervisor. Here, all the steps are based on Ubuntu, for other Linux distributions please replace the package manager and package name.
Clone and build
First you need to clone and build the cloud-hypervisor repo:
This will build a
cloud-hypervisorbinary under$CLOUDH/cloud-hypervisor/target/release/cloud-hypervisor.Containerized builds and tests
If you want to build and test Cloud Hypervisor without having to install all the required dependencies (The rust toolchain, cargo tools, etc), you can also use Cloud Hypervisor’s development script:
dev_cli.sh. Please note that upon its first invocation, this script will pull a fairly large container image.For example, to build the Cloud Hypervisor release binary:
With
dev_cli.sh, one can also run the Cloud Hypervisor CI locally. This can be very convenient for debugging CI errors without having to fully rely on the Cloud Hypervisor CI infrastructure.For example, to run the Cloud Hypervisor unit tests:
Run the
./scripts/dev_cli.sh --helpcommand to view all the supported development script commands and their related options.Run
You can run a guest VM by either using an existing cloud image or booting into your own kernel and disk image.
Cloud image
Cloud Hypervisor supports booting disk images containing all needed components to run cloud workloads, a.k.a. cloud images. To do that we rely on the Rust Hypervisor Firmware project to provide an ELF formatted KVM firmware for
cloud-hypervisorto directly boot into.We need to get the latest
rust-hypervisor-firmwarerelease and also a working cloud image. Here we will use a Ubuntu image:Multiple arguments can be given to the
--diskparameter.Custom kernel and disk image
Building your kernel
Cloud Hypervisor also supports direct kernel boot into a
vmlinuxELF kernel orbzImage. In order to support virtio-fs and virtio-iommu we have our own development branch. You are of course able to use your own kernel but these instructions will continue with the version that we develop and test against.To build the kernel:
The
vmlinuxkernel image will then be located atlinux-cloud-hypervisor/arch/x86/boot/compressed/vmlinux.bin.Disk image
For the disk image, we will use a Ubuntu cloud image that contains a root partition:
Booting the guest VM
Now we can directly boot into our custom kernel and make it use the Ubuntu root partition. If we want to have 4 vCPUs and 512 MBytes of memory:
The above example use the
virtio-consoledevice as the guest console, and this device may not be enabled soon enough by the guest kernel to get early kernel debug messages.When in need for earlier debug messages, using the legacy serial device based console is preferred:
3. Status
Cloud Hypervisor is under active development. No API or feature stability is guaranteed.
As of 2020-07-02, the following cloud images are supported:
Direct kernel boot to userspace should work with a rootfs from most distributions.
Hot Plug
Cloud Hypervisor supports hotplug of CPUs, passthrough devices (VFIO),
virtio-{net,block,pmem,fs,vsock}and memory resizing. This document details how to add devices to a running VM.Device Model
Details of the device model can be found in this documentation.
TODO
We are not tracking the Cloud Hypervisor TODO list from a specific git tracked file but through github issues instead.
4.
rust-vmmproject dependencyIn order to satisfy the design goal of having a high-performance, security-focused hypervisor the decision was made to use the Rust programming language. The language’s strong focus on memory and thread safety makes it an ideal candidate for implementing VMMs.
Instead of implementing the VMM components from scratch, Cloud Hypervisor is importing the rust-vmm crates, and sharing code and architecture together with other VMMs like e.g. Amazon’s Firecracker and Google’s crosvm.
Cloud Hypervisor embraces the rust-vmm project goals, which is to be able to share and re-use as many virtualization crates as possible. As such, the Cloud Hypervisor relationship with the rust-vmm project is twofold:
Firecracker and crosvm
A large part of the Cloud Hypervisor code is based on either the Firecracker or the crosvm projects implementations. Both of these are VMMs written in Rust with a focus on safety and security, like Cloud Hypervisor.
However we want to emphasize that the Cloud Hypervisor project is neither a fork nor a reimplementation of any of those projects. The goals and use cases we’re trying to meet are different. We’re aiming at supporting cloud workloads, i.e. those modern, full Linux distribution images currently being run by Cloud Service Provider (CSP) tenants.
Our primary target is not to support client or serverless use cases, and as such our code base already diverges from the crosvm and Firecracker ones. As we add more features to support our use cases, we believe that the divergence will increase while at the same time sharing as much of the fundamental virtualization code through the rust-vmm project crates as possible.
5. Community
The Cloud Hypervisor project follows the governance, and community guidelines described in the Community repository.
Contribute
We are working on building a global, diverse and collaborative community around the Cloud Hypervisor project. Anyone who is interested in contributing to the project is welcome to participate.
We believe that contributing to a open source project like Cloud Hypervisor covers a lot more than just sending code. Testing, documentation, pull request reviews, bug reports, feature requests, project improvement suggestions, etc, are all equal and welcome means of contribution. See the CONTRIBUTING document for more details.
Join us
Get an invite to our Slack channel and join us on Slack.