[Libguestfs] [libnbd PATCH 0/3] Simplify nbd_shutdown vs. opt mode

Eric Blake
2023-08-29T22:20:40Z

While working on a larger set of patches to make nbdinfo favor
NBD_OPT_INFO over NBD_OPT_GO where possible (which requires use of
nbd_set_opt_mode(,true) in more cases), I noticed that it got unwieldy
to have to pick the correct shutdown function in all code paths.  So I
propose making the API smarter, by adding an opt-in flag that does the
right thing on my behalf.

If you have an idea for a better name for the flag, or think this
functionality should be enabled by default, let me know.  Part of the
reason for choosing a new flag is that it becomes a compile-time
witness of whether nbd_shutdown has the desired capability (if we
allow it to auto-opt_abort without a flag, it's harder to tell whether
we are running against an older libnbd where it errors out instead).

Eric Blake (3):
  tests: Test behavior of nbd_shutdown during opt mode
  api: Add new COVER_OPT_MODE flag to nbd_shutdown
  info: Simplify shutdown calls

 generator/API.ml          |  21 ++++--
 lib/disconnect.c          |  15 ++++
 tests/Makefile.am         |   5 ++
 tests/shutdown-opt-mode.c | 149 ++++++++++++++++++++++++++++++++++++++
 .gitignore                |   1 +
 info/list.c               |   8 +-
 info/main.c               |   4 +-
 7 files changed, 188 insertions(+), 15 deletions(-)
 create mode 100644 tests/shutdown-opt-mode.c

--
2.41.0