error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Connection refused

7.1k views Asked by At

I added a virtual network card from a physical network card to the xml file of the virtual machine.

 <devices>
  <interface type='hostdev' managed='yes'>
    <driver name='vfio'/>
    <source>
      <address type='pci' domain='0x0000' bus='0x86' slot='0x0a' function='0x7'/>
    </source>
    <mac address='52:54:00:6d:90:02'/>
  </interface>
  </devices>

When I execute virsh define, I get error info

error: failed to connect to the hypervisor

error: Failed to connect socket to '/var/run/libvirt/libvirt-sock': Connection refused

I tried reinstall libvirt qemu ,but no effect.

1

There are 1 answers

0
Ali Hassan Ahmed Khan On

Try these steps:

sudo setfacl -m user:$USER:rw /var/run/libvirt/libvirt-sock

Exit the session and again logged in then,

sudo systemctl enable libvirtd
sudo systemctl start libvirtd