[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [libnbd PATCH v2 2/2] info: List available meta-contexts



On 10/2/20 8:20 AM, Eric Blake wrote:
> Use the just-added nbd_opt_list_meta_context() API to give more
> details about each export (matching what 'qemu-nbd --list' already
> does).  Note that this requires some shuffling: listing meta exports
> requires being in opt mode, but is easiest to do in list_one_export(),
> which requires setting opt_mode in more code paths, and deferring
> ready mode until the last possible minute during get_content().
> 
> As written, the code displays the list in reverse order from how the
> server presented it, thanks to my use of a simple linked list.  We
> could use a different data type if we don't like the data being
> reversed, although the information being presented really is a set
> with no inherent meaning to its presentation order.
> ---

> @@ -368,8 +396,15 @@ list_one_export (struct nbd_handle *nbd, const char *desc,
>    int can_cache, can_df, can_fast_zero, can_flush, can_fua,
>      can_multi_conn, can_trim, can_zero;
>    int64_t block_minimum, block_preferred, block_maximum;
> +  struct context_list *contexts = NULL;
> +  bool show_context = false;
> 
>    /* Collect the metadata we are going to display. */
> +  if (nbd_aio_is_negotiating (nbd) &&
> +      nbd_opt_info (nbd) == -1) {
> +    fprintf (stderr, "%s\n", nbd_get_error ());
> +    exit (EXIT_FAILURE);
> +  }

For the record: this failed on a server with legacy "newstyle" protocol
(nbdkit --mask-handshake=0) - such a server lacks nbd_opt_info support,
and you HAVE to use nbd_opt_go to get size and other details.  But when
I fixed this line, it in turn flushed out an assertion failure present
since 1.4 (now fixed) where nbd_opt_go() on a legacy newstyle accessed
uninitialized memory, and nbd_aio_opt_go() could leak resources, because
of a forgotten completion callback invocation.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]