From patchwork Thu Dec 8 13:23:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 9466379 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 698256071E for ; Thu, 8 Dec 2016 13:29:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55FE728585 for ; Thu, 8 Dec 2016 13:29:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48A6E28589; Thu, 8 Dec 2016 13:29:28 +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 BFC4128585 for ; Thu, 8 Dec 2016 13:29:27 +0000 (UTC) Received: from localhost ([::1]:53868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cEylJ-0001so-Aa for patchwork-qemu-devel@patchwork.kernel.org; Thu, 08 Dec 2016 08:29:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cEyfX-0005VH-FV for qemu-devel@nongnu.org; Thu, 08 Dec 2016 08:23:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cEyfW-00030K-IX for qemu-devel@nongnu.org; Thu, 08 Dec 2016 08:23:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42104) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cEyfU-0002w1-57; Thu, 08 Dec 2016 08:23:24 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (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 52BF48553C; Thu, 8 Dec 2016 13:23:23 +0000 (UTC) Received: from noname.str.redhat.com (dhcp-192-175.str.redhat.com [10.33.192.175]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uB8DNEMC009574; Thu, 8 Dec 2016 08:23:21 -0500 From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 8 Dec 2016 14:23:08 +0100 Message-Id: <1481203391-9523-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1481203391-9523-1-git-send-email-kwolf@redhat.com> References: <1481203391-9523-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 08 Dec 2016 13:23:23 +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] [RFC PATCH 3/6] 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: kwolf@redhat.com, jcody@redhat.com, pl@kamp.de, qemu-devel@nongnu.org, ptoscano@redhat.com, ronniesahlberg@gmail.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Kevin Wolf Reviewed-by: Daniel P. Berrange --- block/iscsi.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index c5106c1..7b909e8 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1311,26 +1311,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); @@ -1575,7 +1564,7 @@ static void iscsi_parse_iscsi_option(const char *target, QDict *options) { QemuOptsList *list; QemuOpts *opts; - const char *user; + const char *user, *initiator_name; list = qemu_find_opts("iscsi"); if (!list) { @@ -1598,6 +1587,11 @@ static void iscsi_parse_iscsi_option(const char *target, QDict *options) qdict_set_default_str(options, "password-secret", qemu_opt_get(opts, "password-secret")); } + + initiator_name = qemu_opt_get(opts, "initiator-name"); + if (initiator_name) { + qdict_set_default_str(options, "initiator-name", initiator_name); + } } /* @@ -1682,6 +1676,10 @@ static QemuOptsList runtime_opts = { .name = "lun", .type = QEMU_OPT_NUMBER, }, + { + .name = "initiator-name", + .type = QEMU_OPT_STRING, + }, { /* end of list */ } }, }; @@ -1738,7 +1736,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) {