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 <p...@kamp.de> --- 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; -- 1.7.9.5