Bhyve Hypervisor (Bsdcan 2011)
Bhyve Hypervisor (Bsdcan 2011)
BSD Hypervisor
Neel Natu
Peter Grehan
Introduction
BHyVe stands for BSD Hypervisor
Pronounced like beehive
Availability
NetApp is releasing the source code under the BSD license!
Snapshot against 8.1 in svn repository: /projects/bhyve_ref
Work In Progress
Status
Guest
FreeBSD/amd64 releases 7.2 and 8.1
SMP - up to 8 virtual cpus
I/O - virtio or pci passthru
Minor kernel patches required
Host
FreeBSD/amd64 release 8.1
Unmodified GENERIC kernel
Hardware
Requires hardware virtualization assist with Nested Page Tables
Intel VT-x is supported
AMD-V support in progress
3
Guest
App
Host Application
Guest
App
Host Application
Guest Operating System
FreeBSD
Host Operating System
Hypervisor
Module
BHyVe: Implementation
legacy i/o
uart, rtc
virtio-net
virtio-block
vmrun
host
threads
Host user
allocmem
setreg
run
ioemul
Host kernel
ioctls, memory management, apic emulation
vmm.ko
Intel VT-x or AMD-V
vm enter
vcpus
address
translation
Guest
Physical
Memory
Virtual
machine
CPU Virtualization
Requires Intel VT-x or AMD-V virtualization assists
Trap into the hypervisor for a variety of reasons
Instructions like RDMSR, OUTB, CPUID, HLT, PAUSE
Hardware interrupts
Memory Virtualization
Requires hardware support for Nested Page Tables
Guest Physical to Host Physical translation
virtio
Paravirtualized device specification
http://ozlabs.org/~rusty/virtio-spec/virtio-paper.pdf
PCI Passthru
Guest has direct access to a PCI device
Some configuration registers are still emulated
BAR registers
MSI capability
Stub driver in the host forwards interrupts from the device to the
guest
Virtual MSI capability for passthru devices that only support
legacy interrupts
blackhole driver prevents the host from attaching to passthru
devices
10
Guest Modifications
Custom console and debug port
Done for expediency
Not necessary if we have a 16550 device model
11
User-space API
A virtual machine appears in the host filesystem as a device
node
ioctls used to control and configure the virtual machine
20 in total
For e.g. setreg, pincpu, run, interrupt, getstats
Can read(), write() and mmap() the virtual machine device node
Useful to inspect the virtual machine's memory
dd if=/dev/vmm/testvm of=memdump bs=1024 count=1024
12
Performance
Features
Address space identifiers for virtual cpus
Minimal overhead host IPIs
Some guest state is lazily saved only on slow trap to user-space
Guest floating point registers
System call related MSRs
make buildworld
4 cores, 2GB memory, 1GbE NIC, 1 SATA disk
/usr/src is mounted over NFS
/usr/obj is mounted on a block device
Configuration
Bare Metal
1308
Partitioned
1336
Virtualized
1446
13
Future Opportunities
Support Windows, Linux and *BSD guests
Support AMDs hardware virtualization assist
Guest suspend/resume and live migration
BIOS emulation
14
15