Virtualization with KVM: virt-manager

Here you'll find a place for solutions and hints.

Please use one of the support subforums below for questions or if you have any issues and need support.

Virtualization with KVM: virt-manager

Postby inktvis75 » Oct 9th, '17, 08:33

The virt-manager tool to manage KVM virtual machines is maybe not winning a price for his graphical design, it's a very useful and powerful piece of software.

To install it:

Code: Select all
sudo dnf install virt-manager


It will automatically pull all dependencies such as qemu-kvm

After that you have to enable the libvirt daemon at boot time:

Code: Select all
sudo systemctl enable libvirtd


Start this daemon with:

Code: Select all
sudo systemctl start libvirtd


As a normal user you don't have the right permissions to do anything, and it's difficult to get them.
First add yourself to the kvm group:

Code: Select all
usermod -aG kvm <user name>


and create a file /etc/polkit-1/rules.d/50-libvirt.rules with the following content:

Code: Select all
/* Allow users in kvm group to manage the libvirt
daemon without authentication */
polkit.addRule(function(action, subject) {
    if (action.id == "org.libvirt.unix.manage" &&
        subject.isInGroup("kvm")) {
            return polkit.Result.YES;
    }
});


Logout, and you are ready to create virtual machines
inktvis75
 
Posts: 8
Joined: Jun 21st, '13, 08:42
Location: The Netherlands

Re: Virtualization with KVM: virt-manager

Postby doktor5000 » Oct 10th, '17, 09:09

Hi there, at first thanks for sharing.

Just a few hints - please do not assume that people have sudo installed and preconfigured.
Also dnf was only introduced in Mageia 6 and this would not work on Mageia 5, whereas urpmi works for both.
And you should also mention at least that virt-manager is just a graphical frontend to libvirt and to qemu, it can't do anything on its own.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 17629
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Virtualization with KVM: virt-manager

Postby inktvis75 » Oct 10th, '17, 11:01

Thank you for your reply,
i am new in Mageia, and of course new to the Wiki as well.

I updated the article in the wiki, replaced sudo with su and for the systemctl commands: let polkit take care of it :)
inktvis75
 
Posts: 8
Joined: Jun 21st, '13, 08:42
Location: The Netherlands

Re: Virtualization with KVM: virt-manager

Postby Bequimao » Oct 10th, '17, 14:09

Hi,

I started with openSUSE and have a different setup in Mageia 6. My user is part of a group libvirt.
I never started any systemd unit manually, and also did not modify any policykit or Shorewall rule.
The Virtual Machines and isos are owned by root.

Code: Select all
[root@localhost ~]# cat /etc/group | egrep 'libvirt|qemu|kvm'
kvm:x:971:qemu
qemu:x:970:
libvirt:x:469:beq-mageia
[root@localhost ~]#
[root@localhost ~]# systemctl list-units | egrep 'libvirt'
libvirt-guests.service                                                                          loaded active exited    Suspend/Resume Running libvirt Guests
libvirtd.service                                                                                loaded active running   Virtualization daemon
[root@localhost ~]#


Best regards,
Bequimão
Bequimao
 
Posts: 108
Joined: Jun 3rd, '11, 21:51
Location: Minas Gerais, Brazil

Re: Virtualization with KVM: virt-manager

Postby inktvis75 » Oct 10th, '17, 14:31

There are more ways to configure it.
My fresh Mageia installation, after installing libvirtd doesn't contain a libvirt group,
that's why I used the existing kvm group and created a policy.
inktvis75
 
Posts: 8
Joined: Jun 21st, '13, 08:42
Location: The Netherlands

Re: Virtualization with KVM: virt-manager

Postby Bequimao » Jul 23rd, '19, 11:45

Retested now in Mageia 7

Create a system group libvirt.
Code: Select all
# groupadd --system libvirt

Assign your user to it
Code: Select all
# usermod -aG libvirt <user-name>


This also could be implemented in MCC. System groups have group IDs lower than 1000.

The Virtual Machines are owned by root. The isos and paths should be readable by group qemu.
If you want to run a Qemu/KVM user session, uncomment these lines in /etc/libvirt/libvirtd.conf

Code: Select all
unix_sock_group = "libvirt"
unix_sock_rw_perms = "0770"


Reference https://fedoramagazine.org/full-virtual ... tation-30/

Best regards,
Bequimão
Bequimao
 
Posts: 108
Joined: Jun 3rd, '11, 21:51
Location: Minas Gerais, Brazil


Return to The magician suggests...

Who is online

Users browsing this forum: No registered users and 1 guest

cron