[Libguestfs] Interesting libnbd/nbdkit bug
Eric Blake
eblake at redhat.com
Sat May 25 20:24:35 UTC 2019
On 5/25/19 1:10 PM, Richard W.M. Jones wrote:
> 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!
Both wouldn't hurt for robustness, but it is more common to fix the
process sending in the non-blocking fd to an unsuspecting child than to
write child processes designed to be robust against parents that forgot.
So I see that you followed precedent and posted a patch for libnbd first :)
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20190525/c15421e5/attachment.sig>
More information about the Libguestfs
mailing list