Virtualization is a hot area in Computing. There is a different type of virtualization solutions and techniques used in a different environment and operating systems. KVM or Kernel-based Virtual Machine is a virtualization technology used in Linux kernel and distributions. Linux KVM can be only used in Linux kernel and distribution because of its design architecture.
Hardware Support for KVM
KVM technology can be only used with hardware support which is provided by the CPU. Intel and AMD CPUs provide this hardware support with the name of
How Does KVM Work?
KVM is a Linux kernel module and in order to work with KVM, the module should be installed and loaded into the Linux kernel. The module is named as
kvm generically but for Intel processors, it is named as
kvm_intel and AMD processors
kvm_amd. Linux kernel will isolate the created Virtual Machine memory and CPU into a process like a separate system.
KVM virtualization provides the following features during the virtualization process.
- `Security`: KVM uses a combination of SELinux and sVirt in order to secure and isolate VMs.
- `Storage`: KVM can use local or NAS related storage technologies with different file systems. VM disk is stored single or multiple files with snapshot, backups.
- `Hardware`: KVM can use a wide variety of Linux supported hardware like USB, Printer, PCI devices, etc.
- `Memory`: KVM inherits memory management features of Linux, including non-uniform memory access and kernel same-page merging.
- `Live Migration`: KVM supports live migration from one Virtualization host to another host without service interruption.
KVM Kernel Modules
As stated previously Linux KVM can be used with kernel modules named
kvm. We install the Linux KVM kernel module with the following command if it is not installed.
$ sudo apt install qemu-kvm
Verify KVM Installation
We can verify the KVM installation with the
kvm-ok command where which will provide information and the hardware support like below.
We can see from the screenshot that
/dev/kvm exists and
KVM acceleration can be used without problem.
KVM is the Linux kernel part of the virtualization. In the user space, the tool named
Qemu is used. Qemu provides the VM devices emulation and kernel communication.
Qemu is started as VM emulator and merged with KVM to provide full virtualization. We can install KVM Qemu with the following command.
$ sudo apt install qemu-kvm
KVM Tool Libvirt
Libvirt is a library used to make KVM virtualization in more enterprise manner. Libvirt provides services in order to connect, manage virtualization services and create, delete, start and stop VMs. We can install the
libvirt with the package name
libvirt-daemon which is a service.
$ sudo apt install libvirt-daemon
KVM GUI Tools
KVM VMs can be managed with different GUI tools. But
virt-manager is the popular tools which can be used locally on the system. We can install Virt Manager like below.
$ sudo apt install virt-manager