Skip to content

Kernel virtual machine

Qemu, KVM and libvirt always get mentioned in the same sentence but what exactly is the relation and purpose of each ?

In short :

  • QEMU is a hypervisor/emulator (Quick EMUlator)
  • KVM is a hypervisor and acceleration agent. (Kernel Virtual Machine)
  • libvirt is just a library of tools to manage the two.

So, whenever you are using these all together, remember there is a hypervisor, an accelerating agent and a management library.

KVM vs QEMU

Libvirt's role is obvious but the difference between kvm and qemu is a lot more subtle.

One hint you will get is that qemu is a standalone package and kvm is called qemu-kvm. And so kvm is indeed and extension of the kernel that let's the virtual machine directly use hardware virtualization, or pass instruction for the Virtual CPU straight to the (a) physical cpu.

Let's start one of each with libvirt:

virt-manager
1
2
3
su
apt install virt-manager qemu qemu-kvm
virt-manager

If you try to run any of these as normal user you will get stuck, so 'su' first.

Creating a...

qemu-system-x86

Actually this was in a script on a disk i wiped afterwards. It is a commandline for starting a qemu image no doubt :

qemu
1
2
3
#qemu-img create diska.img -f qcow2 20G
qemu-system-x86_64 -hda diska.img -cdrom debian-9.1.0-amd64-netinst.iso -boot d -net nic -net user -m 2048 -smp cores=8
#qemu-system-x86_64 -hda diska.img -boot c -net nic -net user -m 2048