From patchwork Tue Feb 21 15:40:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 9585171 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DCF87600CA for ; Tue, 21 Feb 2017 17:09:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5BE22861E for ; Tue, 21 Feb 2017 17:09:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B844D28620; Tue, 21 Feb 2017 17:09:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 2208C28619 for ; Tue, 21 Feb 2017 17:09:41 +0000 (UTC) Received: from localhost ([::1]:47019 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgDwa-0006Km-IM for patchwork-qemu-devel@patchwork.kernel.org; Tue, 21 Feb 2017 12:09:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgCYx-0005wm-Bn for qemu-devel@nongnu.org; Tue, 21 Feb 2017 10:41:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgCYw-0004OF-5R for qemu-devel@nongnu.org; Tue, 21 Feb 2017 10:41:11 -0500 Received: from mx1.redhat.com ([209.132.183.28]:33350) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgCYr-0004Kt-N4; Tue, 21 Feb 2017 10:41:05 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CA33C7FB96; Tue, 21 Feb 2017 15:41:05 +0000 (UTC) Received: from localhost (ovpn-116-19.phx2.redhat.com [10.3.116.19]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1LFf4t2004216 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 21 Feb 2017 10:41:05 -0500 From: Jeff Cody To: qemu-block@nongnu.org Date: Tue, 21 Feb 2017 10:40:54 -0500 Message-Id: <20170221154057.20313-7-jcody@redhat.com> In-Reply-To: <20170221154057.20313-1-jcody@redhat.com> References: <20170221154057.20313-1-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 21 Feb 2017 15:41:05 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 6/9] iscsi: Add blockdev-add support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: peter.maydell@linaro.org, jcody@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Kevin Wolf This adds blockdev-add support for iscsi devices. Reviewed-by: Daniel P. Berrange Reviewed-by: Fam Zheng Signed-off-by: Kevin Wolf Signed-off-by: Jeff Cody --- block/iscsi.c | 14 ++++++---- qapi/block-core.json | 75 ++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 79 insertions(+), 10 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index 3adb9b1..c4f813b 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1291,13 +1291,13 @@ static void apply_header_digest(struct iscsi_context *iscsi, QemuOpts *opts, digest = qemu_opt_get(opts, "header-digest"); if (!digest) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C); - } else if (!strcmp(digest, "CRC32C")) { + } else if (!strcmp(digest, "crc32c")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_CRC32C); - } else if (!strcmp(digest, "NONE")) { + } else if (!strcmp(digest, "none")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE); - } else if (!strcmp(digest, "CRC32C-NONE")) { + } else if (!strcmp(digest, "crc32c-none")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_CRC32C_NONE); - } else if (!strcmp(digest, "NONE-CRC32C")) { + } else if (!strcmp(digest, "none-crc32c")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C); } else { error_setg(errp, "Invalid header-digest setting : %s", digest); @@ -1576,7 +1576,11 @@ static void iscsi_parse_iscsi_option(const char *target, QDict *options) header_digest = qemu_opt_get(opts, "header-digest"); if (header_digest) { - qdict_set_default_str(options, "header-digest", header_digest); + /* -iscsi takes upper case values, but QAPI only supports lower case + * enum constant names, so we have to convert here. */ + char *qapi_value = g_ascii_strdown(header_digest, -1); + qdict_set_default_str(options, "header-digest", qapi_value); + g_free(qapi_value); } timeout = qemu_opt_get(opts, "timeout"); diff --git a/qapi/block-core.json b/qapi/block-core.json index 932f5bb..ea9b04a 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2110,16 +2110,17 @@ # @nfs: Since 2.8 # @replication: Since 2.8 # @ssh: Since 2.8 +# @iscsi: Since 2.9 # # Since: 2.0 ## { 'enum': 'BlockdevDriver', 'data': [ 'archipelago', 'blkdebug', 'blkverify', 'bochs', 'cloop', 'dmg', 'file', 'ftp', 'ftps', 'gluster', 'host_cdrom', - 'host_device', 'http', 'https', 'luks', 'nbd', 'nfs', 'null-aio', - 'null-co', 'parallels', 'qcow', 'qcow2', 'qed', 'quorum', 'raw', - 'replication', 'ssh', 'vdi', 'vhdx', 'vmdk', 'vpc', - 'vvfat' ] } + 'host_device', 'http', 'https', 'iscsi', 'luks', 'nbd', 'nfs', + 'null-aio', 'null-co', 'parallels', 'qcow', 'qcow2', 'qed', + 'quorum', 'raw', 'replication', 'ssh', 'vdi', 'vhdx', 'vmdk', + 'vpc', 'vvfat' ] } ## # @BlockdevOptionsFile: @@ -2601,6 +2602,70 @@ '*logfile': 'str' } } ## +# @IscsiTransport: +# +# An enumeration of libiscsi transport types +# +# Since: 2.9 +## +{ 'enum': 'IscsiTransport', + 'data': [ 'tcp', 'iser' ] } + +## +# @IscsiHeaderDigest: +# +# An enumeration of header digests supported by libiscsi +# +# Since: 2.9 +## +{ 'enum': 'IscsiHeaderDigest', + 'prefix': 'QAPI_ISCSI_HEADER_DIGEST', + 'data': [ 'crc32c', 'none', 'crc32c-none', 'none-crc32c' ] } + +## +# @BlockdevOptionsIscsi: +# +# @transport The iscsi transport type +# +# @portal The address of the iscsi portal +# +# @target The target iqn name +# +# @lun #optional LUN to connect to. Defaults to 0. +# +# @user #optional User name to log in with. If omitted, no CHAP +# authentication is performed. +# +# @password-secret #optional The ID of a QCryptoSecret object providing +# the password for the login. This option is required if +# @user is specified. +# +# @initiator-name #optional The iqn name we want to identify to the target +# as. If this option is not specified, an initiator name is +# generated automatically. +# +# @header-digest #optional The desired header digest. Defaults to +# none-crc32c. +# +# @timeout #optional Timeout in seconds after which a request will +# timeout. 0 means no timeout and is the default. +# +# Driver specific block device options for iscsi +# +# Since: 2.9 +## +{ 'struct': 'BlockdevOptionsIscsi', + 'data': { 'transport': 'IscsiTransport', + 'portal': 'str', + 'target': 'str', + '*lun': 'int', + '*user': 'str', + '*password-secret': 'str', + '*initiator-name': 'str', + '*header-digest': 'IscsiHeaderDigest', + '*timeout': 'int' } } + +## # @ReplicationMode: # # An enumeration of replication modes. @@ -2786,7 +2851,7 @@ 'host_device':'BlockdevOptionsFile', 'http': 'BlockdevOptionsCurl', 'https': 'BlockdevOptionsCurl', -# TODO iscsi: Wait for structured options + 'iscsi': 'BlockdevOptionsIscsi', 'luks': 'BlockdevOptionsLUKS', 'nbd': 'BlockdevOptionsNbd', 'nfs': 'BlockdevOptionsNfs',