KVM and Qemu as Linux Hypervisor
Previously we had discussed (https://medium.com/@jain.sm/virtualization-basics-dad2f20067e6)about some of the primitives of Virtualization like cpu,memory and i/o virtualization. Today the intent is to discuss the same more in context of the Linux Kernel virtual machine and Qemu.
Linux provides hypervisor facilities by using Qemu in userspace and a specialized kernel module called KVM. KVM makes use of the intel vt-x extension instruction set to provide isolation of resources at hardware level. Since Qemu is a userspace process, the kernel treats it like other processes from the scheduling perspective.
Before we discuss Qemu and KVM, we touch upon Intel Vt-x and the specific instruction set added by vt-x.
Vt-x solves the problem that the x86 instructions architecture cannot be virtualized.
Simplify VMM software by closing virtualization holes by design.
Ring Compression
Non-trapping instructions
Excessive trapping
Eliminate need for software virtualization (i.e paravirtualization, binary translation).
Adds one more mode called the non-root mode where the virtualized guest can run. Guest doesn’t necessarily have to be an operating system though. There are projects like Dune which run a process within the VM environment rather then a complete OS. In root mode it’s the VMM which runs. This is the mode where kvm runs.