On Tue, Jul 31, 2018 at 6:17 PM Richard W.M. Jones <address@hidden
> If you like to check the prototype, see:
> qemu's nbd/client.c was very helpful so far, since NBD doc
> is not very clear.
I agree the protocol spec has evolved by accretion so that it no
longer has a coherent narrative. Anyway some general comments on your
client in no particular order:
- Be nice if it was a separate Python library.
- It should support TCP sockets too. In fact those are probably more
important than Unix sockets in the bigger picture. Is there not a
Python "socket client" class you can subclass from which does all
the socket machinery?
This should be easy to support. We probably need to separate the transport
from the client. Will also make it easy to inject errors.
I'm not sure yet about the high level interface, maybe somehting
And for unix:
We need a better url systax.
I would test against ‘qemu-nbd -x’ primarily, then secondarily against
nbd-server and nbdkit. Once it interoperates with all 3 then you're
good to go :-)
nbdkit is not supported now because it does not implement NBD_OPT_GO:
I'll look at it again when qemu-nbd and qemu are fully supported for
incremental backup and virt-v2v.
> Not sure that imageio is the best place for this. Do you have a better idea
> about a better home for this library?
A separate Python library in PyPi or wherever would be my preference.
I don't know what the policy is in imageio about dependencies though.
This seems like the best way, but we need to package it for RHEL and Fedora
to use it in oVirt. Including it in imageio avoid the packaging effort.
In the meantime we can read write and flush, here is an example:
$ qemu-nbd --fork -k /tmp/nbd.sock -t -f qcow2 test.qcow2 -x export -n
>>> from ovirt_imageio_common import nbd
>>> c = nbd.Client("/tmp/nbd.sock", "export")
>>> c.write(1073741824, b"NBD is awesome!")
>>> print(c.read(1073741824, 15))
NBD is awesome!
As is this is very useful for vdsm tests - we currently qemu-io to generate
images with known data, and verify images after operations (e.g. commit).
Using nbd client will be simpler and more powerful.