[GTALUG] Setting up a VM host

Lennart Sorensen lsorense at csclub.uwaterloo.ca
Fri Sep 2 12:22:47 EDT 2016


On Thu, Sep 01, 2016 at 10:07:41PM -0400, William Park via talk wrote:
> Now you got me confused.  I thought VirtualBox and QEMU are just
> "emulator" which use KVM kernel modules (ie. kvm, kvm-intel, kvm-amd) if
> they are available, or do full software emulation if not available.
> And, VT-x is required for KVM kernel modules to work.

Virtualbox runs fine without vt-x, bit can't run 64 bit guests in
that case.

kvm is a linux kernel feature for doing virtual machines, and on x86,
it requires vt-x (or the amd equivalant), while on other architectures
(powerpc and arm) it requries different features.  On arm it requires
HYP mode on the CPU, while I think on powerpc it should run on anything.

qemu is an emulator with quite fast cpu emulation that lets you emulate
lots of different architectures.  It's rather neat.  It of course has to
emulate lots of hardware as well as the CPU to emulate complete systems.
So since it emulates lots of hardware very well, kvm decided to use qemu
as the frontend and the device emulation, but to skip the cpu emulation
and instead run natively with kvm providing that part.  It was originally
a fork with patches, but is now merged into the normal qemu.  If you
want an arm vm or powerpc vm, qemu is the thing to use.  Won't be fast,
but they do work.  Qemu also has a user mode emulation where instead
of emulating a whole machine, it emulates a running linux system on
your existing system, so it runs a binary, translating the instructions
for the cpu type (like arm or powerpc) and then translates the system
calls to your native kernel, so you are only emulating the application,
not the whole system, which makes it faster.  This can let you do neat
cross compile tricks with autoconf and such, which normally hate cross
compiling, since you are actually pretending to be the target system
when running things, even though using a cross compiler to actually
build things.  The kernel's binfmt handler helps make this happen
automatically when you register the qemu handlers correctly.

virtualbox also uses qemu code for device emulation (at least some of
it), but I believe it uses its own way of doing the cpu handling (similar
to kvm, but since it runs on many platforms it does not use kvm, and I
believe it actually predates kvm).  It is almost certainly more similar
to what vmware has been doing for years too.  It is able to use the
cpu vt-x (and similar) features when present for better performance,
and in the case of 64 bit guests, it is in fact required (as it also is
for vmware and any other vm system as far as I know).

Virtualbox does NOT use kvm, and in fact gives an error if the kvm
modules are loaded (or at least it used to).  It wants to do vt-x
itself instead.

-- 
Len Sorensen


More information about the talk mailing list