[libvirt] Cannot write data: Broken pipe when accesing libvirt from a forked process

Josef Stribny jstribny at redhat.com
Wed Sep 30 11:06:48 UTC 2015

Hi all,

I am trying to add vagrant-libvirt support for landrush plugin[0] and 
found out that libvirt fails for me with:

Call to virConnectNumOfNetworks failed: Cannot write data: Broken pipe 

I created a minimal reproducer that causes this:

require 'libvirt'

conn = Libvirt::open("qemu:///system")

fork do
  puts conn.list_networks

puts conn.list_networks

This works just fine on my host, but fails on my virtualized guest 
(when using nested KVM). The journal shows
the following lines in logs:

Failed to acquire pid file '/run/user/1001/libvirt/libvirtd.pid': 
Resource temporarily unavailable

So the forked process here tries to access not-existing libvirtd pid 
file for root (1001 on the VM).

Is this a feature/bug? How can one avoid it?

Thanks everyone

[0] https://github.com/phinze/landrush/pull/124
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150930/2ccf680c/attachment-0001.htm>

More information about the libvir-list mailing list