From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZbUji-0005x1-6T for qemu-devel@nongnu.org; Mon, 14 Sep 2015 10:28:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZbUjh-0002Qj-6h for qemu-devel@nongnu.org; Mon, 14 Sep 2015 10:28:02 -0400 From: Markus Armbruster References: <1441878905-5272-1-git-send-email-wency@cn.fujitsu.com> <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> Date: Mon, 14 Sep 2015 16:27:50 +0200 In-Reply-To: <1441878905-5272-2-git-send-email-wency@cn.fujitsu.com> (Wen Congyang's message of "Thu, 10 Sep 2015 17:55:01 +0800") Message-ID: <87r3m1krdl.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH v3 1/5] support nbd driver in blockdev-add List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wen Congyang Cc: Kevin Wolf , Alberto Garcia , zhanghailiang , qemu block , Jiang Yunhong , Dong Eddie , qemu devel , "Dr. David Alan Gilbert" , Gonglei , Stefan Hajnoczi , Yang Hongyang Wen Congyang writes: > The NBD driver needs: filename, path or (host, port, exportname). > It checks which key exists and decides use unix or inet socket. > It doesn't recognize the key type, so we can't use union, and > can't reuse InetSocketAddress. > > Signed-off-by: Wen Congyang > Signed-off-by: zhanghailiang > Signed-off-by: Gonglei > --- > qapi/block-core.json | 42 ++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 40 insertions(+), 2 deletions(-) > > diff --git a/qapi/block-core.json b/qapi/block-core.json > index 11134a8..e68a59f 100644 > --- a/qapi/block-core.json > +++ b/qapi/block-core.json > @@ -1376,12 +1376,14 @@ > # > # @host_device, @host_cdrom: Since 2.1 > # > +# @nbd: Since 2.5 > +# > # Since: 2.0 > ## > { 'enum': 'BlockdevDriver', > 'data': [ 'archipelago', 'blkdebug', 'blkverify', 'bochs', 'cloop', > 'dmg', 'file', 'ftp', 'ftps', 'host_cdrom', 'host_device', > - 'http', 'https', 'null-aio', 'null-co', 'parallels', > + 'http', 'https', 'nbd', 'null-aio', 'null-co', 'parallels', > 'qcow', 'qcow2', 'qed', 'quorum', 'raw', 'tftp', 'vdi', 'vhdx', > 'vmdk', 'vpc', 'vvfat' ] } > > @@ -1797,6 +1799,42 @@ > '*read-pattern': 'QuorumReadPattern' } } > > ## > +# @BlockdevOptionsNBD > +# > +# Driver specific block device options for NBD > +# > +# @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 > +# > +# @path: #optional filesystem path to use > +# > +# @host: #optional host part of the address > +# > +# @port: #optional port part of the address > +# > +# @ipv4: #optional whether to accept IPv4 addresses, default try both IPv4 > +# and IPv6 > +# > +# @ipv6: #optional whether to accept IPv6 addresses, default try both IPv4 > +# and IPv6 > +# > +# @export: #optional the NBD export name > +# > +# Since: 2.5 > +## > +{ 'struct': 'BlockdevOptionsNBD', > + 'data': { '*filename': 'str', > + '*path': 'str', > + '*host': 'str', > + '*port': 'str', > + '*ipv4': 'bool', > + '*ipv6': 'bool', > + '*export': 'str' } } > + > +## I'm afraid this doesn't address Eric's review of your v2. In v2, you had { 'struct': 'BlockdevOptionsNBD', 'base': 'InetSocketAddress', 'data': { '*export': 'str' } } Eric observed that InetSocketAddress can represent a port range. Since NBD doesn't support a range, he suggested to have two types rather than InetSocketAddress: one to represent a single port, and another one to represent a port range. He further suggested to make the single port type a base type of the port range type. Eric further observed that support for the nbd+unix transport was missing, and suggested to have a union type combining the various transports. Instead of that, you simply replaced InetSocketAddress by a bunch of optional arguments with (unspoken!) conditions, such as "either filename, or path+host". That's not how we want things done in the schema. If we decide we want types separate for single ports and port range, you need those two types. For either one, you need a union type combining transports. It already exists for port ranges: SocketAddress. You need to create the other. We can then discuss names. For me, InetSocketAddress and SocketAddress strongly suggest single port. I'd prefer naming the port range types *AddressRange or something. If we decide separate types for single port and port ranges aren't worthwhile, you can simply use SocketAddress where your v2 used InetSocketAddress. Eric, how strongly do you feel about separating the two? > # @BlockdevOptions > # > # Options for creating a block device. > @@ -1822,7 +1860,7 @@ > 'http': 'BlockdevOptionsFile', > 'https': 'BlockdevOptionsFile', > # TODO iscsi: Wait for structured options > -# TODO nbd: Should take InetSocketAddress for 'host'? > + 'nbd': 'BlockdevOptionsNBD', > # TODO nfs: Wait for structured options > 'null-aio': 'BlockdevOptionsNull', > 'null-co': 'BlockdevOptionsNull',