[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-block] [RFC PATCH 2/6] iscsi: Handle -iscsi user/password in b
From: |
Daniel P. Berrange |
Subject: |
Re: [Qemu-block] [RFC PATCH 2/6] iscsi: Handle -iscsi user/password in bdrv_parse_filename() |
Date: |
Thu, 8 Dec 2016 13:42:08 +0000 |
User-agent: |
Mutt/1.7.1 (2016-10-04) |
On Thu, Dec 08, 2016 at 02:23:07PM +0100, Kevin Wolf wrote:
> This splits the logic in the old parse_chap() function into a part that
> parses the -iscsi options into the new driver-specific options, and
> another part that actually applies those options (called apply_chap()
> now).
>
> Note that this means that username and password specified with -iscsi
> only take effect when a URL is provided. This is intentional, -iscsi is
> a legacy interface only supported for compatibility, new users should
> use the proper driver-specific options.
>
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
> block/iscsi.c | 72
> +++++++++++++++++++++++++++++++----------------------------
> 1 file changed, 38 insertions(+), 34 deletions(-)
>
> diff --git a/block/iscsi.c b/block/iscsi.c
> index 7a6664e..c5106c1 100644
> --- a/block/iscsi.c
> +++ b/block/iscsi.c
> @@ -1235,29 +1235,14 @@ retry:
> return 0;
> }
>
> -static void parse_chap(struct iscsi_context *iscsi, const char *target,
> +static void apply_chap(struct iscsi_context *iscsi, QemuOpts *opts,
> Error **errp)
> {
> - QemuOptsList *list;
> - QemuOpts *opts;
> const char *user = NULL;
> const char *password = NULL;
> const char *secretid;
> char *secret = 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;
> - }
> - }
> -
> user = qemu_opt_get(opts, "user");
> if (!user) {
> return;
> @@ -1586,6 +1571,35 @@ out:
> }
> }
>
> +static void iscsi_parse_iscsi_option(const char *target, QDict *options)
> +{
> + QemuOptsList *list;
> + QemuOpts *opts;
> + const char *user;
> +
> + 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;
> + }
> + }
> +
> + user = qemu_opt_get(opts, "user");
> + if (user) {
> + qdict_set_default_str(options, "user", user);
> + qdict_set_default_str(options, "password",
> + qemu_opt_get(opts, "password"));
> + qdict_set_default_str(options, "password-secret",
> + qemu_opt_get(opts, "password-secret"));
This core dumps if you set '-iscsi user=foo' but don't set password
or password-secret
#0 0x00007fffda7e2046 in strlen () at /lib64/libc.so.6
#1 0x0000555555b012f9 in qstring_from_str (address@hidden) at
qobject/qstring.c:66
#2 0x0000555555b02148 in qdict_set_default_str (address@hidden, address@hidden
"password", val=0x0) at qobject/qdict.c:490
#3 0x0000555555ab515f in iscsi_parse_iscsi_option (options=0x5555566ea7d0,
target=0x5555566f0eb0 "iqn.2004-04.fedora:fedora25:iscsi.kvm") at
block/iscsi.c:1545
#4 0x0000555555ab515f in iscsi_parse_filename (filename=<optimized out>,
options=0x5555566ea7d0, errp=<optimized out>) at block/iscsi.c:1610
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|
- [Qemu-block] [RFC PATCH 0/6] iscsi: Add blockdev-add support, Kevin Wolf, 2016/12/08
- [Qemu-block] [RFC PATCH 2/6] iscsi: Handle -iscsi user/password in bdrv_parse_filename(), Kevin Wolf, 2016/12/08
- Re: [Qemu-block] [RFC PATCH 2/6] iscsi: Handle -iscsi user/password in bdrv_parse_filename(),
Daniel P. Berrange <=
- [Qemu-block] [RFC PATCH 1/6] iscsi: Split URL into individual options, Kevin Wolf, 2016/12/08
- [Qemu-block] [RFC PATCH 3/6] iscsi: Add initiator-name option, Kevin Wolf, 2016/12/08
- [Qemu-block] [RFC PATCH 4/6] iscsi: Add header-digest option, Kevin Wolf, 2016/12/08
- [Qemu-block] [RFC PATCH 6/6] iscsi: Add blockdev-add support, Kevin Wolf, 2016/12/08