A Virtual Machine Monitor for modern Cloud workloads.
Go to file
Bo Chen 29cf637f3f vmm: Move 'default_serial/console()' to vm_config.rs
In this way, we have all functions related to generate default values of
vm-config structs in the same location.

Signed-off-by: Bo Chen <chen.bo@intel.com>
2022-10-07 09:13:15 -07:00
.github build: Consolidate "gdb" build feature into "guest_debug" 2022-09-27 14:30:57 +01:00
acpi_tables build: Bulk dependencies update 2022-09-14 15:01:04 +01:00
api_client api-client: Allow response to be captured 2022-09-28 15:23:03 +01:00
arch build: Bump libc from 0.2.133 to 0.2.134 2022-09-30 01:01:13 +00:00
block_util build: Bump io-uring from 0.5.6 to 0.5.7 2022-10-06 23:49:36 +00:00
devices build: Bump libc from 0.2.133 to 0.2.134 2022-09-30 01:01:13 +00:00
docs build: Consolidate "gdb" build feature into "guest_debug" 2022-09-27 14:30:57 +01:00
event_monitor build: Bump libc from 0.2.133 to 0.2.134 2022-09-30 01:01:13 +00:00
fuzz build: Bump io-uring from 0.5.6 to 0.5.7 in /fuzz 2022-10-07 00:23:20 +00:00
hypervisor build: Bump libc from 0.2.133 to 0.2.134 2022-09-30 01:01:13 +00:00
net_gen build: bump vmm-sys-util from 0.9.0 to 0.10.0 2022-07-20 09:40:28 +00:00
net_util build: Bump libc from 0.2.133 to 0.2.134 2022-09-30 01:01:13 +00:00
option_parser option_parser: For tuple list type strip brackets only once 2022-08-08 16:23:00 +01:00
pci build: Bump libc from 0.2.133 to 0.2.134 2022-09-30 01:01:13 +00:00
performance-metrics build: Bump clap from 4.0.9 to 4.0.10 2022-10-05 23:51:49 +00:00
qcow build: Bump libc from 0.2.133 to 0.2.134 2022-09-30 01:01:13 +00:00
rate_limiter build: Bump libc from 0.2.133 to 0.2.134 2022-09-30 01:01:13 +00:00
resources build: Update development container to Rust 1.62 2022-07-05 11:50:46 +01:00
scripts scripts: Remove common feature flag for mshv tests 2022-09-28 10:53:22 +00:00
serial_buffer vmm: Move SerialBuffer to its own crate 2022-08-30 13:47:51 +02:00
src vmm: Remove deprecated VmConfig::{kernel, initramfs, cmdline} members 2022-10-06 14:25:29 +01:00
test_data/cloud-init/ubuntu ci: Make L1 guest use RAW image in test_vfio 2022-08-04 11:37:18 +01:00
test_infra build: Bump libc from 0.2.133 to 0.2.134 2022-09-30 01:01:13 +00:00
tests vhost_user_net: Allow user to set MTU 2022-09-27 10:37:35 +01:00
tracer build: Bump libc from 0.2.133 to 0.2.134 2022-09-30 01:01:13 +00:00
vfio_user build: Bump libc from 0.2.133 to 0.2.134 2022-09-30 01:01:13 +00:00
vhdx build: Bump libc from 0.2.133 to 0.2.134 2022-09-30 01:01:13 +00:00
vhost_user_block build: Bump clap from 4.0.9 to 4.0.10 2022-10-05 23:51:49 +00:00
vhost_user_net build: Bump clap from 4.0.9 to 4.0.10 2022-10-05 23:51:49 +00:00
virtio-devices virtio-mem: mem: Simplify 'process_queue' 2022-10-07 07:57:08 -07:00
vm-allocator build: Bump libc from 0.2.133 to 0.2.134 2022-09-30 01:01:13 +00:00
vm-device build: Bump thiserror from 1.0.36 to 1.0.37 2022-09-28 10:06:58 +01:00
vm-migration build: Release v27.0 2022-09-29 17:56:21 +01:00
vm-virtio build: Release v27.0 2022-09-29 17:56:21 +01:00
vmm vmm: Move 'default_serial/console()' to vm_config.rs 2022-10-07 09:13:15 -07:00
.gitignore rpm: Extend spec to support aarch64 and more 2022-05-25 10:08:27 +02:00
.rustfmt.toml build: migrate to Rust 2021 edition 2022-04-11 09:51:12 +01:00
build.rs misc: Automatic beta clippy fixes 2022-09-20 10:59:48 +01:00
Cargo.lock build: Bump itoa from 1.0.3 to 1.0.4 2022-10-07 00:41:45 +00:00
Cargo.toml build: Bump clap from 4.0.9 to 4.0.10 2022-10-05 23:51:49 +00:00
CODE_OF_CONDUCT.md cloud-hypervisor: Adopt the Contributor Covenant code of conduct 2019-05-12 23:15:30 +02:00
CODEOWNERS ci: Adding a CODEOWNERS file 2022-05-18 14:03:37 +01:00
CONTRIBUTING.md CONTRIBUTING.md: Add sample pre-commit hook 2022-08-16 09:42:39 +01:00
CREDITS.md cloud-hypervisor: Add CREDITS 2019-05-12 23:15:30 +02:00
Jenkinsfile build: Disable SGX build 2022-09-20 21:59:03 +01:00
LICENSE-APACHE cloud-hypervisor: Add proper licensing 2019-05-09 15:44:17 +02:00
LICENSE-BSD-3-Clause cloud-hypervisor: Add proper licensing 2019-05-09 15:44:17 +02:00
MAINTAINERS.md docs: Update MAINTAINERS.md 2021-07-29 14:40:31 +02:00
README.md README.md: Add mailing list details 2022-09-29 14:24:48 +01:00
release-notes.md build: Release v27.0 2022-09-29 17:56:21 +01:00

1. What is Cloud Hypervisor?

Cloud Hypervisor is an open source Virtual Machine Monitor (VMM) that runs on top of KVM hypervisor and Microsoft Hypervisor (MSHV).

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

  • Runs on KVM or MSHV
  • Minimal emulation
  • Low latency
  • Low memory footprint
  • Low complexity
  • High performance
  • Small attack surface
  • 64-bit support only
  • CPU, memory, PCI hotplug
  • Machine to machine migration

Architectures

Cloud Hypervisor supports the x86-64 and AArch64 architectures. There are some small differences in functionality between the two architectures (see #1125).

Guest OS

Cloud Hypervisor supports 64-bit Linux and Windows 10/Windows Server 2019.

2. Getting Started

Below sections describe how to build and run Cloud Hypervisor on the x86_64 platform. For getting started on the AArch64 platform, please refer to the Arm64 documentation.

Host OS

Based on required KVM functionality the minimum host kernel version is 4.11. For adequate peformance the minimum recommended host kernel vesion is 5.6. The majority of the CI currently tests with kernel version 5.15.

Preparation

We create a folder to build and run cloud-hypervisor at $HOME/cloud-hypervisor

$ export CLOUDH=$HOME/cloud-hypervisor
$ mkdir $CLOUDH

Install 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.

# Install build-essential, git, and qemu-utils
$ sudo apt install git build-essential qemu-utils
# Install rust tool chain
$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# If you want to build statically linked binary please add musl target
$ rustup target add x86_64-unknown-linux-musl

Clone and build

First you need to clone and build the cloud-hypervisor repo:

$ pushd $CLOUDH
$ git clone https://github.com/cloud-hypervisor/cloud-hypervisor.git
$ cd cloud-hypervisor
$ cargo build --release

# We need to give the cloud-hypervisor binary the NET_ADMIN capabilities for it to set TAP interfaces up on the host.
$ sudo setcap cap_net_admin+ep ./target/release/cloud-hypervisor

# If you want to build statically linked binary
$ cargo build --release --target=x86_64-unknown-linux-musl --all
$ popd

This will build a cloud-hypervisor binary 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:

$ pushd $CLOUDH
$ cd cloud-hypervisor
$ ./scripts/dev_cli.sh build --release

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:

$ ./scripts/dev_cli.sh tests --unit

Run the ./scripts/dev_cli.sh --help command to view all the supported development script commands and their related options.

Use Prebuilt Binaries

Cloud Hypervisor packages targeting some popular Linux distributions are available thanks to the Open Build Service. The OBS README explains how to enable the repository in a supported Linux distribution and install Cloud Hypervisor and accompanying packages. Please report any packaging issues in the obs-packaging repository.

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-hypervisor to directly boot into.

We need to get the latest rust-hypervisor-firmware release and also a working cloud image. Here we will use a Ubuntu image:

$ pushd $CLOUDH
$ wget https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img
$ qemu-img convert -p -f qcow2 -O raw focal-server-cloudimg-amd64.img focal-server-cloudimg-amd64.raw
$ wget https://github.com/cloud-hypervisor/rust-hypervisor-firmware/releases/download/0.4.1/hypervisor-fw
$ popd
$ pushd $CLOUDH
$ sudo setcap cap_net_admin+ep ./cloud-hypervisor/target/release/cloud-hypervisor
$ ./cloud-hypervisor/target/release/cloud-hypervisor \
	--kernel ./hypervisor-fw \
	--disk path=focal-server-cloudimg-amd64.raw \
	--cpus boot=4 \
	--memory size=1024M \
	--net "tap=,mac=,ip=,mask="
$ popd

Multiple arguments can be given to the --disk parameter.

Custom kernel and disk image

Building your kernel

Cloud Hypervisor also supports direct kernel boot into a vmlinux ELF kernel. In order to support virtio-watchdog 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:


# Clone the Cloud Hypervisor Linux branch
$ pushd $CLOUDH
$ git clone --depth 1 https://github.com/cloud-hypervisor/linux.git -b ch-5.15.12 linux-cloud-hypervisor
$ pushd linux-cloud-hypervisor

# Use the cloud-hypervisor kernel config to build your kernel
$ cp $CLOUDH/cloud-hypervisor/resources/linux-config-x86_64 .config
$ KCFLAGS="-Wa,-mx86-used-note=no" make bzImage -j `nproc`
$ popd

The vmlinux kernel image will then be located at linux-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:

$ pushd $CLOUDH
$ wget https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img
$ qemu-img convert -p -f qcow2 -O raw focal-server-cloudimg-amd64.img focal-server-cloudimg-amd64.raw
$ popd

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 1024 MBytes of memory:

$ pushd $CLOUDH
$ sudo setcap cap_net_admin+ep ./cloud-hypervisor/target/release/cloud-hypervisor
$ ./cloud-hypervisor/target/release/cloud-hypervisor \
	--kernel ./linux-cloud-hypervisor/arch/x86/boot/compressed/vmlinux.bin \
	--disk path=focal-server-cloudimg-amd64.raw \
	--cmdline "console=hvc0 root=/dev/vda1 rw" \
	--cpus boot=4 \
	--memory size=1024M \
	--net "tap=,mac=,ip=,mask="

The above example use the virtio-console device 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:

$ ./cloud-hypervisor/target/release/cloud-hypervisor \
	--kernel ./linux-cloud-hypervisor/arch/x86/boot/compressed/vmlinux.bin \
	--console off \
	--serial tty \
	--disk path=focal-server-cloudimg-amd64.raw \
	--cmdline "console=ttyS0 root=/dev/vda1 rw" \
	--cpus boot=4 \
	--memory size=1024M \
	--net "tap=,mac=,ip=,mask="

3. Status

Cloud Hypervisor is under active development. The following stability guarantees are currently made:

  • The API (including command line options) will not be removed or changed in a breaking way without a minimum of 2 major releases notice. Where possible warnings will be given about the use of deprecated functionality and the deprecations will be documented in the release notes.

  • Point releases will be made between individual releases where there are substantial bug fixes or security issues that need to be fixed. These point releases will only include bug fixes.

Currently the following items are not guaranteed across updates:

  • Snapshot/restore is not supported across different versions
  • Live migration is not supported across different versions
  • The following features are considered experimental and may change substantially between releases: TDX, vfio-user, vDPA.

As of 2022-04-05, the following cloud images are supported:

Direct kernel boot to userspace should work with a rootfs from most distributions.

Further details can be found in the release documentation.

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.

Roadmap

The project roadmap is tracked through a GitHub project.

4. rust-vmm project dependency

In 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:

  1. It will use as much of the rust-vmm code as possible. Any new rust-vmm crate that's relevant to the project goals will be integrated as soon as possible.
  2. As it is likely that the rust-vmm project will lack some of the features that Cloud Hypervisor needs (e.g. ACPI, VFIO, vhost-user, etc), we will be using the Cloud Hypervisor VMM to implement and test them, and contribute them back to the rust-vmm project.

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.

Slack

Get an invite to our Slack channel and join us on Slack.

Mailing list

Please report bugs using the GitHub issue tracker but for broader community discussions you may use our mailing list.

Security issues

Please contact the maintainers listed in the MAINTAINERS.md file with security issues.