Running and managing virtual machines on Linux is very easy using the virt-manager GUI program. Under the hood, the virtualization technology takes advantage of KVM (Kernel Virtal Machine) in the Linux kernel. The result of both of these together is fast and efficient hardware virtual machines with a really easy and straightforward GUI to manage them.

For this post, I'll be using the following tools I've talked about in my blog post Using Void Linux as my Daily Driver:

  • vsv - Void Service Manager
  • vpm - Void Package Manager

Installation

Install the following packages to get started:

sudo vpm i virt-manager libvirt qemu

Start the services that are created by these packages:

sudo ln -s /etc/sv/libvirtd /var/service
sudo ln -s /etc/sv/virtlockd /var/service
sudo ln -s /etc/sv/virtlogd /var/service

Use vsv to check the status of the services:

sudo vsv status virt

The final step is to make sure your user is part of the libvirt group:

sudo gpasswd -a "$USER" libvirt

Launching virt-manager

To launch virt-manager, simply call it from the command line:

virt-manager

If everything was set up properly, it should start with no issues. However, there were 2 errors I encountered during my setup that I had to fix. If you follow the instructions above, then these errors shouldn't happen.

Error 1

Authentication error:

no polkit agent available to authenticate action 'org.libvirt.unix.manage'

Unable to connect to libvirt qemu:///system.

authentication unavailable: no polkit agent available to authenticate action 'org.libvirt.unix.manage'

Libvirt URI is: qemu:///system

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/connection.py", line 1036, in _do_open
    self._backend.open(self._do_creds_password)
  File "/usr/share/virt-manager/virtinst/connection.py", line 144, in open
    open_flags)
  File "/usr/lib/python2.7/site-packages/libvirt.py", line 104, in openAuth
    if ret is None:raise libvirtError('virConnectOpenAuth() failed')
libvirtError: authentication unavailable: no polkit agent available to authenticate action 'org.libvirt.unix.manage'

This error is caused by the current user not being part of the libvirt group. This can be fixed with:

$ sudo gpasswd -a "$USER" libvirt
Adding user dave to group libvirt

Error 2

No emulator:

Cannot find suitable emulator for x86_64

Unable to connect to libvirt qemu:///system.

internal error: Cannot find suitable emulator for x86_64

Libvirt URI is: qemu:///system

Traceback (most recent call last):
  File "/usr/share/virt-manager/virtManager/connection.py", line 1120, in _open_thread
    self._populate_initial_state()
  File "/usr/share/virt-manager/virtManager/connection.py", line 1074, in _populate_initial_state
    logging.debug("conn version=%s", self._backend.conn_version())
  File "/usr/share/virt-manager/virtinst/connection.py", line 325, in conn_version
    self._conn_version = self._libvirtconn.getVersion()
  File "/usr/lib/python2.7/site-packages/libvirt.py", line 3992, in getVersion
    if ret == -1: raise libvirtError ('virConnectGetVersion() failed', conn=self)
libvirtError: internal error: Cannot find suitable emulator for x86_64

This error is caused by qemu not being installed. This can be fixed with:

$ sudo vpm i qemu
...

Conclusion

If everything in the installation process worked, then the virt-manager program should open with a blank slate ready to create and manage VMs:

It is also possible to use virsh on the command line to get a list of all VMs on the machine:

$ sudo virsh list --all
 Id   Name   State
--------------------

See my next blog post SmartOS COAL on Linux KVM with Virt Manager for steps to install SmartOS with KVM.