filters: Stronger version match requirements
commitfe8ad62eaaeae5333dad0cc9ad16bbcdc4a066ce
authorEric Blake <eblake@redhat.com>
Tue, 27 Aug 2019 21:28:05 +0000 (27 16:28 -0500)
committerEric Blake <eblake@redhat.com>
Fri, 30 Aug 2019 16:13:40 +0000 (30 11:13 -0500)
tree3a4456dd64ef56c62af5d6c886128017d97f2973
parent0c75ccde19c0b2478412e2b7e63edbe65021f45b
filters: Stronger version match requirements

We documented our intent of only allowing a filter to run with the
same version of nbdkit it was compiled against, but up to now, were
not actually enforcing that - we had only been insisting on the looser
notion of a matching ._api_version, which doesn't help when we've
forgotten to bump that macro when making incompatible API/ABI changes
(see commit 6934d4c1).  However, we can't use .version (it was
documented as optional, so even though all our in-tree filters set it,
a theoretical out-of-tree filter could use NULL; and it has changed
offsets in the ABI during previous API changes, such as commit
ee61d232).  Thus, we have to bump the API version one final time; but
now, our API guarantees enough stable ABI to check the version string
as part of our API sanity checking, so we are set to avoid future
maintenance snafus.

Of course, actually tightening the version match requirement means
that cross-version binaries which DO happen to share an otherwise
compatible API/ABI (such as was the case for v1.6 and v.1.8) would no
longer play nicely together, but that is less of a worry.

All in-tree filters are affected now that .version is no longer
available as an optional member (although it so happens that we are
setting the new mandatory ._version to the same value that they all
used).  And thanks to the previous patch adding nbdkit-version.h, even
a theoretical out-of-tree filter will get the correct version string
without having to maintain it by hand.

Note that the offset of ._version differs between 32- and 64-bit
platform ABIs; but on that front, we are safe: Rich and I tested (at
least on Linux where ELF executables encode ABI) that attempts to load
a 32-bit .so from 64-bit nbdkit, or vice versa, gracefully fail
dlopen() for being an incompatible ABI even before we get far enough
to worry about inspecting ._api_version or ._version.

Signed-off-by: Eric Blake <eblake@redhat.com>
24 files changed:
docs/nbdkit-filter.pod
filters/blocksize/blocksize.c
filters/cache/cache.c
filters/cacheextents/cacheextents.c
filters/cow/cow.c
filters/delay/delay.c
filters/error/error.c
filters/fua/fua.c
filters/log/log.c
filters/nocache/nocache.c
filters/noextents/noextents.c
filters/noparallel/noparallel.c
filters/nozero/nozero.c
filters/offset/offset.c
filters/partition/partition.c
filters/rate/rate.c
filters/readahead/readahead.c
filters/stats/stats.c
filters/truncate/truncate.c
filters/xz/xz.c
include/nbdkit-filter.h
server/filters.c
tests/test-cxx-filter.cpp
tests/test-layers-filter.c