0

I'm currently running a RHEL 7.7 operating system.

I was trying to setup minkube environment using kvm2 driver, so what happens is that minikube starts pretty, but with some errors during the startup .

The error is the following:

'kvm2' driver reported an issue: /bin/virsh domcapabilities --virttype kvm failed:
error: failed to connect to the hypervisor
error: Cannot recv data: Connection reset by peer

So i start to investigate, and first what i did i tried to run the virsh command on the command line getting the same identical error, so second thing i tried is to run this command with sudo, and in this case it worked.

So i think it has to be a permission problem, but still i'm failing to solve this issue (i would like to launch minikube as user without having to use sudo).

What i tried so far:

  1. Add my user in the group libvirt - Still failing
  2. Add my user in the groupos: kvmuser qemu and kvm - Still failing
  3. Updated the libvirtd.conf file with the following configuration:
unix_sock_group = "libvirt"
unix_sock_ro_perms = "0777"
unix_sock_rw_perms = "0770"
unix_sock_dir = "/var/run/libvirt"

  1. Checked the policykit rule, that was already present with this content:
polkit.addRule(function(action, subject) {
    if (action.id == "org.libvirt.unix.manage"
            && subject.local
            && subject.active
            && subject.isInGroup("wheel")) {
        return polkit.Result.YES;
    }
});

So i tried to add my user in the wheel group, still same problem

  1. Addedmy user also in the systemd-network (here i started just to random stuff lol :D) same problem.
  2. Disabled selinux - same problem.

So i searched everywhere and can't find the solution to my problem, soomeone that maybe has managedo to solve it?

I just want to run vish command as a normal user.

0

I do not have a rhel libvirt capable host handy, but with a fedora 31 following the instructions on the libvirt dbus documentation page I can run that as a wheel member user:

$ cat /etc/dbus-1/system.d/org.libvirt.conf 
<?xml version="1.0"?>
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">

<busconfig>

  <policy group="wheel">
    <allow send_destination="org.libvirt"/>
  </policy>

</busconfig>

$ id
uid=1000(natxo) gid=1000(natxo) groups=1000(natxo),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
$ virsh domcapabilities --virttype kvm
<domainCapabilities>
  <path>/usr/bin/qemu-system-x86_64</path>
  <domain>kvm</domain>
  <machine>pc-i440fx-4.1</machine>
  <arch>x86_64</arch>
  <vcpu max='255'/>
  <iothreads supported='yes'/>
  <os supported='yes'>
    <enum name='firmware'>
      <value>efi</value>
    </enum>
...

you may need to restart libvirtd.

  • that didn' t work for me. Btw i found a solution. – Ivan Jan 31 at 13:19
  • I just tried on a rhel 7.7 system and it works, so interesting it didn't for you – natxo asenjo Jan 31 at 15:46
  • Strange, the only thing is that there are some customization from my company on this version of redhat – Ivan Feb 1 at 22:40
0

So after all the struggle (And btw probably adding the user to the right groups was part of the correct configuration), i was still missing one thing to get it works as a user.

Apparently it needs the following environment variable to be exported:

export LIBVIRT_DEFAULT_URI=qemu:///system

After that export if the user is in an allowed group for libvirt, all commands start to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.