[Libguestfs] Interesting libnbd/nbdkit bug

Richard W.M. Jones rjones at redhat.com
Sat May 25 18:10:56 UTC 2019


Try doing:

  $ nbdsh
  nbd> h.connect_command (["nbdkit", "-s", "null"])

At this point you may observe your laptop fan starts to spin and
nbdkit is consuming 100% of CPU.  In all other respects everything
works fine, you can send commands etc.

Anyway I tracked the issue down.  nbdkit sits in a loop continuously
reading stdin, each read(2) call returning EAGAIN.

The reason for that is because libnbd opens a socketpair with the
SOCK_NONBLOCK option and passes one half directly to the forked
subprocess.

It's obviously a bug, but I'm not sure if libnbd should be unsetting
the SOCK_NONBLOCK option or if nbdkit should be doing it.  Maybe both!

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines.  Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v




More information about the Libguestfs mailing list