Rich posted v2 at:

https://listman.redhat.com/archives/libguestfs/2023-January/030555.html

This is my stab at the feature, with a number of changes (that I felt
were prerequisites) prepended. The series is structured as follows. Note
that almost every segment of the series strongly depends on prior
segment(s); in other words, the patches are in reasonably strict
dependency order.

- Patches #1 through #4 are generic, mostly mechanical, tree-wide
  cleanups, dealing with whitespace and reserved identifiers.

- Patch #5 extracts a vector usage pattern we use 11 times in the tree
  to a new vector API called "name##_empty".

- Patches #6 through #8 introduce an assert() variant that is
  async-signal-safe. This means we can make assertions in a child
  process before reaching one of the exec functions, even if the parent
  process was multi-threaded at the time of fork().

- Patches #9 and #10 introduce an execvpe() variant that is
  async-signal-safe.

- Patches #11 through #25 implement the same series of cleanups *twice*,
  once for CONNECT_SA.START ("socket activation"), and another time for
  CONNECT_COMMAND.START. The table below describes this sub-structure:

  change summary                                  CONNECT_SA  CONNECT_COMMAND
  ----------------------------------------------  ----------  ---------------
  minor thinkos and warts                         #11 - #13   #18 - #21
  check syscalls for errors in the child process  #14         #22
  centralize resource release                     #15         #23
  plug resource leak on error                     #16         #24
  replace execvp() call with fork-safe variant    #17         #25

- Patches #26 through #29 implement the LISTEN_FDNAMES passing. This
  sub-series includes two patches from Rich's v2 series (with proper
  attribution).

The series buils, and passes "make check" and "make check-valgrind", at
every stage.

In the Notes sections of some of the patches, there are lines of the
form "context:-U<number>" or "context:-W". I've always wanted to control
the number of context lines at the *individual* patch level -- for
reviewing some patches, the default 3 is just fine, but for reviewing
many other patches, significantly larger contexts are beneficial. I've
finally bitten the bullet and written a (rather awkward) script that
parses this "context:" note out of each patch (where "-W" is the short
form of "--function--context") and applies it to formatting. That's why
the context size varies over the series.

The larger context size may make it harder to apply the series from the
list if the master branch advances meanwhile. I don't expect this to
happen, but in any case, I've passed "--base=master" to
git-format-patch, so that the base commit (the current HEAD of the
master branch) be noted at the end of the cover letter. That way the
series can be applied precisely, and then rebased with a separate local
step (because git has more information that way).

Laszlo

Laszlo Ersek (27):
  use space consistently in function and function-like macro invocations
  generator/C.ml: use space consistently in func. and func.-like macro
    calls
  socket activation: rename sa_(tmpdir|sockpath) to
    sact_(tmpdir|sockpath)
  ocaml: rename "sa_u" to "saddr_u"
  vector: (mostly) factor out DEFINE_VECTOR_EMPTY
  lib/utils: introduce xwrite() as a more robust write()
  lib/utils: add async-signal-safe assert()
  lib/utils: add unit test for async-signal-safe assert()
  lib/utils: introduce async-signal-safe execvpe()
  lib/utils: add unit tests for async-signal-safe execvpe()
  socket activation: fix error message upon asprintf() failure
  socket activation: clean up responsibilities of prep.sock.act.env.()
  socket activation: avoid manipulating the sign bit
  socket activation: check syscalls for errors in the child process
  socket activation: centralize resource release
  socket activation: plug AF_UNIX socket address (filesystem) leak on
    error
  socket activation: replace execvp() call with fork-safe variant
  CONNECT_COMMAND.START: fix small comment thinko about socket pair
    usage
  CONNECT_COMMAND.START: set the NBD error when fcntl() fails
  CONNECT_COMMAND.START: use symbolic constants for fd#0 and fd#1
  CONNECT_COMMAND.START: sanitize close() calls in the child process
  CONNECT_COMMAND.START: check syscalls for errors in the child process
  CONNECT_COMMAND.START: centralize resource release
  CONNECT_COMMAND.START: plug child process leak on error
  CONNECT_COMMAND.START: replace execvp() call with fork-safe variant
  socket activation: generalize environment construction
  socket activation: set LISTEN_FDNAMES

Richard W.M. Jones (2):
  common/include: Copy ascii-ctype functions from nbdkit
  generator: Add APIs to get/set the socket activation socket name

 .gitignore                                   |   4 +
 common/include/Makefile.am                   |   6 +
 common/include/array-size.h                  |   2 +-
 common/include/ascii-ctype.h                 |  75 ++++
 common/include/byte-swapping.h               |  24 +-
 common/include/checked-overflow.h            |  42 +-
 common/include/compiler-macros.h             |   2 +-
 common/include/iszero.h                      |   2 +-
 common/include/minmax.h                      |   4 +-
 common/include/test-array-size.c             |  26 +-
 common/include/test-ascii-ctype.c            |  88 ++++
 common/utils/const-string-vector.h           |   2 +-
 common/utils/nbdkit-string.h                 |   2 +-
 common/utils/string-vector.h                 |   3 +-
 common/utils/test-human-size.c               |  10 +-
 common/utils/test-vector.c                   |   7 +-
 common/utils/vector.h                        |  45 +-
 configure.ac                                 |   5 +
 copy/file-ops.c                              |   2 +-
 copy/main.c                                  |   2 +-
 copy/nbdcopy.h                               |   2 +-
 dump/dump.c                                  |   2 +-
 examples/copy-libev.c                        |  30 +-
 examples/list-exports.c                      |   2 +-
 examples/strict-structured-reads.c           |   2 +-
 examples/threaded-reads-and-writes.c         |   2 +-
 fuse/nbdfuse.c                               |   2 +-
 generator/API.ml                             |  49 +++
 generator/C.ml                               |  20 +-
 generator/states-connect-socket-activation.c | 294 +++++++++----
 generator/states-connect.c                   | 123 ++++--
 info/main.c                                  |   2 +-
 info/show.c                                  |   3 +-
 interop/interop.c                            |   2 +-
 lib/Makefile.am                              |  48 ++-
 lib/errors.c                                 |   6 +-
 lib/handle.c                                 |  80 +++-
 lib/internal.h                               | 112 +++--
 lib/nbd-protocol.h                           |  12 +-
 lib/opt.c                                    |   4 +-
 lib/test-fork-safe-assert.c                  |  63 +++
 lib/test-fork-safe-assert.sh                 |  31 ++
 lib/test-fork-safe-execvpe.c                 | 117 ++++++
 lib/test-fork-safe-execvpe.sh                | 270 ++++++++++++
 lib/uri.c                                    |   2 +-
 lib/utils.c                                  | 430 +++++++++++++++++++-
 ocaml/helpers.c                              |   8 +-
 ocaml/nbd-c.h                                |   6 +-
 tests/eflags.c                               |   6 +-
 tests/get-size.c                             |   4 +-
 tests/newstyle-limited.c                     |   6 +-
 tests/oldstyle.c                             |   4 +-
 ublk/nbdublk.c                               |   4 +-
 ublk/tgt.c                                   |  20 +-
 54 files changed, 1771 insertions(+), 350 deletions(-)
 create mode 100644 common/include/ascii-ctype.h
 create mode 100644 common/include/test-ascii-ctype.c
 create mode 100644 lib/test-fork-safe-assert.c
 create mode 100755 lib/test-fork-safe-assert.sh
 create mode 100644 lib/test-fork-safe-execvpe.c
 create mode 100755 lib/test-fork-safe-execvpe.sh


base-commit: 5a02c7d2cc6a201f9e5531c0c20c2f3c22b805a2
_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to