[Libguestfs] [libnbd PATCH v2 00/12] Improve NBD_OPT_ control

Eric Blake
Wed, 31 Aug 2022 14:39:16 -0000

v1 was here (under the subject Smarter nbd_opt_info)
https://listman.redhat.com/archives/libguestfs/2022-August/029641.html

Since then, I've done a lot.  The original patch 1/2 is now split
across 7/12 and 9/12; while original patch 2/2 is expanded across
several patches to test more scenarios.  Several new prerequisite
patches were added to address smaller issues one at a time and with
better commit messages.  Where possible, I have kept tests separate
from the patch introducing a fix to allow temporary reordering at that
point in the series to prove the test catches the issue.  It was not
possible on tests for new APIs, nor on patch 2/12 where the only test
I could come up with involves hacking a one-off nbdkit that does not
behave like a normal server; it was also hard to justify on 3/12 where
reordering the patches results in a test skip rather than failure,
where distinguishing the difference requires reading logs to see
whether an API failed client-side or server-side.

Maybe we want to add an API to track how many packets are sent over
the wire (client->server, and server->client), to make it easier to
actually catch when things are filtered client-side, or how often a
server uses multiple reply chunks to answer a single client request.

I've also fixed a bug in nbd_can_meta_context that was discovered
while responding to v1 reviews, and completed part of the work at
adding new APIs hinted at earlier (but still to add: APIs for
nbd_opt_structured_replies and nbd_opt_starttls).

Eric Blake (12):
  internal: Use vector instead of linked list for meta_contexts
  api: Fix nbd_can_meta_context if NBD_OPT_SET_META_CONTEXT fails
  api: Allow nbd_opt_list_meta_context without SR
  api: Add nbd_set_request_meta_context()
  tests: Language port of nbd_set_request_meta_context() tests
  info: Explicitly skip NBD_OPT_SET_META_CONTEXT in --list mode
  api: Make nbd_opt_list_meta_context stateless
  tests: Add coverage for stateless nbd_opt_list_meta_context
  api: Reset state on changed nbd_set_export_name()
  tests: Add coverage for nbd_set_export_name fix
  api: Add nbd_[aio_]opt_set_meta_context
  tests: Language port of nbd_opt_set_meta_context() tests

 lib/internal.h                               |  19 +-
 generator/API.ml                             | 174 ++++++++++++-
 generator/states-newstyle-opt-go.c           |   1 +
 generator/states-newstyle-opt-meta-context.c |  77 +++---
 generator/states-newstyle.c                  |   1 +
 generator/states-reply-structured.c          |  11 +-
 lib/flags.c                                  |  27 +-
 lib/handle.c                                 |  26 ++
 lib/opt.c                                    |  53 +++-
 lib/rw.c                                     |   2 +-
 python/t/110-defaults.py                     |   1 +
 python/t/120-set-non-defaults.py             |   2 +
 python/t/230-opt-info.py                     |  36 ++-
 python/t/240-opt-list-meta.py                |  29 ++-
 python/t/250-opt-set-meta.py                 | 126 ++++++++++
 ocaml/tests/Makefile.am                      |   5 +-
 ocaml/tests/test_110_defaults.ml             |   2 +
 ocaml/tests/test_120_set_non_defaults.ml     |   3 +
 ocaml/tests/test_230_opt_info.ml             |  43 +++-
 ocaml/tests/test_240_opt_list_meta.ml        |  34 ++-
 ocaml/tests/test_250_opt_set_meta.ml         | 150 +++++++++++
 tests/Makefile.am                            |   9 +
 tests/opt-info.c                             |  91 ++++++-
 tests/opt-list-meta.c                        | 104 +++++++-
 tests/opt-set-meta                           | 210 ++++++++++++++++
 tests/opt-set-meta.c                         | 236 ++++++++++++++++++
 .gitignore                                   |   1 +
 golang/Makefile.am                           |   3 +-
 golang/libnbd_110_defaults_test.go           |   8 +
 golang/libnbd_120_set_non_defaults_test.go   |  12 +
 golang/libnbd_230_opt_info_test.go           | 111 ++++++++-
 golang/libnbd_240_opt_list_meta_test.go      | 106 ++++++--
 golang/libnbd_250_opt_set_meta_test.go       | 248 +++++++++++++++++++
 info/list.c                                  |   3 +-
 info/show.c                                  |   3 +-
 35 files changed, 1813 insertions(+), 154 deletions(-)
 create mode 100644 python/t/250-opt-set-meta.py
 create mode 100644 ocaml/tests/test_250_opt_set_meta.ml
 create mode 100755 tests/opt-set-meta
 create mode 100644 tests/opt-set-meta.c
 create mode 100644 golang/libnbd_250_opt_set_meta_test.go

--
2.37.2