[Tutorial] How to install Virt-Manager Correctly on EOS/Arch base systems

virtManager_logo

Since its introduction virtualization has come a long way. Nowadays hypervisors are used for almost everything from running enterprise-level servers to testing different operating systems on a local user computer. There are many paid and free hypervisor solutions available in the world.

But in this guide, we are looking at installing one of these best free toolsets used for virtualization and they’re Virt-Manager, KVM, and QEMU. This guide will show you how to install these tools correctly and with less hassle. Before starting let’s get to know this software a bit better.

What is Virt-Manager?

Virt-Manager is a graphical user front end for the libvirt library which provides virtual machine management services. Virt-manager interface makes it easy for the user to create, delete and manipulate virtual machines without going through the terminal.

Virt-manager mainly support KVM but it can work with other hypervisors such as Xen and LXC.

When virt-manager is installed it comes with the below-listed toolset.

  • virt-install: Command-line utility to provision OS
  • virt-viewer: The UI interface with graphical features
  • virt-clone: Command-line tool to close existing inactive hosts
  • virt-xml: Command-line tool for easily editing libvirt domain XML using virt-install’s command-line options.
  • virt-bootstrap: Command tool providing an easy way to set up the root file system for libvirt-based containers.

KVM

The letters KVM stands for Kernel-based Virtual Machines. KVM is a Linux full virtualization solution for x86 architecture processors which has the virtualization extension (Intel VT and AMD-V).

KVM is a free (as free beer) and open-source software. The support for KVM is included in all the new Linux kernels by design.

QEMU

QEMU is the shortened version of Quick EMUlator which is a free open-source emulator that can perform hardware virtualization. It emulates the host machine processor through dynamic binary translation. Which provides different sets of hardware and device models for the host machine, which enables it to run a variety of guest systems.

KVM can be used with QEMU which allows virtual machines to be run nearly to native speeds. Not just hardware emulation QEMU is capable of emulating user-level processors which enable applications compiled for one architecture to run on another.

Installing virt-manager

  1. Installing all the packages to run virt-manager.
sudo pacman -S virt-manager qemu libvirt edk2-ovmf dnsmasq bridge-utils openbsd-netcat iptables-nft

  1. After installation completes you need to enable libvirtd service.
sudo systemctl enable --now libvirtd.service
  1. Check for the status to make sure the service is running.
sudo systemctl status libvirtd.service

The output should look something like below.

○ libvirtd. service - Virtualization daemon
     Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: disabled)
     Active: inactive (dead) since Tue 2021-08-31 20:33:58 +0530; 1h 14min ago
TriggeredBy: ● libvirtd-admin.socket
             ● libvirtd-ro.socket
             ● libvirtd.socket
       Docs: man:libvirtd(8)
             https://libvirt.org
    Process: 21412 ExecStart=/usr/bin/libvirtd $LIBVIRTD_ARGS (code=exited, status=0/SUCCESS)
   Main PID: 21412 (code=exited, status=0/SUCCESS)
      Tasks: 2 (limit: 32768)
     Memory: 18.5M
        CPU: 423ms
     CGroup: /system.slice/libvirtd.service
             ├─982 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
             └─983 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper

Aug 31 20:31:42 sinux-pch systemd[1]: Started Virtualization daemon.
Aug 31 20:31:42 sinux-pch dnsmasq[982]: read /etc/hosts - 5 addresses
Aug 31 20:31:42 sinux-pch dnsmasq[982]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Aug 31 20:31:42 sinux-pch dnsmasq-dhcp[982]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Aug 31 20:33:58 sinux-pch systemd[1]: libvirtd.service: Deactivated successfully.
Aug 31 20:33:58 sinux-pch systemd[1]: libvirtd.service: Unit process 982 (dnsmasq) remains running after unit stopped.
Aug 31 20:33:58 sinux-pch systemd[1]: libvirtd.service: Unit process 983 (dnsmasq) remains running after unit stopped.
Aug 31 21:03:23 sinux-pch dnsmasq[982]: reading /etc/resolv.conf
Aug 31 21:03:23 sinux-pch dnsmasq[982]: using nameserver 192.168.8.1#53
Aug 31 21:03:23 sinux-pch dnsmasq[982]: using nameserver 192.168.1.1#53
  1. To use our normal user without entering the root password we need to configure KVM to enable it. This will also enable the libvirt networking components as well without doing this it won’t work.

    1. You need to open the libvirt configuration file located at /etc/libvirt/libvertd.conf. To open you can use your favorite text editor (vi, vim, or nano).
    sudo nano /etc/libvirt/libvirtd.conf
    
    1. Now we need to set UNIX domain socket ownership to libvirt. Scroll down till you see the below line and uncomment it.
    unix_sock_group = 'libvirt'
    
    1. Let’s set the UNIX socket permission to R/W. Scroll down till you see the below line and uncomment it.
    unix_sock_rw_perms = '0770'
    
    1. Add your user account to the libvirt group.
    sudo usermod -a -G libvirt $(whoami)
    or
    sudo usermod -a -G libvirt <your user name>
    
    • whoami is a function that put the current user to the placeholder
    1. Now we need to add our user to qemu.conf. Otherwise, QEMU will give a permission denied error when trying to access local drives. You can use your favorite text editor to edit the file.
    sudo nano /etc/libvirt/qemu.conf
    
    1. Scroll down or search for user = "root" or group = "root". Then uncomment both entries and change the root to your user name or ID and then save and exit. Once edited it should look something like below.
    # Some examples of valid values are:
    #
    #       user = "qemu"   # A user named "qemu"
    #       user = "+0"     # Super user (uid=0)
    #       user = "100"    # A user named "100" or a user with uid=100
    #
    user = "your user name"
    
    # The group for QEMU processes run by the system instance. It can be
    # specified in a similar way to user.
    group = "your user name"
    
    1. You can restart your service but it’s best to reboot the entire system.
    sudo shutdown -r now
    

Additional Functionality

libguestfs

If you wish to edit the created virtual machine disk images you can install libguestfs. These are set of tools that allow the user to view and edit files inside guest systems, change VM script changes, monitoring disk space, creating new guests, P2V, V2V, performing backups, cloning VM, and much more.

To install.

yay -S libguestfs

qemu-arch-extra

Adds additional architecture support to QEMU.

To install.

yay -S qemu-arch-extra

qemu-block-gluster

Glusterfs is a scalable network filesystem. This adds Glusterfs block support to QEMU.

To install.

yay -S qemu-block-gluster

qemu-block-iscsi

iSCI enables storage access via a network. qemu-block-iscsi enables QEMU to block this.

To install.

yay -S qemu-block-iscsi

qemu-block-rbd

It adds the ability to create block device images.

To install.

yay -S qemu-block-rbd

samba

This would add support to SMB/CIFS support to QEMU.

To install.

yay -S samba

Enabling virtio graphics with 3D acceleration

There are several graphical accelerations modes supported by virt-manager.

  • QXL - QXL paravirtual graphic card. It is VGA compatible (including VESA 2.0 VBE support). Works best with qxl guest drivers installed though. Recommended choice when using the spice-protocol.

  • Bochs - The Bochs VGA BIOS supports, to an extent, the VBE specification.

  • Ramfb - A simple frame buffer that lives in guest RAM and is configured via fw_cfg.

  • VGA - Standard VGA card

  • Virtio - Virtio-gpu is a paravirtualized 3d accelerated graphics driver.

When using virtio with 3D acceleration some time virt-mangers doesn’t work and it throws an error. It’s actually is not virt-manager it’s qemu you that’s crashing.

In order to use virtio with 3D acceleration, you need to configure virt-manager as shown below.

  1. Go to Display Spice and check Open GL check box and select Auto from the drop-down.
    Before configuring,

    After configuring,

  2. Now go to Video and select virtio then check the 3D Acceleration checkbox.

  3. Install spice-vdagent guest drivers. In your gust operating system/disribution.

sudo pacman -S spice-vdagent

NOTE: At the time of writing there is an issue when using virtio with 3D acceleration with XFCE DE which leads to guests having a black screen. It is caused by the default xfwm4+compositing compositor. The known workaround is to use ‘QXL’ or virtio without 3D acceleration. If you want to use it with 3D acceleration you can find the workaround here.

After configuring like this you can enjoy a fully 3D accelerated guest VM. Also, remember to click on Apply.

Installing virtio guest drivers for Windows

RedHat supplies a set of guest drivers for virtio which covers the graphic drivers for the guest system. You can download the latest drivers from their GitHub page here.

Guest tools links

Conclusion

In this article, we have covered most of the aspects of how to install and configure virt-manager and KVM. Hope this article helped you to get your virtual environment up and running. If there are any questions feel free to reach us at the forums or any other contact channel listed below.

21 Likes

Hope this helps some one and like to know if any corrections are needed.

5 Likes

I notice in the file is set to 0777 I changed it to zero. What do these entries do in this file?

unix_sock_rw_perms = '0770'

Edit: Also i tried the graphics thing that dalto mentioned but didn’t see that it did what i wanted for setting resolution. V-box does a better job in this area as i can set exactly my monitor resoltion and it adjusts slight to fit in the window allowing the task bar above and below. The one above being v-box and the one below being my host. This is the way i like it. So i improvise on virt-manager and set the largest i can that fits and it leaves a border on each end in black.

There are 2 entries the one with 0777 is unix_sock_ro_perms = "0777" it’s for the R/O socket which is used to monitor VM status.

You only need to un-comment unix_sock_rw_perms = '0770'. Which allows the full management for the group libvirt.

Graphics I’m still trying to figure that part out as well. I got a resolution issue with Arco Linux when using the graphic setting @dalto mentioned. And had use xrandr. I’ll play with it more and get to know it more.

VirtualBox is fr noob friendly and easy to use also, the guest add-ons make the graphical part much smoother. But I did see a performance difference between VMs on virt-manager and VirtualBox.

2 Likes

I’m also finding that it isn’t working on virtio 3D anymore and i have to use qxl. Before i was using virtio 3D with no issues bit since update which i think was qemu it doesn’t work now.

When i want to install:

Error starting domain: Cannot access storage file ‘/run/media/andreas/DATEN/rebornos.qcow2’ (as uid: 65534, gid: 992): Permission denied

What can i do?

  • When you open virt-manager does it ask for a password?
  • Did you add your user to the libvirt group?
1 Like

Yes, QEMU crashes when trying to use 3D.

no ask for password

sudo usermod -a -G libvirt andreas

I do add my user to the libvirt group!

Then it seems like your user is not able to access the path. If you just added the user try to libvirt group do a restart and try again.

Also, are you able to access that path normally? try creating the .qcow2 file in your /home folder to check if it works then there is a permission issue with the location.

1 Like

Ok, thank you. I take a look at the path!

I managed to recreate and find a solution to the issue. I added it to as step 5 onwards under where we add our user to libvirt group in the tutorial.

EDIT Made: Step 5 onwards under where we add our user to libvirt group in the tutorial. found the workaround to this error virt-manager Could not open '.iso': Permission denied'.

I have added a link to this tutorial on the already existing (but less detailed) tutorial on the same topic (Virt-Manager Tutorial) and have cleaned up the meta talk here regarding that topic.

2 Likes

EDIT Made: Added this section to describe how to enable virtio graphics with 3D acceleration.

P:S: @ricklinux this one is for you. :smiley:

Unfortunately it’s not working. It tries to load the ISO but i only the get cursor on the screen and the live desktop doesn’t load. Also i keep getting the kde wallet coming up. It comes up when i try to connect to wifi, or use chromium and now virt-manager. I don’t know how to deal with kde wallet. There is nothing else installed for it. I don’t know how to use it because i don’t know where to get a key for it or set it up and other components aren’t installed for it. Not sure why it’s even installed as part of the packages.

Screenshot_20210901_134528

That’s strange I tested all the steps before posting them which worked for me.

It works if i don’t fill the 3D box full. If i just leave it half what ever that does. Then it loads the live ISO. I can try it after it’s installed on full.

Edit: It froze in the installer.

I’m testing it. Are you using a Windows ISO or Linux?if Windows are you trying to boot into the installation? If Linux which?eos?

Eos and i have amdgpu on Ryzen.

Edit: I will just use it on Qxl. This all started with the update on qemu. It used to work fine.