Richard W.M. Jones
2020-Aug-27 12:29 UTC
[Libguestfs] [PATCH nbdkit 0/2] Temporarily remove .list_exports for nbdkit 1.22
If you're following nbdkit development upstream you'll have seen that we are still making changes to the .list_exports and related APIs. The current .list_exports API upstream is not how it will look finally. The latest set of proposals was here: https://www.redhat.com/archives/libguestfs/2020-August/thread.html#00330 At the same time I'd like to do an nbdkit 1.22 (stable) release. There are a few reasons for this, some good and some not so great: - We have sufficient new features and the schedule is right to do a release, but I don't want to push large changes in at the last minute. - The VDDK plugin has several vital fixes which will be appreciated by anyone using nbdkit to access VMware. - The Windows patches could be added _after_ we do the stable release so they have plenty of time to sit in development. At the moment I have to keep rebasing them. - (The not so good one) RHEL 8 demands that we either rebase nbdkit now, as in _today_, or else we will wait for many months before our customers can use the new features. Therefore I propose the two following patches. The first one removes the mention of list_exports and nbdkit*export* APIs from the 1.22 release notes. The second one is for stable-1.22 only (before 1.22.0 goes out). It removes the .list_exports feature from plugins. It also removes the nbdkit*export* APIs from <nbdkit-plugin.h> (ie. the public API). This doesn't affect development, it would only be for the 1.22 release. Rich.
Richard W.M. Jones
2020-Aug-27 12:29 UTC
[Libguestfs] [PATCH nbdkit 1/2] docs: Remove .list_exports from release notes for 1.22.
--- docs/nbdkit-release-notes-1.22.pod | 6 ------ 1 file changed, 6 deletions(-) diff --git a/docs/nbdkit-release-notes-1.22.pod b/docs/nbdkit-release-notes-1.22.pod index f84e0e12..20af7ea3 100644 --- a/docs/nbdkit-release-notes-1.22.pod +++ b/docs/nbdkit-release-notes-1.22.pod @@ -165,12 +165,6 @@ New API C<nbdkit_extents_aligned> is a helper function for filters that retrieves extents as needed until at least a certain range is covered (Eric Blake). -New C<.default_export> and C<.list_exports> callbacks, and new APIs -C<nbdkit_add_export>, C<nbdkit_exports_new>, C<nbdkit_exports_free>, -C<nbdkit_exports_count>, C<nbdkit_get_export> can be used by plugins -and filters to reply to clients which want to list the exports that -the server supports (Eric Blake). - New C<nbdkit_is_tls> can be called to determine if TLS was negotiated on the connection. Plugins could use this to hide certain exports from non-authenticated/non-encrypted clients (Eric Blake). -- 2.27.0
Richard W.M. Jones
2020-Aug-27 12:29 UTC
[Libguestfs] [PATCH nbdkit 2/2] api: Remove .list_exports from nbdkit 1.22 release.
During the 1.21 development cycle we added support for listing exports. However at the time that 1.22 was released we did not feel the API was sufficiently finalized to commit to in a stable branch. Therefore this new API was removed before 1.22 was released, but the feature continues to be developed upstream and should appear in nbdkit 1.24. Note this also hides the nbdkit*export* functions so they can only be used from filters (filters do not have a stable API). --- plugins/eval/nbdkit-eval-plugin.pod | 2 - plugins/sh/nbdkit-sh-plugin.pod | 52 ----------- include/nbdkit-common.h | 5 -- include/nbdkit-filter.h | 5 ++ include/nbdkit-plugin.h | 3 - tests/Makefile.am | 4 - server/plugins.c | 9 +- plugins/sh/methods.h | 2 - plugins/eval/eval.c | 2 - plugins/ondemand/ondemand.c | 51 ----------- plugins/sh/methods.c | 106 ---------------------- plugins/sh/sh.c | 1 - plugins/sh/example.sh | 8 -- tests/test-eval-exports.sh | 135 ---------------------------- tests/test-ondemand-list.sh | 67 -------------- tests/test-layers-plugin.c | 9 -- tests/test-layers.c | 15 ---- 17 files changed, 6 insertions(+), 470 deletions(-) diff --git a/plugins/eval/nbdkit-eval-plugin.pod b/plugins/eval/nbdkit-eval-plugin.pod index 7126c6de..7e25a01f 100644 --- a/plugins/eval/nbdkit-eval-plugin.pod +++ b/plugins/eval/nbdkit-eval-plugin.pod @@ -108,8 +108,6 @@ features): =item B<is_rotational=>SCRIPT -=item B<list_exports=>SCRIPT - =item B<open=>SCRIPT =item B<pread=>SCRIPT diff --git a/plugins/sh/nbdkit-sh-plugin.pod b/plugins/sh/nbdkit-sh-plugin.pod index 07d90b57..2d802217 100644 --- a/plugins/sh/nbdkit-sh-plugin.pod +++ b/plugins/sh/nbdkit-sh-plugin.pod @@ -266,58 +266,6 @@ with status C<1>; unrecognized output is ignored. /path/to/script preconnect <readonly> <exportname> -=item C<list_exports> - - /path/to/script list_exports <readonly> <default_only> - -The C<readonly> parameter will be C<true> or C<false>. The -C<default_only> parameter will be C<true> if the caller is only -interested in the canonical name of the default export, or C<false> to -get a full list of export names; the script may safely ignore this -parameter and always provide a full list if desired. - -The first line of output informs nbdkit how to parse the rest of the -output, the remaining lines then supply the inputs of the C -C<nbdkit_add_export> function (see L<nbdkit-plugin(3)>), as follows: - -=over 4 - -=item NAMES - -The remaining output provides one export name per line, and no export -will be given a description. For convenience, this form is also -assumed if the first output line does not match one of the recognized -parse modes. - -=item INTERLEAVED - -The remaining output provides pairs of lines, the first line being an -export name, and the second the corresponding description. - -=item NAMES+DESCRIPTIONS - -The number of remaining lines is counted, with the first half being -used as export names, and the second half providing descriptions to -pair with names from the first half. - -An example of using this form to list files in the current directory, -followed by their L<ls(1)> long description, would be: - - echo NAMES+DESCRIPTIONS - ls - ls -l - -=back - -Note that other output modes might be introduced in the future; in -particular, none of the existing modes allow a literal newline in an -export name or description, although this could be possible under a -new mode supporting escape sequences. - -This method is I<not> required; if it is absent, the list of exports -advertised by nbdkit will be the single export with the empty string -as a name and no description. - =item C<open> /path/to/script open <readonly> <exportname> <tls> diff --git a/include/nbdkit-common.h b/include/nbdkit-common.h index c377e18d..6f580387 100644 --- a/include/nbdkit-common.h +++ b/include/nbdkit-common.h @@ -126,11 +126,6 @@ NBDKIT_EXTERN_DECL (int, nbdkit_add_extent, (struct nbdkit_extents *, uint64_t offset, uint64_t length, uint32_t type)); -struct nbdkit_exports; -NBDKIT_EXTERN_DECL (int, nbdkit_add_export, - (struct nbdkit_exports *, - const char *name, const char *description)); - /* A static non-NULL pointer which can be used when you don't need a * per-connection handle. */ diff --git a/include/nbdkit-filter.h b/include/nbdkit-filter.h index b4024ae5..f059606b 100644 --- a/include/nbdkit-filter.h +++ b/include/nbdkit-filter.h @@ -65,6 +65,7 @@ typedef int nbdkit_next_config_complete (nbdkit_backend *nxdata); typedef int nbdkit_next_get_ready (nbdkit_backend *nxdata); typedef int nbdkit_next_after_fork (nbdkit_backend *nxdata); typedef int nbdkit_next_preconnect (nbdkit_backend *nxdata, int readonly); +struct nbdkit_exports; typedef int nbdkit_next_list_exports (nbdkit_backend *nxdata, int readonly, int default_only, struct nbdkit_exports *exports); @@ -130,6 +131,10 @@ NBDKIT_EXTERN_DECL (int, nbdkit_extents_aligned, struct nbdkit_extents *extents, int *err)); /* Export functions. */ +NBDKIT_EXTERN_DECL (int, nbdkit_add_export, + (struct nbdkit_exports *, + const char *name, const char *description)); + struct nbdkit_export { char *name; char *description; diff --git a/include/nbdkit-plugin.h b/include/nbdkit-plugin.h index a5d85411..be383b85 100644 --- a/include/nbdkit-plugin.h +++ b/include/nbdkit-plugin.h @@ -139,9 +139,6 @@ struct nbdkit_plugin { int (*get_ready) (void); int (*after_fork) (void); - - int (*list_exports) (int readonly, int default_only, - struct nbdkit_exports *exports); }; NBDKIT_EXTERN_DECL (void, nbdkit_set_error, (int err)); diff --git a/tests/Makefile.am b/tests/Makefile.am index 2db56ded..f3e4e3de 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -616,12 +616,10 @@ test_data_LDADD = libtest.la $(LIBGUESTFS_LIBS) TESTS += \ test-eval.sh \ test-eval-file.sh \ - test-eval-exports.sh \ $(NULL) EXTRA_DIST += \ test-eval.sh \ test-eval-file.sh \ - test-eval-exports.sh \ $(NULL) # file plugin test. @@ -756,12 +754,10 @@ test_null_LDADD = $(LIBNBD_LIBS) # ondemand plugin test. TESTS += \ test-ondemand.sh \ - test-ondemand-list.sh \ test-ondemand-locking.sh \ $(NULL) EXTRA_DIST += \ test-ondemand.sh \ - test-ondemand-list.sh \ test-ondemand-locking.sh \ $(NULL) diff --git a/server/plugins.c b/server/plugins.c index 4e320868..033dfc6c 100644 --- a/server/plugins.c +++ b/server/plugins.c @@ -162,7 +162,6 @@ plugin_dump_fields (struct backend *b) HAS (get_ready); HAS (after_fork); HAS (preconnect); - HAS (list_exports); HAS (open); HAS (close); @@ -285,13 +284,7 @@ static int plugin_list_exports (struct backend *b, int readonly, int default_only, struct nbdkit_exports *exports) { - GET_CONN; - struct backend_plugin *p = container_of (b, struct backend_plugin, backend); - - if (!p->plugin.list_exports) - return nbdkit_add_export (exports, "", NULL); - - return p->plugin.list_exports (readonly, default_only, exports); + return nbdkit_add_export (exports, "", NULL); } static void * diff --git a/plugins/sh/methods.h b/plugins/sh/methods.h index 69017fa4..877c7a73 100644 --- a/plugins/sh/methods.h +++ b/plugins/sh/methods.h @@ -44,8 +44,6 @@ extern int sh_thread_model (void); extern int sh_get_ready (void); extern int sh_after_fork (void); extern int sh_preconnect (int readonly); -extern int sh_list_exports (int readonly, int default_only, - struct nbdkit_exports *exports); extern void *sh_open (int readonly); extern void sh_close (void *handle); extern int64_t sh_get_size (void *handle); diff --git a/plugins/eval/eval.c b/plugins/eval/eval.c index 2bd5e79f..54c5029e 100644 --- a/plugins/eval/eval.c +++ b/plugins/eval/eval.c @@ -74,7 +74,6 @@ static const char *known_methods[] = { "get_ready", "get_size", "is_rotational", - "list_exports", "missing", "open", "pread", @@ -394,7 +393,6 @@ static struct nbdkit_plugin plugin = { .after_fork = sh_after_fork, .preconnect = sh_preconnect, - .list_exports = sh_list_exports, .open = sh_open, .close = sh_close, diff --git a/plugins/ondemand/ondemand.c b/plugins/ondemand/ondemand.c index f2fcb68e..a09003d5 100644 --- a/plugins/ondemand/ondemand.c +++ b/plugins/ondemand/ondemand.c @@ -174,55 +174,6 @@ ondemand_get_ready (void) "type=ext4|... The filesystem type.\n" \ "command=<COMMAND> Alternate command instead of mkfs." -/* Because we rewind the exportsdir handle, we need a lock to protect - * list_exports from being called in parallel. - */ -static pthread_mutex_t exports_lock = PTHREAD_MUTEX_INITIALIZER; - -static int -ondemand_list_exports (int readonly, int default_only, - struct nbdkit_exports *exports) -{ - ACQUIRE_LOCK_FOR_CURRENT_SCOPE (&exports_lock); - struct dirent *d; - - /* First entry should be the default export. XXX Should we check if - * the "default" file was created? I don't think we need to. - */ - if (nbdkit_add_export (exports, "", NULL) == -1) - return -1; - if (default_only) return 0; - - /* Read the rest of the exports. */ - rewinddir (exportsdir); - - /* XXX Output is not sorted. Does it matter? */ - while (errno = 0, (d = readdir (exportsdir)) != NULL) { - /* Skip any file containing non-permitted characters '.' and ':'. - * As a side effect this skips all dot-files. Commands can use - * dot-files to "hide" files in the export dir (eg. if needing to - * keep state). - */ - if (strchr (d->d_name, '.') || strchr (d->d_name, ':')) - continue; - - /* Skip the "default" filename which refers to the "" export. */ - if (strcmp (d->d_name, "default") == 0) - continue; - - if (nbdkit_add_export (exports, d->d_name, NULL) == -1) - return -1; - } - - /* Did readdir fail? */ - if (errno != 0) { - nbdkit_error ("readdir: %s: %m", dir); - return -1; - } - - return 0; -} - struct handle { int fd; int64_t size; @@ -624,8 +575,6 @@ static struct nbdkit_plugin plugin = { .magic_config_key = "size", .get_ready = ondemand_get_ready, - .list_exports = ondemand_list_exports, - .can_multi_conn = ondemand_can_multi_conn, .can_trim = ondemand_can_trim, .can_fua = ondemand_can_fua, diff --git a/plugins/sh/methods.c b/plugins/sh/methods.c index 8e2e4256..bd045b0c 100644 --- a/plugins/sh/methods.c +++ b/plugins/sh/methods.c @@ -225,112 +225,6 @@ struct sh_handle { int can_zero; }; -/* If @s begins with @prefix, return the next offset, else NULL */ -static const char * -skip_prefix (const char *s, const char *prefix) -{ - size_t len = strlen (prefix); - if (strncmp (s, prefix, len) == 0) - return s + len; - return NULL; -} - -static int -parse_exports (const char *script, - const char *s, size_t slen, struct nbdkit_exports *exports) -{ - const char *n, *d, *p, *q; - - /* The first line determines how to parse the rest of s */ - if ((p = skip_prefix (s, "INTERLEAVED\n")) != NULL) { - n = p; - while ((d = strchr (n, '\n')) != NULL) { - p = strchr (d + 1, '\n') ?: d + 1; - CLEANUP_FREE char *name = strndup (n, d - n); - CLEANUP_FREE char *desc = strndup (d + 1, p - d - 1); - if (!name || !desc) { - nbdkit_error ("%s: strndup: %m", script); - return -1; - } - if (nbdkit_add_export (exports, name, desc) == -1) - return -1; - n = p + !!*p; - } - } - else if ((p = skip_prefix (s, "NAMES+DESCRIPTIONS\n")) != NULL) { - n = d = p; - /* Searching from both ends, using memrchr, would be less work, but - * memrchr is not widely portable. Multiple passes isn't too bad. - */ - while (p && (p = strchr (p, '\n')) != NULL) { - p = strchr (p + 1, '\n'); - if (p) - p++; - d = strchr (d, '\n') + 1; - } - s = d; - while (n < s) { - p = strchr (n, '\n'); - q = strchr (d, '\n') ?: d; - CLEANUP_FREE char *name = strndup (n, p - n); - CLEANUP_FREE char *desc = strndup (d, q - d); - if (!name || !desc) { - nbdkit_error ("%s: strndup: %m", script); - return -1; - } - if (nbdkit_add_export (exports, name, desc) == -1) - return -1; - n = p + 1; - d = q + 1; - } - } - else { - n = skip_prefix (s, "NAMES\n") ?: s; - while ((p = strchr (n, '\n')) != NULL) { - CLEANUP_FREE char *name = strndup (n, p - n); - if (!name) { - nbdkit_error ("%s: strndup: %m", script); - return -1; - } - if (nbdkit_add_export (exports, name, NULL) == -1) - return -1; - n = p + 1; - } - } - return 0; -} - -int -sh_list_exports (int readonly, int default_only, - struct nbdkit_exports *exports) -{ - const char *method = "list_exports"; - const char *script = get_script (method); - const char *args[] = { script, method, readonly ? "true" : "false", - default_only ? "true" : "false", NULL }; - CLEANUP_FREE char *s = NULL; - size_t slen; - - switch (call_read (&s, &slen, args)) { - case OK: - return parse_exports (script, s, slen, exports); - - case MISSING: - return nbdkit_add_export (exports, "", NULL); - - case ERROR: - return -1; - - case RET_FALSE: - nbdkit_error ("%s: %s method returned unexpected code (3/false)", - script, method); - errno = EIO; - return -1; - - default: abort (); - } -} - void * sh_open (int readonly) { diff --git a/plugins/sh/sh.c b/plugins/sh/sh.c index 374888a4..9e484823 100644 --- a/plugins/sh/sh.c +++ b/plugins/sh/sh.c @@ -300,7 +300,6 @@ static struct nbdkit_plugin plugin = { .after_fork = sh_after_fork, .preconnect = sh_preconnect, - .list_exports = sh_list_exports, .open = sh_open, .close = sh_close, diff --git a/plugins/sh/example.sh b/plugins/sh/example.sh index 4f547db0..99e4e890 100755 --- a/plugins/sh/example.sh +++ b/plugins/sh/example.sh @@ -85,14 +85,6 @@ case "$1" in echo parallel ;; - list_exports) - # The following lists the names of all files in the current - # directory that do not contain whitespace, backslash, or single - # quotes. No description accompanies the export names. - # The first file listed is used when a client requests export ''. - find . -type f \! -name "*['\\\\[:space:]]*" - ;; - open) # Open a new client connection. diff --git a/tests/test-eval-exports.sh b/tests/test-eval-exports.sh deleted file mode 100755 index aa694aaa..00000000 --- a/tests/test-eval-exports.sh +++ /dev/null @@ -1,135 +0,0 @@ -#!/usr/bin/env bash -# nbdkit -# Copyright (C) 2018-2020 Red Hat Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Red Hat nor the names of its contributors may be -# used to endorse or promote products derived from this software without -# specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. - -# This is an example from the nbdkit-eval-plugin(1) manual page. -# Check here that it doesn't regress. - -source ./functions.sh -set -e -set -x - -# requires nbdinfo --version # nbdinfo 1.3.9 was broken, so check this instead: -requires nbdkit -U - memory 1 --run 'nbdinfo --size --json "$uri"' -requires jq --version - -sock=$(mktemp -u) -files="eval-exports.list eval-exports.out eval-exports.pid $sock" -rm -f $files -cleanup_fn rm -f $files -fail=0 - -# Control case: no .list_exports, which defaults to advertising "" -rm -f eval-exports.list -nbdkit -U - -v eval \ - open='[ "$3" = "" ] || { echo EINVAL wrong export >&2; exit 1; }' \ - get_size='echo 0' --run 'nbdinfo --list --json "$uri"' > eval-exports.out -cat eval-exports.out -diff -u <(jq -c \ - '[.exports[] | [."export-name", .description, ."export-size"]]' \ - eval-exports.out) <(printf %s\\n '[["",null,0]]') - -# Start a long-running server with .list_exports set to varying contents -start_nbdkit -P eval-exports.pid -U $sock eval get_size='echo "$2"|wc -c' \ - open='echo "$3"' list_exports="cat '$PWD/eval-exports.list'" - -# do_nbdkit EXPNAME EXPOUT -do_nbdkit () -{ - # Check how the default export name is handled - # nbdinfo currently makes multiple connections, so we can't use the - # long-running server for validating default export name. - nbdkit -U - -v eval list_exports="cat '$PWD/eval-exports.list'" \ - open='[ "$3" = "'"$1"'" ] || { echo EINVAL wrong export >&2; exit 1; }' \ - get_size='echo 0' --run 'nbdsh -u "$uri" -c "exit()"' - # Check what exports are listed - nbdinfo --list --json nbd+unix://\?socket=$sock >eval-exports.out - cat eval-exports.out - diff -u <(jq -c \ - '[.exports[] | [."export-name", .description, ."export-size"]]' \ - eval-exports.out) <(printf %s\\n "$2") -} - -# With no file, .list_exports fails, but connecting works -nbdinfo --list --json nbd+unix://\?socket=$sock && fail=1 -nbdsh -u nbd+unix://\?socket=$sock -c 'quit()' - -# Various spellings of empty lists, producing 0 exports -for fmt in '' 'NAMES\n' 'INTERLEAVED\n' 'NAMES+DESCRIPTIONS\n'; do - printf "$fmt" >eval-exports.list - do_nbdkit '' '[]' -done - -# Various spellings of explicit list for the default export, no description -for fmt in '\n' 'NAMES\n\n' 'INTERLEAVED\n\n' 'INTERLEAVED\n\n\n' \ - 'NAMES+DESCRIPTIONS\n\n' 'NAMES+DESCRIPTIONS\n\n\n'; do - printf "$fmt" >eval-exports.list - do_nbdkit '' '[["",null,1]]' -done - -# A non-default name -for fmt in 'name\n' 'NAMES\nname\n'; do - printf "$fmt" >eval-exports.list - do_nbdkit name '[["name",null,5]]' -done - -# One export with a description -for fmt in 'INTERLEAVED\nname\ndesc\n' 'NAMES+DESCRIPTIONS\nname\ndesc\n'; do - printf "$fmt" >eval-exports.list - do_nbdkit name '[["name","desc",5]]' -done - -# Multiple exports, with correct number of lines -for fmt in 'INTERLEAVED\nname 1\ndesc 1\nname two\ndesc 2\n' \ - 'NAMES+DESCRIPTIONS\nname 1\nname two\ndesc 1\ndesc 2\n'; do - printf "$fmt" >eval-exports.list - do_nbdkit 'name 1' '[["name 1","desc 1",7],["name two","desc 2",9]]' -done - -# Multiple exports, with final description line missing -for fmt in 'INTERLEAVED\nname 1\ndesc 1\nname two\n' \ - 'NAMES+DESCRIPTIONS\nname 1\nname two\ndesc 1\n'; do - printf "$fmt" >eval-exports.list - do_nbdkit 'name 1' '[["name 1","desc 1",7],["name two",null,9]]' -done - -# Largest possible name and description -long=$(printf %04096d 1) -echo NAMES+DESCRIPTIONS >eval-exports.list -echo $long >>eval-exports.list -echo $long >>eval-exports.list -do_nbdkit $long "[[\"$long\",\"$long\",4097]]" - -# Invalid name (too long) causes an error response to NBD_OPT_LIST -nbdkit -U - -v eval list_exports="echo 2$long" \ - get_size='echo 0' --run 'nbdinfo --list --json "$uri"' && fail=1 - -exit $fail diff --git a/tests/test-ondemand-list.sh b/tests/test-ondemand-list.sh deleted file mode 100755 index e4b2a74c..00000000 --- a/tests/test-ondemand-list.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env bash -# nbdkit -# Copyright (C) 2020 Red Hat Inc. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# * Neither the name of Red Hat nor the names of its contributors may be -# used to endorse or promote products derived from this software without -# specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR -# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF -# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. - -source ./functions.sh -set -e -set -x - -requires_plugin ondemand -requires qemu-nbd --version - -dir=`mktemp -d` -cleanup_fn rm -rf $dir - -out=test-ondemand-list.out -rm -f $out -cleanup_fn rm -f $out - -# Put some files into the exports directory to pretend that we're -# restarting nbdkit after a previous run. -touch $dir/default -touch $dir/export1 -touch $dir/export2 -touch $dir/export3 - -export LANG=C -nbdkit -U - ondemand dir=$dir size=1M \ - --run 'qemu-nbd -k $unixsocket -L' > $out -cat $out - -# We should have 4 exports, since "default" file is the same as the -# default export. -grep "exports available: 4" $out - -# Check the 4 exports are present. -grep "export: ''" $out -grep "export: 'export1'" $out -grep "export: 'export2'" $out -grep "export: 'export3'" $out diff --git a/tests/test-layers-plugin.c b/tests/test-layers-plugin.c index 1dfd069e..ccb67fe4 100644 --- a/tests/test-layers-plugin.c +++ b/tests/test-layers-plugin.c @@ -93,14 +93,6 @@ test_layers_plugin_preconnect (int readonly) return 0; } -static int -test_layers_plugin_list_exports (int readonly, int default_only, - struct nbdkit_exports *exports) -{ - DEBUG_FUNCTION; - return nbdkit_add_export (exports, "", NULL); -} - static void * test_layers_plugin_open (int readonly) { @@ -256,7 +248,6 @@ static struct nbdkit_plugin plugin = { .get_ready = test_layers_plugin_get_ready, .after_fork = test_layers_plugin_after_fork, .preconnect = test_layers_plugin_preconnect, - .list_exports = test_layers_plugin_list_exports, .open = test_layers_plugin_open, .close = test_layers_plugin_close, .get_size = test_layers_plugin_get_size, diff --git a/tests/test-layers.c b/tests/test-layers.c index dd826f36..9a0279f1 100644 --- a/tests/test-layers.c +++ b/tests/test-layers.c @@ -326,21 +326,6 @@ main (int argc, char *argv[]) "test_layers_plugin_preconnect", NULL); - /* list_exports methods called in outer-to-inner order, complete - * in inner-to-outer order. But since we didn't send NBD_OPT_LIST, - * the outer filter does not expose a list; rather, the rest of the - * chain is used to resolve the canonical name of the default export. - */ - log_verify_seen_in_order - ("filter3: test_layers_filter_list_exports", - "testlayersfilter2: list_exports", - "filter2: test_layers_filter_list_exports", - "testlayersfilter1: list_exports", - "filter1: test_layers_filter_list_exports", - "testlayersplugin: list_exports", - "test_layers_plugin_list_exports", - NULL); - /* open methods called in outer-to-inner order, but thanks to next * pointer, complete in inner-to-outer order. */ log_verify_seen_in_order -- 2.27.0
Eric Blake
2020-Aug-27 13:01 UTC
Re: [Libguestfs] [PATCH nbdkit 2/2] api: Remove .list_exports from nbdkit 1.22 release.
On 8/27/20 7:29 AM, Richard W.M. Jones wrote:> During the 1.21 development cycle we added support for listing > exports. However at the time that 1.22 was released we did not feel > the API was sufficiently finalized to commit to in a stable branch. > Therefore this new API was removed before 1.22 was released, but the > feature continues to be developed upstream and should appear in > nbdkit 1.24. > > Note this also hides the nbdkit*export* functions so they can only be > used from filters (filters do not have a stable API). > --- > plugins/eval/nbdkit-eval-plugin.pod | 2 - > plugins/sh/nbdkit-sh-plugin.pod | 52 ----------- > include/nbdkit-common.h | 5 -- > include/nbdkit-filter.h | 5 ++ > include/nbdkit-plugin.h | 3 - > tests/Makefile.am | 4 - > server/plugins.c | 9 +- > plugins/sh/methods.h | 2 - > plugins/eval/eval.c | 2 - > plugins/ondemand/ondemand.c | 51 ----------- > plugins/sh/methods.c | 106 ---------------------- > plugins/sh/sh.c | 1 - > plugins/sh/example.sh | 8 -- > tests/test-eval-exports.sh | 135 ---------------------------- > tests/test-ondemand-list.sh | 67 -------------- > tests/test-layers-plugin.c | 9 -- > tests/test-layers.c | 15 ---- > 17 files changed, 6 insertions(+), 470 deletions(-)Do we also want to fix the wording in docs/nbdkit-protocol.pod (to not mention 1.22 as the release where .list_exports was supported) and docs/nbdkit-plugin.pod (to not document the callback)? The former could be squashed into patch 1/2, the latter is specific to the 1.22 stable branch. Otherwise ACK. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Eric Blake
2020-Aug-27 13:18 UTC
Re: [Libguestfs] [PATCH nbdkit 1/2] docs: Remove .list_exports from release notes for 1.22.
On 8/27/20 7:29 AM, Richard W.M. Jones wrote:> --- > docs/nbdkit-release-notes-1.22.pod | 6 ------ > 1 file changed, 6 deletions(-) > > diff --git a/docs/nbdkit-release-notes-1.22.pod b/docs/nbdkit-release-notes-1.22.pod > index f84e0e12..20af7ea3 100644 > --- a/docs/nbdkit-release-notes-1.22.pod > +++ b/docs/nbdkit-release-notes-1.22.pod > @@ -165,12 +165,6 @@ New API C<nbdkit_extents_aligned> is a helper function for filters > that retrieves extents as needed until at least a certain range is > covered (Eric Blake). > > -New C<.default_export> and C<.list_exports> callbacks, and new APIs > -C<nbdkit_add_export>, C<nbdkit_exports_new>, C<nbdkit_exports_free>, > -C<nbdkit_exports_count>, C<nbdkit_get_export> can be used by plugins > -and filters to reply to clients which want to list the exports that > -the server supports (Eric Blake). > - > New C<nbdkit_is_tls> can be called to determine if TLS was negotiated > on the connection. Plugins could use this to hide certain exports > from non-authenticated/non-encrypted clients (Eric Blake).Missing removal of: L<nbdkit-sh-plugin(1)> and L<nbdkit-eval-plugin(1)> now support listing server exports (Eric Blake). -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org