On 09/15/2015 01:37 AM, Markus Armbruster wrote: >>>>> +# @filename: #optional unix or inet path. The format is: >>>>> +# unix: nbd+unix:///export?socket=path or >>>>> +# nbd:unix:path:exportname=export >>>>> +# inet: nbd[+tcp]://host[:port]/export or >>>>> +# nbd:host[:port]:exportname=export >>> > Since there's an either/or, the complex QAPI type should be a union. > >>> { 'enum': 'NBDTransport', 'data': ['unix', 'tcp', 'udp'] } >> >> NBD only uses tcp, it doesn't support udp. Fair enough. >> >>> { 'union': 'BlockdevOptionsNBD', >>> 'base': { 'transport': 'NBDTransport', 'export': 'str' }, >>> 'discriminator': 'transport', >>> 'data': { 'unix': 'NBDUnix', 'tcp': 'NBDInet', 'udp': 'NBDInet' } } >>> { 'struct': 'NBDUnix', 'data': { 'socket': 'str' } } >> >> unix socket needs a path, and I think we can use UnixSocketAddress here. Sure, if that works, you could do 'unix':'UnixSocketAddress' instead of inventing 'NBDUnix'. > > Yes, we should try to reuse common types like SocketAddress, > InetSocketAddress, UnixSocketAddress. Well, we've already questioned whether 'InetSocketAddress' needs to be fixed to be separate from a socket range, but it can be a separate fix. > > Perhaps it could be as simple as > > { 'struct': 'BlockdevOptionsNBD', > 'data': { 'addr: 'SocketAddress', 'export': 'str' } } > > Eric, what do you think? It has more nesting on the wire, but should work. That is, to express "nbd+unix:///export?socket=path", the QMP would be: { "export":"export", "addr":{ "type":"unix", "data":{ "path": "str"}}} instead of a nicer: { "export":"export", "type":"unix", "path":"str" } but the advantage of working now rather than waiting on qapi fixes in the pipeline has its benefit. There's also the question of how to handle 'fd', if NBD can't reuse an existing fd but must be given a unix socket filename or tcp host/port destination. Documenting that we reject a combination may be okay, except that it is harder to introspect later if the combination is no longer rejected because we later add support. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org