Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory

(Andrew Pennebaker) #1


I’m trying to setup vagrant-libvirt in macOS, so that I can run qemu-provided Vagrant boxes. I have installed Vagrant 2.0.1 via caskroom/cask/vagrant, as well as the vagrant-libvirt 0.0.40 plugin, based on brew’s libvirt 3.9.0 formula (whew!)

However, when I try to run vagrant up --provider libvirt, Vagrant reports:

Error while connecting to libvirt: Error making a connection to libvirt URI qemu:///system?no_verify=1&keyfile=/Users/andrew/.ssh/id_rsa&socket=/var/run/libvirt/libvirt-sock:
Call to virConnectOpen failed: Failed to connect socket to '/var/run/libvirt/libvirt-sock': No such file or directory

Now, I’m new to libvirt, so I’m not really sure how to get the /var/run/libvirt/libvirt-sock connection going in macOS. I’ve seen similar messages about missing sockets with Docker, that are easy enough to resolve by ensuring that Docker is running, and occasionally reloading the shell environment to update any important environment variables. But with libvirt, I don’t see an obvious way to get this socket setup. brew info libvirt doesn’t show any kind of service associated with libvirt, unlike with docker, redis, postgresql, etc. I did find virtlogd, and ran that foreground (silent) application, but by itself, it doesn’t appear to affect the missing socket error presented by Vagrant.

Any idea what a macOS user should do at this point? It would be helpful if the libvirt formula setup this socket on behalf of Vagrant users, but I wasn’t sure if I should suggest this on homebrew-core, in case Discourse is a better place to post this. Anyway, what are the next steps here?


I found libvirtd and ran that foreground application in another terminal tab for now. This still does not allow any virsh -c "qemu+ssh://$(hostname)/system?socket=/var/run/libvirt/libvirt-sock" kind of connection to succeed, but I suspect it’s a form of progress. The libvirtd stderr log shows:

2017-11-14 07:22:56.636+0000: 18446744073709551615: info : libvirt version: 3.9.0
2017-11-14 07:22:56.636+0000: 18446744073709551615: info : hostname: mockingjay.local
2017-11-14 07:22:56.636+0000: 18446744073709551615: warning : virProcessGetStartTime:1070 : Process start time of pid 86142 not available on this platform
2017-11-14 07:22:56.640+0000: 18446744073709551615: error : virConnectOpenInternal:1118 : no connection driver available for qemu:///session

Not sure if this is okay, or if the no connection driver error is getting in the way of virsh from connecting. I just don’t know.

I think the Homebrew formula for libvirt should prepare the libvirtd service in a plist, present the command to the user in the brew info libvirt section, just like how docker, redis, postgresql services are described. Uh, we’ll probably need a more complete libvirtd configuration, but this is a start for really bringing the formula together into a more Just Works^TM mode.