As long as we can only connect to one export name of the server, we don't need .list_exports, and our default export name was hard-coded on the command line. With new libnbd 1.4 functionality, we can also report any description that the server handed us.
(Of course, limiting ourselves to one export name is boring, so the next patch will take further advantage of libnbd 1.4 to lift that restriction.) Signed-off-by: Eric Blake <[email protected]> --- plugins/nbd/nbd.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/plugins/nbd/nbd.c b/plugins/nbd/nbd.c index 34194950..e8ce4124 100644 --- a/plugins/nbd/nbd.c +++ b/plugins/nbd/nbd.c @@ -558,6 +558,10 @@ nbdplug_open_handle (int readonly) goto errnbd; if (nbd_add_meta_context (h->nbd, LIBNBD_CONTEXT_BASE_ALLOCATION) == -1) goto errnbd; +#if LIBNBD_HAVE_NBD_SET_FULL_INFO + if (nbd_set_full_info (h->nbd, 1) == -1) + goto errnbd; +#endif if (nbd_set_tls (h->nbd, tls) == -1) goto errnbd; if (tls_certificates && @@ -619,6 +623,13 @@ nbdplug_open_handle (int readonly) return NULL; } +/* Canonical name of default export. */ +static const char * +nbdplug_default_export (int readonly, int is_tls) +{ + return export; +} + /* Create the per-connection handle. */ static void * nbdplug_open (int readonly) @@ -652,6 +663,19 @@ nbdplug_close (void *handle) nbdplug_close_handle (h); } +/* Description. */ +static const char * +nbdplug_export_description (void *handle) +{ +#if LIBNBD_HAVE_NBD_GET_EXPORT_DESCRIPTION + struct handle *h = handle; + CLEANUP_FREE char *desc = nbd_get_export_description (h->nbd); + if (desc) + return nbdkit_strdup_intern (desc); +#endif + return NULL; +} + /* Get the file size. */ static int64_t nbdplug_get_size (void *handle) @@ -947,8 +971,10 @@ static struct nbdkit_plugin plugin = { .magic_config_key = "uri", .after_fork = nbdplug_after_fork, .dump_plugin = nbdplug_dump_plugin, + .default_export = nbdplug_default_export, .open = nbdplug_open, .close = nbdplug_close, + .export_description = nbdplug_export_description, .get_size = nbdplug_get_size, .can_write = nbdplug_can_write, .can_flush = nbdplug_can_flush, -- 2.28.0 _______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
