bhyvecon Tokyo 2019 - The BSD Hypervisor Conference
Author: Kamil Rytarowski
E-mail: kamil@netbsd.org
Date: March 20th, 2019
Location: Tokyo, Japan
Kamil Rytarowski (born 1987)
Krakow, Poland
NetBSD user since 6.1.
NetBSD Foundation member since 2015.
Work areas: kernel, userland, pkgsrc.
Interest: NetBSD on desktop and in particular NetBSD as a workstation.
Current activity in 3rd party software:
Virtualization is a very broad term. We refer here to running a full Operating System [instance] (guest) on another already running Operating System [instance] (host).
There are two basic types of virtualization:
A hypervisor (Virtual Machine Monitor) is software, firmware, or hardware that creates and runs virtual machines.
There are two types of hypervisors:
Software emulation VS hardware assisted emulation
Full software emulation is slower, but can support cross-CPU virtualization and is typically accessible without privileged hardware features.
Hardware assisted virtualization uses CPU specific features in order to get near native execution speed of a guest machine, but it's usually restricted to the same CPU architecture only and requires privileged kernel drivers.
There are two types of virtualization in the interest of NetBSD developers and users:
Whenever applicable and expected, it's desired to support NetBSD as both guest and host Operating System.
For practical reasons it's necessary to handle NetBSD as a guest Operating System in foreign environments (such as remote VPS services) and virtualize non-NetBSD systems on a NetBSD host (such as retro computing).
Does it still matter in NetBSD? Yes!
Software emulation matters in NetBSD in particular for:
NetBSD/riscv running on the Spike emulator
https://twitter.com/zmcgrew/status/1055682596812730368
http://releng.netbsd.org/test-results.html
Featured kernel cross-CPU debugging and introspection.
Powerful combination of emulator and debugger, such as Qemu + GDB (prebuilt with cross-ABI support).
1 # Adding breakpoints on function names:
2 (gdb) break sys_open
3 Breakpoint 1 at 0xffffffff804b267f:
4 file /home/dimitris/Code/netbsd-current/src/sys/kern/vfs_syscalls.c, \
5 line 1672.
6 [...]
7 (gdb) ptype struct mbuf
8 type = struct mbuf {
9 struct m_hdr m_hdr;
10 union {
11 struct {...} MH;
12 char M_databuf[456];
13 } M_dat;
14 }
https://t.pagef.lt/working-with-the-netbsd-kernel/
Probably the most frequently used software virtual machines for NetBSD guests:
https://www.netbsd.org/ports/emulators.html
Software emulation is not good for everything, especially whenever we depend upon performance.
Performance and cost of execution are mandatory elements of practically all production work loads.
Whenever we require performance we need hardware assisted emulation.
Due to practical reasons and current resources of the project, the main focus of hardware assisted emulation is the x86 (Intel and AMD) architecture.
However, there is some activity and interest in the aarch64 land as well.
Currently available options:
https://github.com/NetBSD/src/commit/5929a332ef850162327ea78d56ab9c1900daf71f
http://wiki.netbsd.org/ports/xen/
https://wiki.xen.org/wiki/Xen_Project_Software_Overview#Guest_Types
http://wiki.netbsd.org/ports/xen/howto/
Multiprocessor (SMP) support in NetBSD differs depending on the domain:
The standard approach is to use NetBSD/amd64 for the dom0.
The dom0 system, plus each domU, can be either i386PAE or amd64. i386 without PAE is not supported.
For domUs, i386PAE is considered faster than amd64.
http://wiki.netbsd.org/ports/xen/howto/
There are two hardware accelerated engines in the NetBSD kernel.
HAXM (by Intel, ported to NetBSD by Kamil Rytarowski):
NVMM (by Maxime Villard):
Both engines:
Why are there two kernel engines for the same purpose?
All in all: HAXM allows to get the job done earlier and reduce cost of porting software to NetBSD (expanding the QEMU support for NetBSD/HAXM was a 1-liner patch), NVMM is the long term recommendation (and requires more porting).
Could HAXM and NVMM be merged? No, as both have different targets and the legacy of HAXM APIs and design choices (with accumulated technical debt) restricts it to Intel x86 desktop users. It was easier to start from scratch than totally rewrite existing code.
http://blog.netbsd.org/tnf/entry/the_hardware_assisted_virtualization_challenge
http://m00nbsd.net/4e0798b7f2620c965d0dd9d6a7a2f296.html
1 I have been running Windows 2000, XP and 7 as NetBSD/Xen guests
2 (amd64) for quite a while now. It is not perfect (eg. graphics
3 over VNC, no audio, could not get PCI or USB forwarding to work,
4 performance is not great) but quite reliable.
5
6 Posted by khorben on January 30, 2019 at 10:26 AM UTC #
http://blog.netbsd.org/tnf/entry/the_hardware_assisted_virtualization_challenge#comment-1548843971000
There is in-kernel hypervisor detection and extra handling of VMware, Microsoft HyperV, Xen and KVM.
There are available special device drivers for virtualization:
Pending tasks:
Long term/research:
https://wiki.netbsd.org/users/kamil/qemu/
Enable NetBSD support for:
If possible port Xen to NetBSD/evbarm and NetBSD/aarch64.
NVMM pending tasks:
HAXM pending tasks:
Table of Contents | t |
---|---|
Exposé | ESC |
Full screen slides | e |
Presenter View | p |
Source Files | s |
Slide Numbers | n |
Toggle screen blanking | b |
Show/hide slide context | c |
Notes | 2 |
Help | h |