Linux virtualization
By Sudheer S
KVM (Kernel-based Virtual Machine), libvirt
, and QEMU are three components that work together to provide a
virtualization solution on Linux systems.
KVM is a virtualization infrastructure built into the Linux kernel that allows it to run multiple virtual machines (VMs) on a single physical host. It provides the underlying virtualization technology, such as hardware acceleration for virtualized CPU and memory, and device emulation.
libvirt
is an open-source API, daemon, and management tool for virtualization environments, it provides a common,
stable, and simple interface for managing virtualization technologies such as KVM, QEMU, and others.
QEMU is a type-2 hypervisor, it is an emulator that provides the virtual devices (such as virtual CPUs, virtual hard drives and virtual network interfaces) for the virtual machines. It is the device model for KVM and provides the interface for interacting with the virtual devices. It also provides the ability to run VMs on different architectures, so that you can run VMs with different CPU architectures than the host.
When using KVM, libvirt
and QEMU together, libvirt
communicates with the kernel through KVM to create and control
virtual machines, while QEMU provides the virtual devices for the VMs. The libvirt
API allows for the creation,
management, and monitoring of virtual machines, and the use of QEMU allows for a wide range of virtual devices to be
used with these VMs.
In summary, KVM provides the virtualization infrastructure, QEMU provides the virtual devices, and libvirt
provides
a common interface for managing both, making it easy to create, control and manage virtual machines on Linux systems.
Other programs leverage the interface provided by libvirt
to offer a user interface. Some examples of such programs:
- Virtual Machine Manager known as
virt-manager
provides a GUI application to manage the VMs - Cockpit provides a web UI to manage virtual machines
virsh
is a command line tool to manager virtual machines
Vagrant leveraging libvirt
provides a reproducible virtual environments.
Command To Install Virtualization Tools
Ubuntu
sudo apt install virt-manager vagrant-sshfs vagrant-libvirt libvirt-daemon-system libvirt-daemon-driver-qemu libvirt-daemon libvirt-clients qemu
Fedora
sudo dnf install @virtualization --with-optional virtualization
sudo dnf install @vagrant
Start And Enable libvirt
sudo systemctl start libvirtd
sudo systemctl enable libvirtd
Operate libvirt without using sudo
Add yourself to the libvirt
group.
sudo gpasswd -a ${USER} libvirt
newgrp libvirt