I've mentioned this topic before (in fact, the idea of adding NBD_CMD_FLAG_DF was first mentioned at [1]), but finally finished enough of an implementation to feel confident in posting it. I'd still like to add something under examples/ that uses the new API to implement strict checking of a server's structured replies read implementation (ensure that a server never sends data after an error at the same offset, that it does not send overlapping data, and that it does not report success unless all of the range is covered). [1] https://www.redhat.com/archives/libguestfs/2019-May/msg00209.html Eric Blake (8): states: Add state for structured reply completion states: Consolidate search for current reply's command pread: Reject server SR read response with no data chunks states: Prepare for read callback states: Wire in a read callback states: Add nbd_pread_callback API states: Add tests for nbd_pread_callback states: Add DF flag support for pread .gitignore | 1 + generator/generator | 140 +++++++++++++++++++-- generator/states-reply-simple.c | 31 +++-- generator/states-reply-structured.c | 147 +++++++++++----------- generator/states-reply.c | 31 ++++- interop/Makefile.am | 11 +- interop/structured-read.c | 182 ++++++++++++++++++++++++++++ interop/structured-read.sh | 57 +++++++++ lib/aio.c | 2 + lib/flags.c | 11 ++ lib/internal.h | 22 +++- lib/nbd-protocol.h | 1 + lib/protocol.c | 1 + lib/rw.c | 51 +++++++- python/t/405-pread-callback.py | 42 +++++++ tests/oldstyle.c | 74 ++++++++++- 16 files changed, 686 insertions(+), 118 deletions(-) create mode 100644 interop/structured-read.c create mode 100755 interop/structured-read.sh create mode 100644 python/t/405-pread-callback.py -- 2.20.1