A Virtual Machine Monitor for modern Cloud workloads.
Go to file
Rob Bradford 23174800ca tests: Port vhost_user_block tests to new methodology
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
2020-08-12 14:53:02 +01:00
.github/workflows scripts: Remove the workaround for "with-serde" build error on AArch64 2020-07-31 12:35:17 +01:00
acpi_tables vmm: acpi_tables: Fix PM timer I/O port width 2020-07-23 17:48:22 +02:00
arch build(deps): bump libc from 0.2.73 to 0.2.74 2020-07-28 20:46:37 +00:00
arch_gen arch, pci, vmm: Initial switch to the hypervisor crate 2020-06-22 15:03:15 +02:00
block_util io-uring: Move to the crates.io 0.4.0 version 2020-08-10 08:40:51 +01:00
devices build(deps): bump libc from 0.2.73 to 0.2.74 2020-07-28 20:46:37 +00:00
docs docs: use shared memory with vhost-user 2020-08-11 19:37:31 +02:00
fuzz fuzz: qcow: Remove unnecessary "use libc" 2020-07-20 20:22:47 +02:00
hypervisor hypervisor: kvm: Make MSRs set/get more flexible 2020-08-05 14:52:35 +01:00
net_gen vmm: Port to latest vmm-sys-util 2019-12-11 14:11:11 +00:00
net_util build(deps): bump serde from 1.0.114 to 1.0.115 2020-08-11 05:14:51 +00:00
option_parser vhost_user_net, vhost_user_block, option_parser: Remove vmm dependency 2020-07-06 18:33:29 +01:00
pci pci: use vfio-bindings from crates.io 2020-08-05 17:50:45 +01:00
qcow build(deps): bump libc from 0.2.73 to 0.2.74 2020-07-28 20:46:37 +00:00
resources ci: AArch64: Update custom linux kernel to v5.8-rc4 2020-07-31 14:06:55 +02:00
rpm rpm: Add spec file for packaging cloud-hypervisor 2020-08-06 09:29:36 +01:00
scripts tests: Use a disk image for test_vfio rather than virtio-fs 2020-08-12 12:19:34 +02:00
src main, vmm: seccomp: Add the '--seccomp log' option 2020-08-04 11:40:49 +02:00
test_data/cloud-init/ubuntu tests: Use a disk image for test_vfio rather than virtio-fs 2020-08-12 12:19:34 +02:00
tests tests: Port vhost_user_block tests to new methodology 2020-08-12 14:53:02 +01:00
vhost_user_backend build(deps): bump libc from 0.2.73 to 0.2.74 2020-07-28 20:46:37 +00:00
vhost_user_block build(deps): bump clap from 2.33.1 to 2.33.2 2020-08-05 20:36:12 +00:00
vhost_user_fs build(deps): bump seccomp from v0.21.2 to v0.22.0 2020-08-06 07:25:30 +00:00
vhost_user_net vhost_user_net: don't claim to impl all features 2020-08-11 12:58:26 +02:00
virtio-devices virtio-devices: vhost-user: Port to EpollHelper 2020-08-12 14:39:54 +02:00
vm-allocator build(deps): bump libc from 0.2.73 to 0.2.74 2020-07-28 20:46:37 +00:00
vm-device pci: Enable GSI routing (MSI type) for AArch64 2020-07-14 14:34:54 +01:00
vm-migration vm-migration: Define the Snapshottable and Transportable traits 2020-04-02 13:24:25 +01:00
vm-virtio build(deps): bump log from 0.4.8 to 0.4.11 2020-07-16 05:33:44 +00:00
vmm vmm: Add brk syscall to the API thread 2020-08-11 15:04:21 +01:00
.gitignore .gitignore: Add build directory 2020-04-03 15:44:14 +01:00
.rustfmt.toml Add .rustfmt.toml to the project 2020-03-13 15:20:34 +00:00
build.rs main: Display git commit hash with the '--version' option 2020-02-14 10:00:14 +01:00
Cargo.lock build(deps): bump linux-loader from b309c9d to b13674a 2020-08-12 07:52:10 +00:00
Cargo.toml Cargo.toml: add missing [package] entries 2020-08-10 08:44:09 +02:00
CODE_OF_CONDUCT.md cloud-hypervisor: Adopt the Contributor Covenant code of conduct 2019-05-12 23:15:30 +02:00
CONTRIBUTING.md misc: Update to new repository locations 2019-11-21 11:39:11 +00:00
CREDITS.md cloud-hypervisor: Add CREDITS 2019-05-12 23:15:30 +02:00
Jenkinsfile build: Remove job directory on ARM64 build 2020-08-10 14:55:50 +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 cloud-hypervisor: Add initial list of maintainers 2019-05-12 23:15:30 +02:00
README.md README: Fix copy command when using config from Cloud-hypervisor 2020-07-28 21:09:22 +01:00
release-notes.md build, release-notes.md: Document 0.9.0 release 2020-08-06 14:31:36 +01:00

Build Status

  1. What is Cloud Hypervisor?
  2. Getting Started
  3. Status
  4. rust-vmm dependency
  5. Community
  6. Security

1. What is Cloud Hypervisor?

This project is an experiment and should not be used with production workloads.

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 Linux* distributions with most I/O handled by paravirtualised devices (i.e. virtio), no requirement for legacy devices and recent CPUs and KVM.

Cloud Hypervisor is implemented in Rust and is based on the rust-vmm crates.

Objectives

High Level

  • KVM and KVM only based
  • Minimal emulation
  • Low latency
  • Low memory footprint
  • Low complexity
  • High performance
  • Small attack surface
  • 64-bit support only
  • Build time configurable CPU, memory, PCI and NVDIMM hotplug
  • Machine to machine migration

Architectures

cloud-hypervisor only supports the x86-64 CPU architecture for now.

We're planning to add support for the AArch64 architecture in the future.

Guest OS

  • 64-bit Linux

Support for modern 64-bit Windows guest is being evaluated.

2. Getting Started

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

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

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

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

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.2.8/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=" \
	--rng
$ 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 image. 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:


# Clone the Cloud Hypervisor Linux branch
$ pushd $CLOUDH
$ git clone --depth 1 https://github.com/cloud-hypervisor/linux.git -b virtio-fs-virtio-iommu-virtio-mem-5.6-rc4 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
$ 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 512 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=" \
	--rng

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=" \
	--rng

3. Status

cloud-hypervisor is in a very early, pre-alpha stage. Use at your own risk!

As of 2020-07-02, the following cloud images are supported:

Direct kernel boot to userspace should work with most rootfs.

Hot Plug

This document details how to add devices to a running VM. Currently only CPU hot plug is supported.

Device Model

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

Join us

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

6. Security

Reporting a Potential Security Vulnerability: If you have discovered potential security vulnerability in this project, please send an e-mail to secure@intel.com. For issues related to Intel Products, please visit https://security-center.intel.com.

It is important to include the following details:

  • The projects and versions affected
  • Detailed description of the vulnerability
  • Information on known exploits

Vulnerability information is extremely sensitive. Please encrypt all security vulnerability reports using our PGP key

A member of the Intel Product Security Team will review your e-mail and contact you to to collaborate on resolving the issue. For more information on how Intel works to resolve security issues, see: Vulnerability Handling Guidelines

PGP Key: https://www.intel.com/content/www/us/en/security-center/pgp-public-key.html

Vulnerability Handling Guidelines: https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html