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

Re: Standard NBD URL syntax (again)



On Mon, May 20, 2019 at 4:42 PM Eric Blake <eblake@redhat.com> wrote:
On 5/20/19 4:20 AM, Richard W.M. Jones wrote:
>
> Previous discussion:
> https://lists.debian.org/nbd/2018/07/msg00002.html
>
> Again I'm stuck because we need a URL syntax for NBD.
>
> Various URLs have been proposed before:
>
>   * Library      Hostname+port over TCP/IP
>                  Unix domain socket
>                Export name
>   - Link for further information
>   - Notes
>
>   * libguestfs   nbd://example.com:port      (:port is optional)
>                  nbd://?socket=/socket
>                nbd://example.com:port/exportname
>                  nbd:///exportname?socket=/socket
>   - http://libguestfs.org/guestfish.1.html#a-nbd:-example.com-:port
>   - Cannot specify an export name without a leading '/' character
>
>   * QEMU         nbd:example.com:port
>                  nbd:unix:/socket
>                nbd:example.com:port:exportname=/export
>   - https://qemu.weilnetz.de/doc/qemu-doc.html#Device-URL-Syntax
>   - Not a real URL!

Qemu also supports actual URLs:

nbd[+tcp]://example.com[:port]/[exportname]
nbd+unix:///[exportname]?socket=path

where the [...] blocks are optional (missing exportname requests the
default '' export, missing port defaults to 10809)

>
>   * Curl         nbd://example.com/
>                  nbd://example.com/exportname
>   - https://github.com/rwmjones/curl/commit/2aba3dd7d8f9b8e03a8c3435e7555ab9e195675a#diff-77ab3188c0ad08b7b9d8d9787c8e9d75
>   - Cannot specify an export name without a leading '/' character
>   - No Unix domain socket syntax was ever defined.
>   - Did not go upstream.
>
> The leading problem with the "obvious" NBD URL format seems to be that
> it's impossible to specify empty export names or export names which
> don't start with a '/' character.

The qemu format allows empty export names. 'nbd://hostname' and
'nbd://hostname/' are the same empty export, 'nbd://hostname//' is the
export named '/'.

>
> This is why I'd be inclined to use an extra URL parameter instead,
> like:
>
>   nbd://example.com[:port]/?export=exportname
>
> and for Unix domain sockets:
>
>   nbd:///?export=exportname&socket=/socket

The qemu solution was to use the 'nbd+unix://' protocol rather than the
bare 'nbd://' protocol to tell the difference between tcp and Unix
sockets, rather than trying to figure out from the rest of the URL which
context was implied.

The qemu solution is consistent , flexible and easy to use and does not require
any policy on the server (stripping leading /).

I think we should adapt it for the NBD spec.

I wonder why this syntax is not documented in:

>
> The export would be optional, defaulting to empty string.  IPv6
> addresses would work in the obvious way for URLs, using "[...]"
> around the address part (ie as in RFC 2732).  All escaping issues
> would work as for standard URLs.
>
> I think we should standardize this once and for all in a document in
> the NBD repository.
>
> Anyway let me know what you think and I will try to write something
> formal.
>
> Rich.
>

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


Reply to: