Virtualization & Containers

the hypervisor

/ HY-per-vy-zer /

If machine virtualization is the magic show, the hypervisor is the stage manager backstage who makes it all work. It is the piece of software that creates virtual machines, decides which one gets the real CPU right now, owns the real memory and parcels it out, and stands ready to intercept anything a guest does that could affect the real hardware or its neighbours. The older, more precise name is virtual machine monitor (VMM); hypervisor is the popular word for the same thing.

Concretely, the hypervisor runs at a higher privilege level than any of the operating systems it hosts. Picture privilege as rings: an ordinary program runs in the least-trusted ring, an operating system kernel runs in a more-trusted ring, and the hypervisor sits in a ring above even the kernels of its guests. So when a guest kernel - which thinks it is the most powerful software on the machine - executes a sensitive instruction, the hypervisor underneath can catch that attempt, check it, and emulate the intended effect on the virtual hardware, all without the guest noticing. It schedules guests in and out the way an operating system schedules processes, and it presents each guest a consistent illusion of dedicated hardware.

The honest distinction to keep straight: a hypervisor virtualizes the MACHINE (CPU, memory, devices) so each guest brings its own kernel, whereas an operating system kernel virtualizes PROCESSES on top of one machine. They solve the same broad problem - sharing hardware safely - one level apart. Modern hypervisors lean heavily on CPU hardware support (the VT-x and AMD-V features) to make interception cheap; without that support, a hypervisor on x86 had to play elaborate tricks, which is the whole story behind trap-and-emulate and the Popek-Goldberg requirements.

KVM turns the Linux kernel itself into a hypervisor: a normal Linux process opens /dev/kvm, asks the kernel to create a virtual CPU, loads a guest kernel into the guest's memory, and then runs the guest by calling an ioctl that says 'enter the guest until it does something I must handle.'

With KVM the host's own kernel plays the role of the hypervisor.

Hypervisor and virtual machine monitor (VMM) mean the same thing. Do not confuse the hypervisor with the host operating system; in a hosted (type-2) setup they are distinct layers, and in a bare-metal (type-1) setup the hypervisor IS effectively the lowest-level OS.

Also called
virtual machine monitorVMM虛擬機監視器(VMM)