Home VirtualizationKVM How To Manage KVM Virtual Machines With Virt-Manager
Manage KVM Virtual Machines With Virt-Manager In Linux

How To Manage KVM Virtual Machines With Virt-Manager

By sk
7029 Views

This article describes how to manage KVM virtual machines with Virt-manager in Linux. We already knew how to install and configure KVM in CentOS 8 server, how to setup KVM in Ubuntu 20.04 LTS server and how to manage the kvm guests using Cockpit web-console. The virt-manager application is for managing KVM guests hosted in Linux systems that have graphical desktop environments.

Virt-manager, short for Virtual Machine Manager, is a graphical user interface application used for managing virtual machines through libvirt. Even though it is mainly created for KVM guests, it also can manage XEN and LXC containers as well. It has an embedded VNC and SPICE client viewer application to view the full screen console of a running VM.

Virtual Machine Manager allows the users to:

  • create, edit, start, suspend, resume and stop VMs,
  • view and control each VM's console,
  • view all running VMs and hosts,
  • view the performance and utilization statistics of each VM,
  • view the live performance and resource utilization statistics of VMs and hosts,
  • manage KVM, Xen or QEMU virtual machines, running either locally or remotely,
  • manage LXC containers etc.

Virt-manager is written in Python and developed by Red Hat.

Install Virt-Manager in Linux

Virt-manager has been packaged for many popular Linux distros.

On Arch Linux and its variants like Manjaro Linux, run the following command to install Virt-manager:

$ sudo pacman -S virt-manager

On Debian, Ubuntu:

$ sudo apt install virt-manager

In Ubuntu make sure you have enabled [universe] repository.

On RHEL, CentOS, Fedora:

$ sudo dnf install virt-manager

On openSUSE:

$ sudo zypper install virt-manager

In addition to Virt-manager, the following supporting tools will also be installed as well:

  • virt-install - a command line tool to provision new virtual machines. It creates a new KVM, Xen, or Linux container guests from command line using the "libvirt" hypervisor management library.
  • virt-viewer - a lightweight UI interface to view and interact with the graphical display of virtualized guest OS. It can display VNC or SPICE, and uses libvirt to lookup the graphical connection details.
  • virt-clone - a command line tool used to clone existing inactive guests. It copies the disk images, and defines a config with new name, UUID and MAC address pointing to the copied disks.
  • virt-xml - a command line tool to edit libvirt domain XML.
  • virt-convert - a command line tool to convert OVF and VMX VM configurations to run with libvirt.
  • virt-bootstrap - a command tool providing an easy way to setup the root file system for libvirt-based containers.

Manage KVM Virtual Machines With Virt-Manager

Once Virt-manager is installed, launch it from Dash or menu. The default interface of Virt-manager should look like below:

Default interface of Virt-manager application

Managing KVM guests with Virt-manager is very easier than you think. Let me show you basic Kvm management tasks with screenshots.

Create a new virtual machine

Go to File -> New Virtual Machine from Virt-manager main window. Choose how would you like to install the guest OS. You will be give four choices as listed below:

  • Local install media (E.g. ISO or CDROM),
  • Network install such as HTTP, HTTPS, or FTP,
  • Network Boot (E.g. PXE),
  • Import existing disk image.

I go with "Local install media" option. Click Forward to continue:

choose install medium for kvm guest

Choose the ISO file location of the OS. If you have the physical CD/DVD medium, choose it instead. You operating system type will automatically be selected depending on the installation medium you choose. If Virt-manager can't detect the OS type, uncheck the option that says "Automatically detect from the installation media / source" and select "Generic default" as your OS type. I selected POP_OS! 20.04 ISO file, but Virt-manager could not detect the OS type, so I choose Generic default.

choose ISO or install medium location

Choose memory size and number of cores for virtual CPU:

select memory and vcpu for kvm guest

Choose the disk size for the Kvm guest:

Create disk image for Kvm guest

Enter the name for your Kvm guest. The name should not contain any blank spaces. Click Finish to create the virtual machine.

Enter Kvm guest name

Once the Virtual machine is created, you will be automatically taken to the virtual machine's graphical console window.

KVM virtual machine's console in Virt-manager

Continue the guest OS installation as usual.

Switch between normal mode and full screen screen mode

By default, the guest will start in normal window mode. You can toggle to full screen mode by clicking on the "Switch to full screen view" button on the top right side of console window.

switch to full screen view in virt-manager

To go back to normal window, move the mouse cursor to the top middle side (over the date and time of VM) and you will see "Leave full screen" option, just click on it to switch to normal window.

switch to normal screen view in virt-manager

View all running kvm guests and their resource usage

The Virt-manager main window shows all running kvm guests and resource utilization by the guests.

View resource usage of kvm guest machines

From here, you can start, pause, save the current state of a VM, restart and shutdown VMs.

View Kvm virtual machine details

The virtual hardware details window shows the information about all hardware resources configured to the kvm guest.

show virtual hardware details

In this window, you can,

  • view running guest OS details,
  • view the Hypervisor details,
  • view guest operating system's type,
  • view resource utilization by cpu, memory, disk and network,
  • view number of vCPUs,
  • view allocated memory size,
  • view boot options,
  • view virtual disk and cdrom details,
  • view network settings,
  • view keyboard and mouse settings,
  • view display card details,
  • view sound card details,
  • view information of all other hardware attached to the guest machine,
  • add a new virtual hardware,
  • modify the parameters of a virtual hardware,
  • remove virtual hardware etc.

Add a virtual hardware

Open Virtual hardware details window and click "Add Hardware" button at the bottom.

add new virtual hardware for KVM guest

Choose the hardware type you want to add from the left pane and pick a device from the list to attach to the guest machine.

choose virtual hardware to attach to KVM guest

View Kvm host and guest CPU usage

From Virt-manager main window, we can view the all guest machines' cpu usage by default. To view the KVM host's CPU usage, go to View -> Graph and select "Host CPU Usage" option.

Display Kvm host and guest CPU usage

Clone Kvm guests

Virt-manager allows us to clone the existing virtual machines. First make sure the guest machine is switched off. Right click on the guest machine and choose "Clone" from the menu.

clone Kvm guests

It creates a new independent copy of the original virtual disk and defines a config with new name, UUID and MAC address pointing to the copied disks.

clone Kvm virtual machine

View Disk I/O, Network I/O, Memory stats

By default, Virt-manager will only shows the CPU usage. If you want to view the statistics of Disk I/O, Network I/O and Memory, you must enable them from Virt-manager main window.

Go to View -> Preferences and check those options to enable them.

Virt-manager preferences window

Then go to View -> Graph and select Memory Usage, Disk I/O and Network I/O. Now you will see these statistics from the Virt-manager main window.

view Kvm guest statistics graph

Conclusion

Virt-manager is poor man's Vmware ESXi server and a great replacement for other standalone virtualization applications like Oracle VirtualBox and Vmware workstation. Deploying and managing VMs using Virt-manager is easy and fast. Since it is from Red Hat, we can get consistent updates and bug fixes. If you have sufficient hardware, you could setup a perfect server virtualization environment for your organization using Virt-manager without much hassle.

Resources:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

3 comments

Mike Galax July 11, 2020 - 12:27 am

The KVM series on this web site is a god send. This covers up-to-date tutorial about KVM. Particularly interesting for KVM beginners. Can you please also cover how to use Vagrant to manage KVM VMs?

Reply
sk July 11, 2020 - 12:03 pm

I added this to my todo list. KVM is vast topic. I will try to cover as much as I can in the days to come.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More