cif16: solo5: building a unikernel base from scratch (dan williams, ibm)

28
Building a unikernel base from scratch Dan Williams, IBM Research 2016 Unikernels and More: Cloud Innovators Forum January 22, 2016, Pasadena, CA Solo5

Upload: the-linux-foundation

Post on 18-Jan-2017

820 views

Category:

Technology


4 download

TRANSCRIPT

Page 1: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

Building a unikernel base from scratch Dan Williams, IBM Research 2016 Unikernels and More: Cloud Innovators Forum January 22, 2016, Pasadena, CA

Solo5

Page 2: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 2 20 January 2016

§ For the purposes of this talk, think of MirageOS unikernels – Are tiny VMs running on Xen – Run one program (no more, no less) – Are written in OCaml

§ Many potential benefits – Security – Performance – Ops

Unikernels are great

Xen-based Cloud

OCaml Program

Page 3: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 3 20 January 2016

Inside a unikernel

Unikernel

application code

libraries and runtime

unikernel base

OC

aml

C

Hypervisor

Page 4: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 4 20 January 2016

§ Low-level hypervisor-interfacing code

§ Example: Mini-OS – Demonstrates Xen PV interface – Used by MirageOS, ClickOS,

HalVM, LING, etc.

Inside a unikernel

Unikernel

application code

libraries and runtime

unikernel base

OC

aml

C

Hypervisor

Page 5: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 5 20 January 2016

§ Built from scratch

§ Available on Github – https://github.com/djwillia/solo5

Solo5: a new unikernel base

Unikernel

application code

libraries and runtime

Solo5

OC

aml

C

Hypervisor

Page 6: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 6 20 January 2016

§ Where a unikernel can run

§ How fast a unikernel can boot

§ What higher layers can do

Why focus on the unikernel base?

Unikernel

application code

libraries and runtime

unikernel base

OC

aml

C

Hypervisor

Page 7: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 7 20 January 2016

§  Different hypervisors expose different abstractions –  Full virtualization (e.g., KVM/QEMU) –  Paravirtualization (e.g., Xen PV) – Mini-OS was designed for Xen PV

§  Device interfaces –  PV device access (Xen, virtio) –  Physical device access (SR-IOV)

§  Defined by interaction between hypervisor and unikernel base

Where a unikernel can run

Mini-OS

Xen PV

Solo5

KVM/QEMU

Page 8: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 8 20 January 2016

§  20ms boot time – ClickOS and Jitsu – Both built on mini-OS

§  Is PV essential?

§ What is the role of the hypervisor toolstack vs. the unikernel base?

How fast a unikernel can boot

Image from: https://github.com/mirage/jitsu

§  Defined by interaction between hypervisor and unikernel base

Page 9: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 9 20 January 2016

§ Base for language runtime – MirageOS (OCaml), LING (Erlang), HalVM (Haskell), etc.

§ Base for native applications – ClickOS (Click router), etc.

§ Exposing primitives – Memory protection or tracing – Address space layout randomization – Support for thread/event model

What higher layers can do

Page 10: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 10 20 January 2016

§  The unikernel base is fundamentally important!

§  The best way to really understand (and then innovate on) this layer is to build one (Solo5)

§  But hopefully it can be useful to others – Ensure existing higher layers still work à MirageOS – Broaden where MirageOS can run à KVM/QEMU

§  Solo5 runs MirageOS on KVM/QEMU

Summary

Page 11: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 11 20 January 2016

§ Why focus on the unikernel base?

§ How to build a unikernel base (Solo5) from scratch

§ How you can try it out

Roadmap

Page 12: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 12 20 January 2016

MirageOS in a bit more detail

§ Application (OCaml) Config

files App

Code

Page 13: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 13 20 January 2016

MirageOS in a bit more detail

§ Application (OCaml)

§ OCaml libraries TCP/IP HTTP

serving Lwt FS Config files

App Code

Page 14: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 14 20 January 2016

MirageOS in a bit more detail

§ Application (OCaml)

§ OCaml libraries

§ Platform bindings – OCaml runtime – Calls out to a subset

of libc– Calls out to some

Xen-specific functions

TCP/IP HTTP serving Lwt FS Config

files App

Code

mirage-platform bindings

Page 15: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 15 20 January 2016

MirageOS in a bit more detail

§ Application (OCaml)

§ OCaml libraries

§ Platform bindings

§ Drivers – Written in OCaml – Xen PV split model – Call out to platform

TCP/IP HTTP serving Lwt FS Config

files App

Code

mirage-net-xen

mirage-blk-xen

mirage-console-xen

mirage-platform bindings

Page 16: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 16 20 January 2016

MirageOS in a bit more detail

Mini-OS kernel

Low-level Xen PV primitives

§ Application (OCaml)

§ OCaml libraries

§ Platform bindings

§ Drivers

§ Unikernel base – Contains some libc– Low-level Xen info

TCP/IP HTTP serving Lwt FS Config

files App

Code

Xen PV

mirage-net-xen

mirage-blk-xen

mirage-console-xen

mirage-platform bindings

Page 17: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 17 20 January 2016

MirageOS in a bit more detail

Mini-OS kernel

Low-level Xen PV primitives

§ Application (OCaml)

§ OCaml libraries

§ Platform bindings

§ Drivers

§ Unikernel base

§ Tooling

VM

TCP/IP HTTP serving Lwt FS Config

files App

Code

Xen PV

mirage-net-xen

mirage-blk-xen

mirage-console-xen

mirage-platform bindings

Page 18: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 18 20 January 2016

MirageOS on Solo5

Mini-OS kernel

Low-level Xen PV primitives

§ Application (OCaml) TCP/IP HTTP

serving Lwt FS Config files

App Code

mirage-net-xen

mirage-blk-xen

mirage-console-xen

mirage-platform bindings

Page 19: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 19 20 January 2016

MirageOS on Solo5

Mini-OS kernel

Low-level Xen PV primitives

§ Application (OCaml)

§ OCaml libraries – No changes!

TCP/IP HTTP serving Lwt FS Config

files App

Code

mirage-net-xen

mirage-blk-xen

mirage-console-xen

mirage-platform bindings

Page 20: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 20 20 January 2016

MirageOS on Solo5

Mini-OS kernel

Low-level Xen PV primitives

§ Application (OCaml)

§ OCaml libraries

§ Platform bindings – OCaml runtime – Calls out to a subset

of libc– Rewrite Xen-specific

functions

TCP/IP HTTP serving Lwt FS Config

files App

Code

mirage-net-xen

mirage-blk-xen

mirage-console-xen

mirage-platform bindings

Page 21: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 21 20 January 2016

MirageOS on Solo5

Mini-OS kernel

Low-level Xen PV primitives

mirage-platform bindings

§ Application (OCaml)

§ OCaml libraries

§ Platform bindings

§ Drivers – virtio instead of Xen – Access PCI bus – Solo5 drivers do most

of the work in C with wrappers in OCaml

TCP/IP HTTP serving Lwt FS Config

files App

Code

mirage-net-solo5

mirage-blk-solo5

mirage-console-solo5

virtio net driver

virtio blk driver console driver

Page 22: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 22 20 January 2016

MirageOS on Solo5

Solo5 kernel

Low-level HW primitives

mirage-platform bindings

§ Application (OCaml)

§ OCaml libraries

§ Platform bindings

§ Drivers

§ Unikernel base – Some libc– HW initialization – Memory, Interrupts – No threads, address

spaces

TCP/IP HTTP serving Lwt FS Config

files App

Code

mirage-net-solo5

mirage-blk-solo5

mirage-console-solo5

virtio net driver

virtio blk driver console driver

KVM/QEMU

Page 23: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 23 20 January 2016

MirageOS on Solo5

§ Application (OCaml)

§ OCaml libraries

§ Platform bindings

§ Drivers

§ Unikernel base

§ Tooling – mirage tool – Makefile

VM

TCP/IP HTTP serving Lwt FS Config

files App

Code

mirage-net-solo5

mirage-blk-solo5

mirage-console-solo5

mirage-platform bindings

Solo5 kernel virtio net driver

virtio blk driver console driver

Low-level HW primitives

KVM/QEMU

Page 24: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 24 20 January 2016

§ Why focus on the unikernel base?

§ How to build a unikernel base (Solo5) from scratch

§ How you can try it out

Roadmap

Page 25: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 25 20 January 2016

§  On a Linux host with the KVM module

§  Build and run from a Docker container –  Fetch the image

–  Start a privileged container

–  Enter the container

–  Build and run!

How you can try it out

dockerpulldjwillia/solo5-mirage

dockerrun–dprivileged–namesolo5-mirage–tdjwillia/solo5-mirage

dockerexec–itsolo5-mirage/bin/bash-l

cd~/solo5makeconfig_consolemakekvm

Page 26: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 26 20 January 2016

§ Boot time investigation – A bootable iso in KVM/QEMU will be too slow – What about KVM/lkvm?

§ How much of Solo5 can be pushed: – Down into the hypervisor? – Up into MirageOS (OCaml)?

§ What should the hypervisor/unikernel base interface be?

Next steps with Solo5

Page 27: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2016 IBM Corporation 27 20 January 2016

§ Bare unikernel base to build from – https://github.com/djwillia/solo5

§ MirageOS on Solo5 on KVM/QEMU – https://github.com/djwillia/solo5/tree/mirage

§ Contact me! – [email protected]

Thank you!

|___|__|_\|_\__\\__\(||(|)|____/\___/_|\___/____/helloworld

Page 28: CIF16: Solo5: Building a Unikernel Base From Scratch (Dan Williams, IBM)

©2015 IBM Corporation