Home KVM How To Manage KVM Virtual Machines With Virt-Manager

How To Manage KVM Virtual Machines With Virt-Manager

By sk
Published: Last Updated on 61.2K views

This article describes what is Virt-manager application and how to manage KVM virtual machines with Virt-manager in Linux operating systems.

1. What is Virt-manager?

Virt-manager, short for Virtual Machine Manager, is a graphical user interface application used for managing virtual machines through libvirt. To put this in other words, Virt-manager is a graphical front-end for 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.

The virt-manager application is useful for managing KVM guests hosted in Linux systems that have graphical desktop environments.

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.

2. Install Virt-Manager in Linux

I assume you already have installed KVM on your Linux system. I you haven't installed it. Refer the following guides:

Now let us install Virt-manager. 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 the [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 libvir 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.

2.1. Start and enable libvirtd service

Make sure libvirtd service is enabled and running using command:

$ sudo systemctl status libvirtd

If it is not started, run the following commands to enable and start libvirtd service:

$ sudo systemctl enable libvirtd
$ sudo systemctl start libvirtd

2.2. Add user to libvirt group

Every time you launch Virt-manager, you will be asked to enter the sudo password of your user. To avoid this, add your user to the libvirt group using command:

$ sudo usermod -a -G libvirt $(whoami)

Log out and log back in to apply the changes.

3. 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
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.

3.1. 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 given 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 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.

Here, I've selected POP_OS! 20.04 ISO file, but Virt-manager could not detect the OS type, so I chose Generic default.

choose ISO or install medium location
Choose ISO or install medium location

Choose memory size and number of cores for virtual CPU:

select memory and vcpu for kvm guest
Select memory size and vcpu for kvm guest

Choose the disk size for the Kvm guest:

Create disk image for 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
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
KVM virtual machine's console in Virt-manager

Continue the guest OS installation as usual.

3.2. 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
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
Switch to normal screen view in virt-manager

3.3. 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
View resource usage of kvm guest machines

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

3.4. 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
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.

3.5. Add a virtual hardware

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

add new virtual hardware for KVM guest
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
Choose virtual hardware to attach to KVM guest

3.6. 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
Display Kvm host and guest CPU usage

3.7. 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
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
Clone Kvm virtual machine

3.8. 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
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
View Kvm guest statistics graph

Conclusion

In this guide, we discussed how to install and manage KVM virtual machines using Virt-manager graphical application. Deploying and managing VMs using Virt-manager is not only easy but also fast.

Virt-manager is poor man's Vmware ESXi server and a great replacement for other standalone virtualization applications like Oracle VirtualBox and Vmware workstation.

Since Virt-manager 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:

You May Also Like

10 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
Obviously December 15, 2020 - 3:53 pm

The Obvious Next Thing that users will run into and is not mentioned here: how to share a folder with the VM and the host system? Why not write about these obvious things?

Reply
sk December 15, 2020 - 5:30 pm

It is on my to-do list. Will publish a guide when I have time.

Reply
sk June 7, 2021 - 9:43 pm Reply
Oliver. W August 11, 2021 - 9:40 pm

This is an excellent guide. After troubleshooting, simply following this enabled me to get virt-manager up and running. Bookmarking your website in my Linux folder. 🙂

Reply
sk August 11, 2021 - 10:11 pm

Thank you for your positive feedback, Oliver.

Reply
aum November 15, 2022 - 3:50 pm

good info, thx for sharing
to avoid breaking the os (linux mint 21, in my case) in the future (not that i did not break it already, lol), i want to use qemu vms:
1) mint21dev, for software development
2) mint21test, for testing, ie terminals, neovim flavors (ie lunarVim as ide), and all other learning mistakes, which usually break the os

installing vm, via virt-manager, was easy

but i have my (original) development environment (coding files, etc) on a separate partition, ie /dev/nvme0n1p6, which is ntfs format, and i would like to keep the files there, since i can access them from any of my partition-installed os-es

i can not figure out how to access my original dev partition/files (nvme0n1p6 = susaData partition) from guest os (linux mint 21 vanessa)
i did ‘add hardware’ in my mint21dev guest os, and i can see susaData from guest os, but when i click to access it, window pops-up, offering me to authenticate as guest (no login password), or a user, with password
i tried both options (login as guest, login as user with password), none of those works

can you add tutorial how to access partition/files outside of guest / host os ?
i am aware of sharing a host /guest folder, but that would mean i need to copy existing files from my dev partition (susaData), to host os (shared) folder, and when done with coding, copy new/updated files from share folder back to my original dev partition (susaData)

thank you for your sharing

have fun

aum
s love nia

Reply
sk November 19, 2022 - 1:38 pm

I added this to my todo list. I can’t give any certain date, but I will write about it 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. By using this site, we will assume that you're OK with it. Accept Read More