Top Banner
OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan
28

OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

Mar 07, 2019

Download

Documents

trannga
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

OpenBSD vmm/vmd Update

Mike Larkin

bhyvecon 201611 Mar 2016 – Tokyo, Japan

Page 2: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

Agenda

● History and overview of vmm / vmd● Current status● Future plans● (Reyk): Improvements to vmd / vmctl● Q&A

Page 3: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

VMM History

● People have wanted a native OpenBSD hypervisor for some time

● One night, someone bought me a beer and challenged me to build one ...

Page 4: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

VMM History

● People have wanted a native OpenBSD hypervisor for some time

● One night, someone bought me a beer and challenged me to build one ...

– Isn't this how all these stories start?

Page 5: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

VMM History

● Started coding at Brisbane 2015 hackathon

● Solo development through the summer and fall– Thank OpenBSD Foundation for a grant to

support this work

● First commits late fall 2015

Page 6: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

VMM History

● Why not just port bhyve?

● I Looked at this …

● Equal effort to port or rewrite– Seemed to be different project goals anyway

– We wanted legacy support, i386, etc...

Page 7: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

VMM Initial Design Goals

● “Make it work, make it right, make it fast”● Support different processor models

– Support advanced processor features, but don't require them

– Support i386

● Get OpenBSD on OpenBSD working first– Then “generic virtio based VM”

– Work on other things later

Page 8: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

VMM Overview

● VMM has several parts

● vmd(8)– User mode daemon

– Makes requests to vmm(4) to run VMs

– Handles virtual device I/O

Page 9: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

VMM Overview

● vmm(4)– In-kernel part

– Executes guest VM code

– Transfers control to vmd(8) when device I/O or interrupts occur

● vmctl(8)– User mode control program

– Starts, stops, and controls VMs

Page 10: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

VM Execution

● A user creates a VM– “vmctl start ...”

OpenBSD Kernel w/vmm(4)

vmctl(8)

vmd(8)

Page 11: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

VM Execution

● A user creates a VM– “vmctl start ...”

● vmctl asks vmd to create VM with requested devices

OpenBSD Kernel w/vmm(4)

vmctl(8)

vmd(8)

VM

disk

Net

vcpu

Page 12: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

VM Execution

● vmd asks vmm to run the VM (for each vcpu)

OpenBSD Kernel w/vmm(4)

vmctl(8)

vmd(8)

VM

disk

Net

vcpu

Page 13: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

VM Execution

● vmd asks vmm to run the VM (for each vcpu)

● vmm runs the vcpu until help required (exit)

– Device I/O

– Memory allocation

– Interrupt

– Etc...

OpenBSD Kernel w/vmm(4)

vmctl(8)

vmd(8)

VM

disk

Net

vcpu

vcpu

Page 14: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

VM Execution

● Control returns to vmd as needed

– Device I/O (Disk)

OpenBSD Kernel w/vmm(4)

vmctl(8)

vmd(8)

VM

disk

Net

vcpu

vcpu

Page 15: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

VM Execution

● Control returns to vmd as needed

– Device I/O (Network)

OpenBSD Kernel w/vmm(4)

vmctl(8)

vmd(8)

VM

disk

Net

vcpu

vcpu

Page 16: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

VM Execution

● Control returns to vmd as needed

– Device I/O

● vmd performs the I/O operation

– Repeat vcpu launch ...OpenBSD Kernel w/vmm(4)

vmctl(8)

vmd(8)

VM

disk

Net

vcpu

vcpu

Page 17: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

VM Execution

● Control returns to vmd as needed

– Prohibited operations

– VM termination

OpenBSD Kernel w/vmm(4)

vmctl(8)

vmd(8)

VM

disk

Net

vcpu

vcpu

Page 18: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

Current Status

● Device model– Serial conosle

– virtio(4) devices● vio(4) for networking● vioblk(4) for disks

– Platform devices (legacy devices) as needed

Page 19: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

Current Status

● VM compatibility– Initial focus on amd64 OpenBSD guests

– vmd(8)'s boot loader can load arbitrary ELF kernels

– I loaded both FreeBSD and NetBSD (not currently a personal priority)

Page 20: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

Current Status

● After initial commit, many other developers became involved

– Some working on vmm

– Some working on vmd/vmctl

● My initial vmd/vmctl code sucked

Page 21: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

Current Status

● After initial commit, many other developers became involved

– Some working on vmm

– Some working on vmd/vmctl

● My initial vmd/vmctl code sucked– So Reyk stepped in to fix things

Page 22: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

Current Status

● After initial commit, many other developers became involved

– Some working on vmm

– Some working on vmd/vmctl

● My initial vmd/vmctl code sucked– So Reyk stepped in to fix things

– I probably owe him a beer

Page 23: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

Future Plans

● vmm(4) features– Nested VMX

– i386

– AMD SVM● Then someone will ask for nested SVM …

● All these are implemented to some degree, rotting in my tree

Page 24: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

Future Plans

● VM templates– vmctl run firefox

● Boots firefox in a VM● Filesystem passthrough with whitelist

– Eg, to let firefox access host ~/.mozilla● Forwarded display, isolated network

● VM migration– vmctl send “myvm” | ssh [email protected] vmctl receive

Page 25: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

Future Plans

● One developer is working on qemu interface– For legacy OS support

● One developer is working on making vmm look like KVM

– Easier interfacing with existing tools (also gives another route to qemu interface)

Page 26: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

Finally ...

● If you want to get involved…– ... find something interesting (or ask what needs

to be done)

– … implement it

– … send a diff

Page 27: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

Questions?

● Any questions?

Page 28: OpenBSD vmm/vmd Update - bhyveconbhyvecon.org/bhyvecon2016-Mike.pdf · OpenBSD vmm/vmd Update Mike Larkin bhyvecon 2016 11 Mar 2016 – Tokyo, Japan. Agenda ... Get OpenBSD on OpenBSD

Thank You

Mike [email protected]

@mlarkin2012