From patchwork Tue Mar 19 08:19:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 228945 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A5C922C00B8 for ; Tue, 19 Mar 2013 19:21:06 +1100 (EST) Received: from localhost ([::1]:55468 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHrn6-00057Z-RP for incoming@patchwork.ozlabs.org; Tue, 19 Mar 2013 04:21:04 -0400 Received: from eggs.gnu.org ([208.118.235.92]:41121) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHrlQ-0002rQ-Rm for qemu-devel@nongnu.org; Tue, 19 Mar 2013 04:19:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UHrlN-0000LZ-P8 for qemu-devel@nongnu.org; Tue, 19 Mar 2013 04:19:20 -0400 Received: from [2a02:248:0:30:223:aeff:fefe:7f1c] (port=37652 helo=dns.kamp-intra.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UHrlN-0000L9-85 for qemu-devel@nongnu.org; Tue, 19 Mar 2013 04:19:17 -0400 Received: from lieven-pc.kamp-intra.net (lieven-pc.kamp-intra.net [172.21.12.60]) by dns.kamp-intra.net (Postfix) with ESMTP id 3CCA4206E9; Tue, 19 Mar 2013 09:19:15 +0100 (CET) Received: by lieven-pc.kamp-intra.net (Postfix, from userid 1000) id B6F8C5FE95; Tue, 19 Mar 2013 09:19:21 +0100 (CET) From: Peter Lieven To: qemu-devel@nongnu.org Date: Tue, 19 Mar 2013 09:19:18 +0100 Message-Id: <1363681158-26122-3-git-send-email-pl@kamp.de> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1363681158-26122-1-git-send-email-pl@kamp.de> References: <1363681158-26122-1-git-send-email-pl@kamp.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2a02:248:0:30:223:aeff:fefe:7f1c Cc: Peter Lieven Subject: [Qemu-devel] [PATCH 2/2] vl.c: fix segfault in iscsi options parsing 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org this patch fixes parsing of iscsi options such as initiator-name passed to command line via -iscsi option group. because iscsi options where registered too late qemu_find_opts returned NULL leading to a segfault in qemu_opts_parse. Signed-off-by: Peter Lieven --- block/iscsi.c | 27 --------------------------- vl.c | 40 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 30 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index 3d52921..23d4210 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1263,36 +1263,9 @@ static BlockDriver bdrv_iscsi = { #endif }; -static QemuOptsList qemu_iscsi_opts = { - .name = "iscsi", - .head = QTAILQ_HEAD_INITIALIZER(qemu_iscsi_opts.head), - .desc = { - { - .name = "user", - .type = QEMU_OPT_STRING, - .help = "username for CHAP authentication to target", - },{ - .name = "password", - .type = QEMU_OPT_STRING, - .help = "password for CHAP authentication to target", - },{ - .name = "header-digest", - .type = QEMU_OPT_STRING, - .help = "HeaderDigest setting. " - "{CRC32C|CRC32C-NONE|NONE-CRC32C|NONE}", - },{ - .name = "initiator-name", - .type = QEMU_OPT_STRING, - .help = "Initiator iqn name to use when connecting", - }, - { /* end of list */ } - }, -}; - static void iscsi_block_init(void) { bdrv_register(&bdrv_iscsi); - qemu_add_opts(&qemu_iscsi_opts); } block_init(iscsi_block_init); diff --git a/vl.c b/vl.c index ce51e65..9925675 100644 --- a/vl.c +++ b/vl.c @@ -517,6 +517,34 @@ static QemuOptsList qemu_tpmdev_opts = { }, }; +#ifdef CONFIG_LIBISCSI +static QemuOptsList qemu_iscsi_opts = { + .name = "iscsi", + .head = QTAILQ_HEAD_INITIALIZER(qemu_iscsi_opts.head), + .desc = { + { + .name = "user", + .type = QEMU_OPT_STRING, + .help = "username for CHAP authentication to target", + },{ + .name = "password", + .type = QEMU_OPT_STRING, + .help = "password for CHAP authentication to target", + },{ + .name = "header-digest", + .type = QEMU_OPT_STRING, + .help = "HeaderDigest setting. " + "{CRC32C|CRC32C-NONE|NONE-CRC32C|NONE}", + },{ + .name = "initiator-name", + .type = QEMU_OPT_STRING, + .help = "Initiator iqn name to use when connecting", + }, + { /* end of list */ } + }, +}; +#endif + const char *qemu_get_vm_name(void) { return qemu_name; @@ -2899,6 +2927,9 @@ int main(int argc, char **argv, char **envp) qemu_add_opts(&qemu_add_fd_opts); qemu_add_opts(&qemu_object_opts); qemu_add_opts(&qemu_tpmdev_opts); +#ifdef CONFIG_LIBISCSI + qemu_add_opts(&qemu_iscsi_opts); +#endif runstate_init(); @@ -3199,14 +3230,17 @@ int main(int argc, char **argv, char **envp) exit(1); } break; -#ifdef CONFIG_LIBISCSI case QEMU_OPTION_iscsi: - opts = qemu_opts_parse(qemu_find_opts("iscsi"), optarg, 0); + olist = qemu_find_opts("iscsi"); + if (!olist) { + fprintf(stderr, "iscsi is not supported by this qemu build.\n"); + exit(1); + } + opts = qemu_opts_parse(olist, optarg, 0); if (!opts) { exit(1); } break; -#endif #ifdef CONFIG_SLIRP case QEMU_OPTION_tftp: legacy_tftp_prefix = optarg;