<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sat, Aug 4, 2018 at 10:58 PM Nir Soffer <<a href="mailto:nsoffer@redhat.com">nsoffer@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Sat, Aug 4, 2018 at 4:04 PM Richard W.M. Jones <<a href="mailto:rjones@redhat.com" target="_blank">rjones@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This is only lightly tested (against just qemu NBD client), and the<br>
code might be structured a little better as the<br>
_negotiate_handshake_newstyle_options function has now grown to be<br>
huge.  Anyway works for me.<br></blockquote><div><br></div></div></div><div dir="ltr"><div class="gmail_quote"><div>Works for my python nbd client:</div><div><br></div><div>$ rm -f /tmp/nbd.sock && src/nbdkit -f plugins/file/.libs/nbdkit-file-plugin.so file=test.raw -e export -U /tmp/nbd.sock<br></div><div><br></div><div><div>$ 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)"</div><div>INFO:nbd:Connecting to '/tmp/nbd.sock' 'export'</div><div>DEBUG:nbd:Received server flags: 3</div><div>DEBUG:nbd:Sending client flags: 1:</div><div>DEBUG:nbd:Sending option: 'IHAVEOPT\x00\x00\x00\x07\x00\x00\x00\x0c' data: bytearray(b'\x00\x00\x00\x06export\x00\x00')</div><div>DEBUG:nbd:Received reply [magic=3e889045565a9 option=7 type=3 len=12]</div><div>DEBUG:nbd:Received export info [size=1073741824 flags=109]</div><div>DEBUG:nbd:Received reply [magic=3e889045565a9 option=7 type=1 len=0]</div><div>INFO:nbd:Ready for transmission</div><div>it works</div></div></div></div></blockquote><div><br></div><div>But we have a bug - server configure to allow access to "export",</div><div>but allow access to the default empty "" export.</div><div><br></div><div><div>$ python -c "import logging; logging.basicConfig(level=logging.DEBUG); from ovirt_imageio_common import nbd; c = nbd.Client('/tmp/nbd.sock', '')"</div><div>INFO:nbd:Connecting to '/tmp/nbd.sock' ''</div><div>DEBUG:nbd:Received server flags: 3</div><div>DEBUG:nbd:Sending client flags: 1:</div><div>DEBUG:nbd:Sending option: 'IHAVEOPT\x00\x00\x00\x07\x00\x00\x00\x06' data: bytearray(b'\x00\x00\x00\x00\x00\x00')</div><div>DEBUG:nbd:Received reply [magic=3e889045565a9 option=7 type=3 len=12]</div><div>DEBUG:nbd:Received export info [size=6442450944 flags=109]</div><div>DEBUG:nbd:Received reply [magic=3e889045565a9 option=7 type=1 len=0]</div><div>INFO:nbd:Ready for transmission</div></div><div><br></div><div>Same with qemu-nbd:</div><div><br></div><div>$ qemu-nbd -k /tmp/nbd.sock -t -f raw test.raw --export-name export --cache=none --aio=native --discard=unmap --detect-zeroes=unmap<br></div><div><br></div><div><div>$ python -c "import logging; logging.basicConfig(level=logging.DEBUG); from ovirt_imageio_common import nbd; c = nbd.Client('/tmp/nbd.sock', '')"</div><div>INFO:nbd:Connecting to '/tmp/nbd.sock' ''</div><div>DEBUG:nbd:Received server flags: 3</div><div>DEBUG:nbd:Sending client flags: 1:</div><div>DEBUG:nbd:Sending option: 'IHAVEOPT\x00\x00\x00\x07\x00\x00\x00\x06' data: bytearray(b'\x00\x00\x00\x00\x00\x00')</div><div>DEBUG:nbd:Received reply [magic=3e889045565a9 option=7 type=80000006 len=21]</div><div>Traceback (most recent call last):</div><div>  File "<string>", line 1, in <module></div><div>  File "ovirt_imageio_common/nbd.py", line 126, in __init__</div><div>    self._newstyle_handshake(export_name)</div><div>  File "ovirt_imageio_common/nbd.py", line 181, in _newstyle_handshake</div><div>    self._receive_go_reply()</div><div>  File "ovirt_imageio_common/nbd.py", line 206, in _receive_go_reply</div><div>    .format(ERROR_REPLY[reply], message))</div><div>ovirt_imageio_common.nbd.Error: The requested export is not available [message=export '' not present])</div></div><div><br></div><div> </div></div></div>