From patchwork Tue Feb 21 15:40:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 730684 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 3vSR8P6MpPz9s2Q for ; Wed, 22 Feb 2017 03:41:09 +1100 (AEDT) Received: from localhost ([::1]:46808 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgDUx-0004cE-B2 for incoming@patchwork.ozlabs.org; Tue, 21 Feb 2017 11:41:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55203) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cgCYu-0005te-MG for qemu-devel@nongnu.org; Tue, 21 Feb 2017 10:41:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cgCYt-0004MW-Mx for qemu-devel@nongnu.org; Tue, 21 Feb 2017 10:41:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60026) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cgCYp-0004Jl-6S; Tue, 21 Feb 2017 10:41:03 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D71A34E02A; Tue, 21 Feb 2017 15:41:02 +0000 (UTC) Received: from localhost (ovpn-116-19.phx2.redhat.com [10.3.116.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8B49E6D9AF; Tue, 21 Feb 2017 15:41:02 +0000 (UTC) From: Jeff Cody To: qemu-block@nongnu.org Date: Tue, 21 Feb 2017 10:40:51 -0500 Message-Id: <20170221154057.20313-4-jcody@redhat.com> In-Reply-To: <20170221154057.20313-1-jcody@redhat.com> References: <20170221154057.20313-1-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 21 Feb 2017 15:41:02 +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 3/9] iscsi: Add initiator-name 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: peter.maydell@linaro.org, jcody@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com 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 Reviewed-by: Fam Zheng Signed-off-by: Kevin Wolf Signed-off-by: Jeff Cody --- block/iscsi.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index ec26fc6..6db5615 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1321,26 +1321,15 @@ static void parse_header_digest(struct iscsi_context *iscsi, const char *target, } } -static char *parse_initiator_name(const char *target) +static char *get_initiator_name(QemuOpts *opts) { - QemuOptsList *list; - QemuOpts *opts; const char *name; char *iscsi_name; UuidInfo *uuid_info; - list = qemu_find_opts("iscsi"); - if (list) { - opts = qemu_opts_find(list, target); - if (!opts) { - opts = QTAILQ_FIRST(&list->head); - } - if (opts) { - name = qemu_opt_get(opts, "initiator-name"); - if (name) { - return g_strdup(name); - } - } + name = qemu_opt_get(opts, "initiator-name"); + if (name) { + return g_strdup(name); } uuid_info = qmp_query_uuid(NULL); @@ -1589,7 +1578,7 @@ static void iscsi_parse_iscsi_option(const char *target, QDict *options) { QemuOptsList *list; QemuOpts *opts; - const char *user, *password, *password_secret; + const char *user, *password, *password_secret, *initiator_name; list = qemu_find_opts("iscsi"); if (!list) { @@ -1618,6 +1607,11 @@ static void iscsi_parse_iscsi_option(const char *target, QDict *options) if (password_secret) { qdict_set_default_str(options, "password-secret", password_secret); } + + initiator_name = qemu_opt_get(opts, "initiator-name"); + if (initiator_name) { + qdict_set_default_str(options, "initiator-name", initiator_name); + } } /* @@ -1706,6 +1700,10 @@ static QemuOptsList runtime_opts = { .name = "lun", .type = QEMU_OPT_NUMBER, }, + { + .name = "initiator-name", + .type = QEMU_OPT_STRING, + }, { /* end of list */ } }, }; @@ -1762,7 +1760,7 @@ static int iscsi_open(BlockDriverState *bs, QDict *options, int flags, memset(iscsilun, 0, sizeof(IscsiLun)); - initiator_name = parse_initiator_name(target); + initiator_name = get_initiator_name(opts); iscsi = iscsi_create_context(initiator_name); if (iscsi == NULL) {