While I was thinking about what I'd write for my proposed nbdkit talk
at FOSDEM next year, this strikes me as clunky:
rm -f /tmp/sock
nbdkit -U /tmp/sock file foo
nbd-client -u /tmp/sock /dev/nbd0
...
nbd-client -d /dev/nbd0
killall nbdkit
In qemu-nbd, all that is just this:
qemu-nbd -c /dev/nbd0 foo
It seems like it would be nice to implement an ‘nbdkit -c /dev/nbdX’
option.
My first idea was:
nbdkit -c /dev/nbdX
==> nbdkit -U [sock]
& running: nbd-client -nofork -u [sock] /dev/nbdX
However that still leaves the need for end users to manually delete
the nbdX device & kill nbdkit.
If I'm understanding the qemu code correctly, qemu-nbd uses its own
internal NBD client running in a pthread, so it doesn't need
nbd-client. So it can keep the client running next to the server and
neatly handle cleanup of the device & server on exit.
(In case it's not clear, the nbd-client userspace process does not
persist with modern kernel NBD.)
I can't think of a good way to implement this in nbdkit so if anyone's
got any ideas ...
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html