[Libguestfs] [PATCH libnbd v2 4/5] lib: New API nbd_get_uri to get an NBD URI for a connection.

Eric Blake eblake at redhat.com
Thu Apr 8 20:35:11 UTC 2021


On 4/8/21 5:36 AM, Richard W.M. Jones wrote:
> This will make a best-effort attempt to construct an NBD URI for
> connecting back to the current server.  In many cases this is not
> really possible (eg. if we were connected with nbd_connect_socket),
> and it's not guaranteed to be correct.
> ---

> +
> +  "get_uri", {
> +    default_call with
> +    args = []; ret = RString;
> +    permitted_states = [ Connecting; Negotiating; Connected; Closed; Dead ];
> +    shortdesc = "construct an NBD URI for a connection";
> +    longdesc = "\
> +This makes a best effort attempt to construct an NBD URI which
> +could be used to connect to this NBD server (eg. using
> +L<nbd_connect_uri(3)>).

s/this/the same/
After all, 'this' software is a client, not a server; we are giving the
user a string that might get them connected to the same server that this
client is already using.

> +
> +The URI returned is not guaranteed to work, and in some cases
> +(eg. if connected with L<nbd_connect_socket(3)>) it is not possible
> +at all.  Even if a URI is returned it may not be optimal.

Including cases where the server does not accept multiple connections.

> +
> +On error, L<nbd_get_errno(3)> will be set to C<ENOTSUP> if the
> +library was compiled without support for URIs.  In other error
> +cases, L<nbd_get_errno(3)> and L<nbd_get_error(3)> should contain
> +information about why constructing a URI was not possible.";
> +    see_also = [Link "connect_uri"; Link "aio_connect_uri";
> +                Link "supports_uri"];
>    };
>  ]

I like it.


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




More information about the Libguestfs mailing list