In working with Kernel Virtual Machine (KVM), you will encounter a couple of other terms and technologies. These include QEMU and Libvirt. What are these two technologies, and how do they interact with Kernel Virtual Machine? Let’s look at QEMU and Libvirt and see how these are used when working with KVM.

What is QEMU?

You may have seen the term QEMU referenced when working with Linux virtualization technologies. What is it? QEMU is short for “Quick Emulator”. It is an open-source emulator and a “virtualizer”. It allows admins to run virtual machines on the underlying hardware of their virtualization host.

Protect Your Data with BDRSuite

Cost-Effective Backup Solution for VMs, Servers, Endpoints, Cloud VMs & SaaS applications. Supports On-Premise, Remote, Hybrid and Cloud Backup, including Disaster Recovery, Ransomware Defense & more!

What can QEMU emulate from a hardware perspective? It can emulate hardware components like CPUs, devices, and other peripherals. QEMU can be combined with KVM to use hardware-assisted virtualization and provide near bare-metal performance for virtual machines.

It helps to provide the best of both worlds since you can run guest operating systems inside VMs with high performance and broad compatibility with different hardware.

Other QEMU features

There are other features to note with QEMU, including the ability to create snapshots, migrate virtual machines, and use device pass-through. These are capabilities admins have come to know and expect from a virtualization solution.

Download Banner

QEMU provides a set of capabilities and tools for managing VMs at scale and allows satisfying use cases like development servers (running multiple operating systems on a single host) and hosting production environments.

What is Libvirt?

Another term and technology you will encounter with Linux virtualization is Libvirt. Libvirt is an open-source API and daemon that serves as a management tool for administration. You can also use it to orchestrate virtualized environments across dissimilar hypervisors. These include KVM and QEMU, Xen, and even VMware.

You can think of the Libvirt solution as an abstraction layer that allows management of the underlying virtualization solution. It provides a unified interface with a common API for managing even different hypervisors. As you can imagine, this is a great tool for automating dissimilar hypervisors with a common set of tools.

Libvirt tools

Libvirt also includes various tools that can be used for management, including the well-known virsh command line tool that allows admins to have a command line utility for managing VMs. The Virt-Manager tool is also a graphical user interface for managing VM resources. These provide a reliable framework of management tools for admins to take advantage of in the enterprise.

As mentioned earlier, the API is a great way to integrate other software solutions with your virtualization environment. It allows developers to write programmatic automation for VM management, especially in large environments with many hosts and virtual machines.

In addition to the API, virsh, and VM-Manager, it allows performing common tasks with virtualization environments, such as creating snapshots, live migration, and provisioning storage for your virtualization needs.

Installing QEMU

Let’s consider the process for installing QEMU on a Debian system such as Ubuntu Server. First, we need to make sure the system is up-to-date:

sudo apt update
sudo apt upgrade

To install QEMU in Ubuntu, you can use the following command. Note that it installs both QEMU and KVM to use hardware-assisted virtualization.

sudo apt install qemu qemu-kvm

QEMU, KVM, and Libvirt installation

Installing qemu and KVM

Installing Libvirt

Installing Libvirt is straightforward and can be achieved with a single command line command.

sudo apt install virt-manager virt-viewer

QEMU, KVM, and Libvirt installation

Installing virt-manager and virt-viewer

The virt-manager command is the graphical user interface for managing virtual machines in the command above. Virt-viewer is a viewer that connects to the console of VMs.

You can use the command below to ensure the libvirt daemon starts with the server on boot and is active:

sudo systemctl enable libvirtd
sudo systemctl start libvirtd

QEMU, KVM, and Libvirt installation

Enabling libvirtd and starting the service

To view the status of the libvirt daemon, you can use the following command:

sudo systemctl status libvirtd

QEMU, KVM, and Libvirt installation

Checking the status of libvirtd

Permissions for managing virtual machines without root

If you have a user that you want to be able to manage virtual machines without root privileges, admins can add a user to the libvirt and kvm groups:

sudo usermod -aG libvirt,kvm $USER

QEMU, KVM, and Libvirt installation

Adding a user to the libvirt and kvm groups

Testing the installation

After installing both QEMU and libvirt on your VM host, you can verify the installation using the virsh command. Run the following command on your host:

virsh list –all

QEMU, KVM, and Libvirt installation

Listing out any virtual machines with the virsh list command

This command will most likely not return any results, unless you already have VMs running on your host.

Next steps

If you want to follow along, the next steps are to build a test virtual machine or use your existing Linux virtual machine. Create a snapshot before installing QEMU, KVM, and Libvirt so you can roll back easily. Also, by doing this, you can “rinse and repeat” the exercise.

Start getting familiar with the Linux command line, as this will be a great way to become comfortable working with Linux virtualization utilities, even if you use GUI managers like virt-manager. It helps to understand what is going on behind the scenes.

Wrapping up

QEMU and Libvirt are great complements to Kernel Virtual Machine (KVM). They provide great management capabilities on top of KVM so that admins can effectively and efficiently manage their virtualization infrastructure in the enterprise. KVM is extremely powerful. Many may not realize that large cloud providers like Amazon AWS are running on top of heavily modified KVM variants. At its core, it is KVM.

Read More:
KVM for Beginners – Kernel-based Virtual Machine: An Introduction – Part 1

Rate this post