$ rm -f /tmp/nbd.sock && src/nbdkit -f plugins/file/.libs/nbdkit-file-plugin.so file=test.raw -e export -U /tmp/nbd.sock
$ python -c "import logging; logging.basicConfig(level=logging.DEBUG); from ovirt_imageio_common import nbd; c = nbd.Client('/tmp/nbd.sock', 'export'); c.write(1024**2, 'it works'); print c.read(1024**2, 8)"
INFO:nbd:Connecting to '/tmp/nbd.sock' 'export'
DEBUG:nbd:Received server flags: 3
DEBUG:nbd:Sending client flags: 1:
DEBUG:nbd:Sending option: 'IHAVEOPT\x00\x00\x00\x07\x00\x00\x00\x0c' data: bytearray(b'\x00\x00\x00\x06export\x00\x00')
DEBUG:nbd:Received reply [magic=3e889045565a9 option=7 type=3 len=12]
DEBUG:nbd:Received export info [size=1073741824 flags=109]
DEBUG:nbd:Received reply [magic=3e889045565a9 option=7 type=1 len=0]
INFO:nbd:Ready for transmission
it works