From patchwork Wed Jan 25 17:42:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 719769 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v7sqm0bVrz9s3T for ; Thu, 26 Jan 2017 04:44:20 +1100 (AEDT) Received: from localhost ([::1]:33454 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWRcH-0006Jb-LX for incoming@patchwork.ozlabs.org; Wed, 25 Jan 2017 12:44:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cWRaM-0004Tc-Jy for qemu-devel@nongnu.org; Wed, 25 Jan 2017 12:42:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cWRaL-0005gl-Im for qemu-devel@nongnu.org; Wed, 25 Jan 2017 12:42:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45678) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cWRaI-0005eW-Og; Wed, 25 Jan 2017 12:42:14 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (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 DA92683F3E; Wed, 25 Jan 2017 17:42:14 +0000 (UTC) Received: from localhost (ovpn-116-248.phx2.redhat.com [10.3.116.248]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v0PHgEeu001761 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 25 Jan 2017 12:42:14 -0500 From: Jeff Cody To: qemu-devel@nongnu.org Date: Wed, 25 Jan 2017 12:42:05 -0500 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 25 Jan 2017 17:42:14 +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] [PATCH v2 4/7] iscsi: Add header-digest option 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: kwolf@redhat.com, pbonzini@redhat.com, qemu-block@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Kevin Wolf This was previously only available with -iscsi. Again, after this patch, the -iscsi option only takes effect if an URL is given. New users are supposed to use the new driver-specific option. Reviewed-by: Daniel P. Berrange Signed-off-by: Kevin Wolf Signed-off-by: Jeff Cody Reviewed-by: Fam Zheng --- block/iscsi.c | 39 +++++++++++++++------------------------ 1 file changed, 15 insertions(+), 24 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index 3401b7e..a989b52 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1274,32 +1274,15 @@ static void apply_chap(struct iscsi_context *iscsi, QemuOpts *opts, g_free(secret); } -static void parse_header_digest(struct iscsi_context *iscsi, const char *target, +static void apply_header_digest(struct iscsi_context *iscsi, QemuOpts *opts, Error **errp) { - QemuOptsList *list; - QemuOpts *opts; const char *digest = NULL; - list = qemu_find_opts("iscsi"); - if (!list) { - return; - } - - opts = qemu_opts_find(list, target); - if (opts == NULL) { - opts = QTAILQ_FIRST(&list->head); - if (!opts) { - return; - } - } - digest = qemu_opt_get(opts, "header-digest"); if (!digest) { - return; - } - - if (!strcmp(digest, "CRC32C")) { + iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C); + } else if (!strcmp(digest, "CRC32C")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_CRC32C); } else if (!strcmp(digest, "NONE")) { iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE); @@ -1565,7 +1548,8 @@ static void iscsi_parse_iscsi_option(const char *target, QDict *options) { QemuOptsList *list; QemuOpts *opts; - const char *user, *password, *password_secret, *initiator_name; + const char *user, *password, *password_secret, *initiator_name, + *header_digest; list = qemu_find_opts("iscsi"); if (!list) { @@ -1599,6 +1583,11 @@ static void iscsi_parse_iscsi_option(const char *target, QDict *options) if (initiator_name) { qdict_set_default_str(options, "initiator-name", initiator_name); } + + header_digest = qemu_opt_get(opts, "header-digest"); + if (header_digest) { + qdict_set_default_str(options, "header-digest", header_digest); + } } /* @@ -1687,6 +1676,10 @@ static QemuOptsList runtime_opts = { .name = "initiator-name", .type = QEMU_OPT_STRING, }, + { + .name = "header-digest", + .type = QEMU_OPT_STRING, + }, { /* end of list */ } }, }; @@ -1778,10 +1771,8 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, goto out; } - iscsi_set_header_digest(iscsi, ISCSI_HEADER_DIGEST_NONE_CRC32C); - /* check if we got HEADER_DIGEST via the options */ - parse_header_digest(iscsi, target, &local_err); + apply_header_digest(iscsi, opts, &local_err); if (local_err != NULL) { error_propagate(errp, local_err); ret = -EINVAL;