From patchwork Wed Feb 3 16:33:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Reitz X-Patchwork-Id: 8204941 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9E5A79F1C0 for ; Wed, 3 Feb 2016 16:33:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0299520270 for ; Wed, 3 Feb 2016 16:33:50 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 439CB20266 for ; Wed, 3 Feb 2016 16:33:49 +0000 (UTC) Received: from localhost ([::1]:36145 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aR0NI-00078d-MS for patchwork-qemu-devel@patchwork.kernel.org; Wed, 03 Feb 2016 11:33:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aR0N2-00073e-Da for qemu-devel@nongnu.org; Wed, 03 Feb 2016 11:33:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aR0My-0007nD-GS for qemu-devel@nongnu.org; Wed, 03 Feb 2016 11:33:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38998) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aR0Mt-0007lo-9W; Wed, 03 Feb 2016 11:33:23 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id E97D1CF92; Wed, 3 Feb 2016 16:33:22 +0000 (UTC) Received: from localhost (ovpn-116-41.ams2.redhat.com [10.36.116.41]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u13GXLkE005121 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 3 Feb 2016 11:33:22 -0500 From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 3 Feb 2016 17:33:16 +0100 Message-Id: <1454517196-4560-3-git-send-email-mreitz@redhat.com> In-Reply-To: <1454517196-4560-1-git-send-email-mreitz@redhat.com> References: <1454517196-4560-1-git-send-email-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Kevin Wolf , qemu-devel@nongnu.org, Markus Armbruster , Paolo Bonzini , Max Reitz Subject: [Qemu-devel] [PATCH 2/2] qapi: Allow blockdev-add for NBD X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We have to introduce a new object (BlockdevOptionsNbd) for several reasons: - Neither of InetSocketAddress nor UnixSocketAddress alone is sufficient, because both are supported - We cannot use SocketAddress because NBD does not support an fd, and because it is not a flat union which BlockdevOptionsNbd is - We cannot use a flat union of InetSocketAddress and UnixSocketAddress because we would need some kind of discriminator which we do not have; we could inline the UnixSocketAddress as a string and then make it an 'alternate' type instead of a union, but this will not work either, because: - InetSocketAddress itself is not suitable for NBD because the port is not optional (which it is for NBD) and because it offers more options (like choosing between ipv4 and ipv6) which NBD does not support. Signed-off-by: Max Reitz --- qapi/block-core.json | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index 33012b8..e1b8543 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1567,13 +1567,14 @@ # Drivers that are supported in block device operations. # # @host_device, @host_cdrom: Since 2.1 +# @nbd: Since 2.6 # # 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' ] } @@ -2002,6 +2003,29 @@ '*read-pattern': 'QuorumReadPattern' } } ## +# @BlockdevOptionsNbd +# +# Driver specific block device options for NBD. Either of @host or @path must be +# specified, but not both. +# +# @host: #optional Connects to the given host using TCP. +# +# @port: #optional Specifies the TCP port to connect to; may be used only in +# conjunction with @host. Defaults to 10809. +# +# @path: #optional Connects to the given Unix socket path. +# +# @export: #optional Name of the NBD export to open. +# +# Since: 2.6 +## +{ 'struct': 'BlockdevOptionsNbd', + 'data': { '*host': 'str', + '*port': 'str', + '*path': 'str', + '*export': 'str' } } + +## # @BlockdevOptions # # Options for creating a block device. @@ -2027,7 +2051,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',